post-merge fixes
This commit is contained in:
parent
c18f0ed8ea
commit
09e2ba2d68
1 changed files with 46 additions and 49 deletions
|
@ -282,11 +282,10 @@ struct ClaimTrieChainFixture: public CClaimTrieCacheBase
|
||||||
clear(); // clears the internal cache
|
clear(); // clears the internal cache
|
||||||
for (int i = 0; i < num_blocks; ++i)
|
for (int i = 0; i < num_blocks; ++i)
|
||||||
{
|
{
|
||||||
std::unique_ptr<CBlockTemplate> pblocktemplate;
|
|
||||||
CScript coinbase_scriptpubkey;
|
CScript coinbase_scriptpubkey;
|
||||||
coinbase_scriptpubkey << CScriptNum(chainActive.Height());
|
coinbase_scriptpubkey << CScriptNum(chainActive.Height());
|
||||||
std::unique_ptr<CBlockTemplate> pblocktemplate = AssemblerForTest().CreateNewBlock(coinbase_scriptpubkey);
|
std::unique_ptr<CBlockTemplate> pblocktemplate = AssemblerForTest().CreateNewBlock(coinbase_scriptpubkey);
|
||||||
BOOST_CHECK_EQUAL(pblocktemplate != nullptr, true);
|
BOOST_CHECK(pblocktemplate != nullptr);
|
||||||
if (!added_unchecked)
|
if (!added_unchecked)
|
||||||
BOOST_CHECK_EQUAL(pblocktemplate->block.vtx.size(), num_txs_for_next_block + 1);
|
BOOST_CHECK_EQUAL(pblocktemplate->block.vtx.size(), num_txs_for_next_block + 1);
|
||||||
BOOST_CHECK_EQUAL(CreateBlock(pblocktemplate), true);
|
BOOST_CHECK_EQUAL(CreateBlock(pblocktemplate), true);
|
||||||
|
@ -596,29 +595,29 @@ BOOST_AUTO_TEST_CASE(claim_locktime_test)
|
||||||
// the future, staged for automatic takeover if accepted.
|
// the future, staged for automatic takeover if accepted.
|
||||||
CMutableTransaction tx1 = fixture.MakeClaim(fixture.GetCoinbase(), "test", "one", 2, 10);
|
CMutableTransaction tx1 = fixture.MakeClaim(fixture.GetCoinbase(), "test", "one", 2, 10);
|
||||||
fixture.IncrementBlocks(1);
|
fixture.IncrementBlocks(1);
|
||||||
BOOST_CHECK_EQUAL(is_best_claim("test", tx1), predicate_false);
|
BOOST_CHECK(!fixture.is_best_claim("test", tx1));
|
||||||
CMutableTransaction tx2 = fixture.MakeClaim(fixture.GetCoinbase(), "test", "one", 1);
|
CMutableTransaction tx2 = fixture.MakeClaim(fixture.GetCoinbase(), "test", "one", 1);
|
||||||
fixture.IncrementBlocks(1);
|
fixture.IncrementBlocks(1);
|
||||||
BOOST_CHECK_EQUAL(is_best_claim("test", tx2), predicate_true);
|
BOOST_CHECK(fixture.is_best_claim("test", tx2));
|
||||||
|
|
||||||
// Forward to locktime expiration and takeover delay time.
|
// Forward to locktime expiration and takeover delay time.
|
||||||
fixture.IncrementBlocks(25);
|
fixture.IncrementBlocks(25);
|
||||||
BOOST_CHECK_EQUAL(is_best_claim("test", tx1), predicate_true);
|
BOOST_CHECK(fixture.is_best_claim("test", tx1));
|
||||||
|
|
||||||
// Abandon/Spend tx1.
|
// Abandon/Spend tx1.
|
||||||
fixture.Spend(tx1);
|
fixture.Spend(tx1);
|
||||||
fixture.IncrementBlocks(1);
|
fixture.IncrementBlocks(1);
|
||||||
|
|
||||||
// Ensure tx2 is now best.
|
// Ensure tx2 is now best.
|
||||||
BOOST_CHECK_EQUAL(is_best_claim("test", tx2), predicate_true);
|
BOOST_CHECK(fixture.is_best_claim("test", tx2));
|
||||||
|
|
||||||
// Rewind and check tx1 is best again.
|
// Rewind and check tx1 is best again.
|
||||||
fixture.DecrementBlocks(1);
|
fixture.DecrementBlocks(1);
|
||||||
BOOST_CHECK_EQUAL(is_best_claim("test", tx1), predicate_true);
|
BOOST_CHECK(fixture.is_best_claim("test", tx1));
|
||||||
|
|
||||||
// Rewind to before locktime and activation.
|
// Rewind to before locktime and activation.
|
||||||
fixture.DecrementBlocks(25);
|
fixture.DecrementBlocks(25);
|
||||||
BOOST_CHECK_EQUAL(is_best_claim("test", tx2), predicate_true);
|
BOOST_CHECK(fixture.is_best_claim("test", tx2));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -647,7 +646,7 @@ BOOST_AUTO_TEST_CASE(spend_claim_test)
|
||||||
// spending winning claim will make inactive claim winner
|
// spending winning claim will make inactive claim winner
|
||||||
CMutableTransaction tx3 = fixture.MakeClaim(fixture.GetCoinbase(), "test", "one", 2);
|
CMutableTransaction tx3 = fixture.MakeClaim(fixture.GetCoinbase(), "test", "one", 2);
|
||||||
fixture.IncrementBlocks(10);
|
fixture.IncrementBlocks(10);
|
||||||
BOOST_CHECK_EQUAL(is_best_claim("test", tx3), predicate_true);
|
BOOST_CHECK(fixture.is_best_claim("test",tx3));
|
||||||
CMutableTransaction tx4 = fixture.MakeClaim(fixture.GetCoinbase(), "test", "one", 2);
|
CMutableTransaction tx4 = fixture.MakeClaim(fixture.GetCoinbase(), "test", "one", 2);
|
||||||
fixture.IncrementBlocks(1);
|
fixture.IncrementBlocks(1);
|
||||||
BOOST_CHECK(fixture.is_best_claim("test",tx3));
|
BOOST_CHECK(fixture.is_best_claim("test",tx3));
|
||||||
|
@ -692,33 +691,32 @@ BOOST_AUTO_TEST_CASE(support_test)
|
||||||
CMutableTransaction s1 = fixture.MakeSupport(fixture.GetCoinbase(), tx1, "test", 1);
|
CMutableTransaction s1 = fixture.MakeSupport(fixture.GetCoinbase(), tx1, "test", 1);
|
||||||
CMutableTransaction s2 = fixture.MakeSupport(fixture.GetCoinbase(), tx2, "test", 10);
|
CMutableTransaction s2 = fixture.MakeSupport(fixture.GetCoinbase(), tx2, "test", 10);
|
||||||
fixture.IncrementBlocks(1);
|
fixture.IncrementBlocks(1);
|
||||||
BOOST_CHECK_EQUAL(is_best_claim("test", tx2), predicate_true);
|
BOOST_CHECK(fixture.is_best_claim("test", tx2));
|
||||||
BOOST_CHECK_EQUAL(best_claim_effective_amount_equals("test", 11), predicate_true);
|
BOOST_CHECK(fixture.best_claim_effective_amount_equals("test", 11));
|
||||||
fixture.DecrementBlocks(1);
|
fixture.DecrementBlocks(1);
|
||||||
|
|
||||||
// check support delay
|
// check support delay
|
||||||
CMutableTransaction tx3 = fixture.MakeClaim(fixture.GetCoinbase(), "test", "one", 1);
|
CMutableTransaction tx3 = fixture.MakeClaim(fixture.GetCoinbase(), "test", "one", 1);
|
||||||
CMutableTransaction tx4 = fixture.MakeClaim(fixture.GetCoinbase(), "test", "two", 2);
|
CMutableTransaction tx4 = fixture.MakeClaim(fixture.GetCoinbase(), "test", "two", 2);
|
||||||
fixture.IncrementBlocks(10);
|
fixture.IncrementBlocks(10);
|
||||||
BOOST_CHECK_EQUAL(is_best_claim("test", tx4), predicate_true);
|
BOOST_CHECK(fixture.is_best_claim("test", tx4));
|
||||||
BOOST_CHECK_EQUAL(best_claim_effective_amount_equals("test", 2), predicate_true);
|
BOOST_CHECK(fixture.best_claim_effective_amount_equals("test", 2));
|
||||||
CMutableTransaction s4 = fixture.MakeSupport(fixture.GetCoinbase(), tx3, "test", 10); //10 delay
|
CMutableTransaction s4 = fixture.MakeSupport(fixture.GetCoinbase(), tx3, "test", 10); //10 delay
|
||||||
fixture.IncrementBlocks(10);
|
fixture.IncrementBlocks(10);
|
||||||
BOOST_CHECK_EQUAL(is_best_claim("test", tx4), predicate_true);
|
BOOST_CHECK(fixture.is_best_claim("test", tx4));
|
||||||
BOOST_CHECK_EQUAL(best_claim_effective_amount_equals("test", 2), predicate_true);
|
BOOST_CHECK(fixture.best_claim_effective_amount_equals("test", 2));
|
||||||
fixture.IncrementBlocks(1);
|
fixture.IncrementBlocks(1);
|
||||||
BOOST_CHECK_EQUAL(is_best_claim("test", tx3), predicate_true);
|
BOOST_CHECK(fixture.is_best_claim("test", tx3));
|
||||||
BOOST_CHECK_EQUAL(best_claim_effective_amount_equals("test", 11), predicate_true);
|
BOOST_CHECK(fixture.best_claim_effective_amount_equals("test", 11));
|
||||||
|
|
||||||
fixture.DecrementBlocks(1);
|
fixture.DecrementBlocks(1);
|
||||||
BOOST_CHECK_EQUAL(is_best_claim("test", tx4), predicate_true);
|
BOOST_CHECK(fixture.is_best_claim("test", tx4));
|
||||||
BOOST_CHECK_EQUAL(best_claim_effective_amount_equals("test", 2), predicate_true);
|
BOOST_CHECK(fixture.best_claim_effective_amount_equals("test", 2));
|
||||||
fixture.DecrementBlocks(10);
|
fixture.DecrementBlocks(10);
|
||||||
BOOST_CHECK_EQUAL(is_best_claim("test", tx4), predicate_true);
|
BOOST_CHECK(fixture.is_best_claim("test", tx4));
|
||||||
BOOST_CHECK_EQUAL(best_claim_effective_amount_equals("test", 2), predicate_true);
|
BOOST_CHECK(fixture.best_claim_effective_amount_equals("test", 2));
|
||||||
fixture.DecrementBlocks(10);
|
fixture.DecrementBlocks(10);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
support on abandon
|
support on abandon
|
||||||
supporting a claim the same block it gets abandoned,
|
supporting a claim the same block it gets abandoned,
|
||||||
|
@ -971,8 +969,8 @@ BOOST_AUTO_TEST_CASE(claimtrie_expire_test)
|
||||||
|
|
||||||
// check claims expire and loses claim
|
// check claims expire and loses claim
|
||||||
CMutableTransaction tx1 = fixture.MakeClaim(fixture.GetCoinbase(),"test", "one", 2);
|
CMutableTransaction tx1 = fixture.MakeClaim(fixture.GetCoinbase(),"test", "one", 2);
|
||||||
fixture.IncrementBlocks(pclaimTrie->nExpirationTime);
|
fixture.IncrementBlocks(fixture.expirationTime());
|
||||||
BOOST_CHECK_EQUAL(is_best_claim("test", tx1), predicate_true);
|
BOOST_CHECK(fixture.is_best_claim("test", tx1));
|
||||||
CMutableTransaction tx2 = fixture.MakeClaim(fixture.GetCoinbase(),"test", "one", 1);
|
CMutableTransaction tx2 = fixture.MakeClaim(fixture.GetCoinbase(),"test", "one", 1);
|
||||||
fixture.IncrementBlocks(1);
|
fixture.IncrementBlocks(1);
|
||||||
BOOST_CHECK(fixture.is_best_claim("test", tx2));
|
BOOST_CHECK(fixture.is_best_claim("test", tx2));
|
||||||
|
@ -984,10 +982,10 @@ BOOST_AUTO_TEST_CASE(claimtrie_expire_test)
|
||||||
// check claims expire and is not updateable (may be changed in future soft fork)
|
// check claims expire and is not updateable (may be changed in future soft fork)
|
||||||
CMutableTransaction tx3 = fixture.MakeClaim(fixture.GetCoinbase(),"test", "one", 2);
|
CMutableTransaction tx3 = fixture.MakeClaim(fixture.GetCoinbase(),"test", "one", 2);
|
||||||
fixture.IncrementBlocks(1);
|
fixture.IncrementBlocks(1);
|
||||||
BOOST_CHECK_EQUAL(is_best_claim("test", tx3), predicate_true);
|
BOOST_CHECK(fixture.is_best_claim("test", tx3));
|
||||||
fixture.IncrementBlocks(pclaimTrie->nExpirationTime);
|
fixture.IncrementBlocks(fixture.expirationTime());
|
||||||
CMutableTransaction u1 = fixture.MakeUpdate(tx3, "test", "two", ClaimIdHash(tx3.GetHash(), 0), 2);
|
CMutableTransaction u1 = fixture.MakeUpdate(tx3, "test", "two", ClaimIdHash(tx3.GetHash(), 0), 2);
|
||||||
BOOST_CHECK_EQUAL(is_best_claim("test", u1), predicate_false);
|
BOOST_CHECK(!fixture.is_best_claim("test",u1));
|
||||||
|
|
||||||
fixture.DecrementBlocks(fixture.expirationTime());
|
fixture.DecrementBlocks(fixture.expirationTime());
|
||||||
BOOST_CHECK(fixture.is_best_claim("test", tx3));
|
BOOST_CHECK(fixture.is_best_claim("test", tx3));
|
||||||
|
@ -998,19 +996,19 @@ BOOST_AUTO_TEST_CASE(claimtrie_expire_test)
|
||||||
CMutableTransaction tx5 = fixture.MakeClaim(fixture.GetCoinbase(), "test", "one", 2);
|
CMutableTransaction tx5 = fixture.MakeClaim(fixture.GetCoinbase(), "test", "one", 2);
|
||||||
CMutableTransaction s1 = fixture.MakeSupport(fixture.GetCoinbase(), tx4, "test", 2);
|
CMutableTransaction s1 = fixture.MakeSupport(fixture.GetCoinbase(), tx4, "test", 2);
|
||||||
fixture.IncrementBlocks(1);
|
fixture.IncrementBlocks(1);
|
||||||
BOOST_CHECK_EQUAL(is_best_claim("test", tx4), predicate_true);
|
BOOST_CHECK(fixture.is_best_claim("test",tx4));
|
||||||
CMutableTransaction u2 = fixture.MakeUpdate(tx4, "test", "two", ClaimIdHash(tx4.GetHash(),0), 1);
|
CMutableTransaction u2 = fixture.MakeUpdate(tx4, "test", "two", ClaimIdHash(tx4.GetHash(),0), 1);
|
||||||
CMutableTransaction u3 = fixture.MakeUpdate(tx5, "test", "two", ClaimIdHash(tx5.GetHash(),0), 2);
|
CMutableTransaction u3 = fixture.MakeUpdate(tx5, "test", "two", ClaimIdHash(tx5.GetHash(),0), 2);
|
||||||
fixture.IncrementBlocks(pclaimTrie->nExpirationTime);
|
fixture.IncrementBlocks(fixture.expirationTime());
|
||||||
BOOST_CHECK_EQUAL(is_best_claim("test", u3), predicate_true);
|
BOOST_CHECK(fixture.is_best_claim("test", u3));
|
||||||
fixture.DecrementBlocks(pclaimTrie->nExpirationTime);
|
fixture.DecrementBlocks(fixture.expirationTime());
|
||||||
BOOST_CHECK_EQUAL(is_best_claim("test", tx4), predicate_true);
|
BOOST_CHECK(fixture.is_best_claim("test", tx4));
|
||||||
fixture.DecrementBlocks(1);
|
fixture.DecrementBlocks(1);
|
||||||
|
|
||||||
// check updated claims will extend expiration
|
// check updated claims will extend expiration
|
||||||
CMutableTransaction tx6 = fixture.MakeClaim(fixture.GetCoinbase(), "test", "one", 2);
|
CMutableTransaction tx6 = fixture.MakeClaim(fixture.GetCoinbase(), "test", "one", 2);
|
||||||
fixture.IncrementBlocks(1);
|
fixture.IncrementBlocks(1);
|
||||||
BOOST_CHECK_EQUAL(is_best_claim("test", tx6), predicate_true);
|
BOOST_CHECK(fixture.is_best_claim("test", tx6));
|
||||||
CMutableTransaction u4 = fixture.MakeUpdate(tx6, "test", "two", ClaimIdHash(tx6.GetHash(), 0), 2);
|
CMutableTransaction u4 = fixture.MakeUpdate(tx6, "test", "two", ClaimIdHash(tx6.GetHash(), 0), 2);
|
||||||
fixture.IncrementBlocks(1);
|
fixture.IncrementBlocks(1);
|
||||||
BOOST_CHECK(fixture.is_best_claim("test", u4));
|
BOOST_CHECK(fixture.is_best_claim("test", u4));
|
||||||
|
@ -1023,7 +1021,6 @@ BOOST_AUTO_TEST_CASE(claimtrie_expire_test)
|
||||||
fixture.DecrementBlocks(fixture.expirationTime());
|
fixture.DecrementBlocks(fixture.expirationTime());
|
||||||
BOOST_CHECK(fixture.is_best_claim("test", tx6));
|
BOOST_CHECK(fixture.is_best_claim("test", tx6));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* tests for CClaimTrie::getEffectiveAmountForClaim
|
* tests for CClaimTrie::getEffectiveAmountForClaim
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in a new issue