This commit is contained in:
Scott Sadler
2018-04-16 22:57:35 -05:00
parent 3205a566d4
commit 0cb91a8d20
30 changed files with 1002 additions and 289 deletions

View File

@@ -15,7 +15,6 @@
#include "testutils.h"
extern Eval* EVAL_TEST;
extern int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestamp);
@@ -61,7 +60,7 @@ static auto noop = [&](CMutableTransaction &mtx){};
template<typename Modifier>
void SetEval(EvalMock &eval, CMutableTransaction &notary, Modifier modify)
void SetupEval(EvalMock &eval, CMutableTransaction &notary, Modifier modify)
{
eval.nNotaries = komodo_notaries(eval.notaries, 780060, 1522946781);
@@ -80,8 +79,6 @@ void SetEval(EvalMock &eval, CMutableTransaction &notary, Modifier modify)
eval.txs[notary.GetHash()] = CTransaction(notary);
eval.blocks[notary.GetHash()].nHeight = 780060;
eval.blocks[notary.GetHash()].nTime = 1522946781;
EVAL_TEST = &eval;
}
@@ -94,12 +91,12 @@ static bool init = DecodeHexTx(notaryTx, rawNotaryTx);
static uint256 proofTxHash = uint256S("37f76551a16093fbb0a92ee635bbd45b3460da8fd00cf7d5a6b20d93e727fe4c");
static auto vMomProof = ParseHex("0303faecbdd4b3da128c2cd2701bb143820a967069375b2ec5b612f39bbfe78a8611978871c193457ab1e21b9520f4139f113b8d75892eb93ee247c18bccfd067efed7eacbfcdc8946cf22de45ad536ec0719034fb9bc825048fe6ab61fee5bd6e9aae0bb279738d46673c53d68eb2a72da6dbff215ee41a4d405a74ff7cd355805b"); // $ fiat/bots txMoMproof $proofTxHash
/*
TEST(TestEvalNotarisation, testGetNotarisation)
{
EvalMock eval;
CMutableTransaction notary(notaryTx);
SetEval(eval, notary, noop);
SetupEval(eval, notary, noop);
NotarisationData data;
ASSERT_TRUE(eval.GetNotarisationData(notary.GetHash(), data));
@@ -111,7 +108,7 @@ TEST(TestEvalNotarisation, testGetNotarisation)
MoMProof proof;
E_UNMARSHAL(vMomProof, ss >> proof);
EXPECT_EQ(data.MoM, proof.Exec(proofTxHash));
EXPECT_EQ(data.MoM, proof.branch.Exec(proofTxHash));
}
@@ -119,13 +116,14 @@ TEST(TestEvalNotarisation, testInvalidNotaryPubkey)
{
EvalMock eval;
CMutableTransaction notary(notaryTx);
SetEval(eval, notary, noop);
SetupEval(eval, notary, noop);
memset(eval.notaries[10], 0, 33);
NotarisationData data;
ASSERT_FALSE(eval.GetNotarisationData(notary.GetHash(), data));
}
*/
TEST(TestEvalNotarisation, testInvalidNotarisationBadOpReturn)
@@ -134,7 +132,7 @@ TEST(TestEvalNotarisation, testInvalidNotarisationBadOpReturn)
CMutableTransaction notary(notaryTx);
notary.vout[1].scriptPubKey = CScript() << OP_RETURN << 0;
SetEval(eval, notary, noop);
SetupEval(eval, notary, noop);
NotarisationData data;
ASSERT_FALSE(eval.GetNotarisationData(notary.GetHash(), data));
@@ -146,7 +144,7 @@ TEST(TestEvalNotarisation, testInvalidNotarisationTxNotEnoughSigs)
EvalMock eval;
CMutableTransaction notary(notaryTx);
SetEval(eval, notary, [](CMutableTransaction &tx) {
SetupEval(eval, notary, [](CMutableTransaction &tx) {
tx.vin.resize(10);
});
@@ -160,7 +158,7 @@ TEST(TestEvalNotarisation, testInvalidNotarisationTxDoesntExist)
EvalMock eval;
CMutableTransaction notary(notaryTx);
SetEval(eval, notary, noop);
SetupEval(eval, notary, noop);
NotarisationData data;
ASSERT_FALSE(eval.GetNotarisationData(uint256(), data));
@@ -172,7 +170,7 @@ TEST(TestEvalNotarisation, testInvalidNotarisationDupeNotary)
EvalMock eval;
CMutableTransaction notary(notaryTx);
SetEval(eval, notary, [](CMutableTransaction &tx) {
SetupEval(eval, notary, [](CMutableTransaction &tx) {
tx.vin[1] = tx.vin[3];
});
@@ -186,7 +184,7 @@ TEST(TestEvalNotarisation, testInvalidNotarisationInputNotCheckSig)
EvalMock eval;
CMutableTransaction notary(notaryTx);
SetEval(eval, notary, [&](CMutableTransaction &tx) {
SetupEval(eval, notary, [&](CMutableTransaction &tx) {
int i = 1;
CMutableTransaction txIn;
txIn.vout.resize(1);