fix all tests

This commit is contained in:
Scott Sadler
2018-05-20 01:27:31 -03:00
parent b6ef9c089a
commit 0df96a2f06
8 changed files with 215 additions and 57 deletions

View File

@@ -147,12 +147,6 @@ bool Eval::CheckNotaryInputs(const CTransaction &tx, uint32_t height, uint32_t t
}
uint32_t Eval::GetCurrentLedgerID() const
{
return -1; // TODO
}
/*
* Get MoM from a notarisation tx hash (on KMD)
*/
@@ -171,6 +165,19 @@ bool Eval::GetNotarisationData(const uint256 notaryHash, NotarisationData &data)
*/
bool Eval::GetProofRoot(uint256 kmdNotarisationHash, uint256 &momom) const
{
return false; // TODO
}
uint32_t Eval::GetAssetchainsCC() const
{
return ASSETCHAINS_CC;
}
std::string Eval::GetAssetchainsSymbol() const
{
return std::string(ASSETCHAINS_SYMBOL);
}

View File

@@ -74,7 +74,8 @@ public:
virtual bool GetNotarisationData(uint256 notarisationHash, NotarisationData &data) const;
virtual bool GetProofRoot(uint256 kmdNotarisationHash, uint256 &momom) const;
virtual bool CheckNotaryInputs(const CTransaction &tx, uint32_t height, uint32_t timestamp) const;
virtual uint32_t GetCurrentLedgerID() const;
virtual uint32_t GetAssetchainsCC() const;
virtual std::string GetAssetchainsSymbol() const;
};

View File

@@ -12,30 +12,31 @@
*/
bool Eval::ImportCoin(const std::vector<uint8_t> params, const CTransaction &importTx, unsigned int nIn)
{
if (importTx.vout.size() == 0) return Invalid("no-vouts");
if (importTx.vout.size() < 2)
return Invalid("too-few-vouts");
// params
TxProof proof;
CTransaction burnTx;
if (!E_UNMARSHAL(params, ss >> proof; ss >> burnTx))
std::vector<CTxOut> payouts;
if (!UnmarshalImportTx(importTx, proof, burnTx, payouts))
return Invalid("invalid-params");
// Control all aspects of this transaction
// It must not be at all malleable
if (MakeImportCoinTransaction(proof, burnTx, importTx.vout).GetHash() != importTx.GetHash())
// It should not be at all malleable
if (MakeImportCoinTransaction(proof, burnTx, payouts).GetHash() != importTx.GetHash())
return Invalid("non-canonical");
// burn params
uint32_t chain; // todo
uint32_t targetCcid;
std::string targetSymbol;
uint256 payoutsHash;
std::vector<uint8_t> burnOpret;
if (burnTx.vout.size() == 0) return Invalid("invalid-burn-outputs");
GetOpReturnData(burnTx.vout[0].scriptPubKey, burnOpret);
if (!E_UNMARSHAL(burnOpret, ss >> VARINT(chain); ss >> payoutsHash))
return Invalid("invalid-burn-params");
// check chain
if (chain != GetCurrentLedgerID())
if (!UnmarshalBurnTx(burnTx, targetSymbol, &targetCcid, payoutsHash))
return Invalid("invalid-burn-tx");
if (targetCcid != GetAssetchainsCC() || targetSymbol != GetAssetchainsSymbol())
return Invalid("importcoin-wrong-chain");
// check burn amount
@@ -51,7 +52,7 @@ bool Eval::ImportCoin(const std::vector<uint8_t> params, const CTransaction &imp
}
// Check burntx shows correct outputs hash
if (payoutsHash != SerializeHash(importTx.vout))
if (payoutsHash != SerializeHash(payouts))
return Invalid("wrong-payouts");
// Check proof confirms existance of burnTx