mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-25 10:43:19 -03:00
Merge #17363: test: add "diamond" unit test to MempoolAncestryTests
b2ff500fb3
test: add "diamond" unit test to MempoolAncestryTests (Sebastian Falbesoner) Pull request description: Approaches #17271 (_Missing Unit Test for Ancestors "diamond"_). If ancestors are represented more than once (in this case `ta` and `tb`), check that those are not overcounted. ACKs for top commit: laanwj: ACKb2ff500fb3
Tree-SHA512: 82a6573cc7f0e82bf6fcfe207d7ddecbf297d2a203d22e95b73d887e3cb280f45a3c5f649161561c1be1eb560ff81b9b385868f205d1c12284211c2377e5ad99
This commit is contained in:
commit
22e7eea629
1 changed files with 37 additions and 0 deletions
|
@ -749,6 +749,43 @@ BOOST_AUTO_TEST_CASE(MempoolAncestryTests)
|
|||
pool.GetTransactionAncestry(ty6->GetHash(), ancestors, descendants);
|
||||
BOOST_CHECK_EQUAL(ancestors, 9ULL);
|
||||
BOOST_CHECK_EQUAL(descendants, 6ULL);
|
||||
|
||||
/* Ancestors represented more than once ("diamond") */
|
||||
//
|
||||
// [ta].0 <- [tb].0 -----<------- [td].0
|
||||
// | |
|
||||
// \---1 <- [tc].0 --<--/
|
||||
//
|
||||
CTransactionRef ta, tb, tc, td;
|
||||
ta = make_tx(/* output_values */ {10 * COIN});
|
||||
tb = make_tx(/* output_values */ {5 * COIN, 3 * COIN}, /* inputs */ {ta});
|
||||
tc = make_tx(/* output_values */ {2 * COIN}, /* inputs */ {tb}, /* input_indices */ {1});
|
||||
td = make_tx(/* output_values */ {6 * COIN}, /* inputs */ {tb, tc}, /* input_indices */ {0, 0});
|
||||
pool.clear();
|
||||
pool.addUnchecked(entry.Fee(10000LL).FromTx(ta));
|
||||
pool.addUnchecked(entry.Fee(10000LL).FromTx(tb));
|
||||
pool.addUnchecked(entry.Fee(10000LL).FromTx(tc));
|
||||
pool.addUnchecked(entry.Fee(10000LL).FromTx(td));
|
||||
|
||||
// Ancestors / descendants should be:
|
||||
// transaction ancestors descendants
|
||||
// ============ =================== ===========
|
||||
// ta 1 (ta 4 (ta,tb,tc,td)
|
||||
// tb 2 (ta,tb) 4 (ta,tb,tc,td)
|
||||
// tc 3 (ta,tb,tc) 4 (ta,tb,tc,td)
|
||||
// td 4 (ta,tb,tc,td) 4 (ta,tb,tc,td)
|
||||
pool.GetTransactionAncestry(ta->GetHash(), ancestors, descendants);
|
||||
BOOST_CHECK_EQUAL(ancestors, 1ULL);
|
||||
BOOST_CHECK_EQUAL(descendants, 4ULL);
|
||||
pool.GetTransactionAncestry(tb->GetHash(), ancestors, descendants);
|
||||
BOOST_CHECK_EQUAL(ancestors, 2ULL);
|
||||
BOOST_CHECK_EQUAL(descendants, 4ULL);
|
||||
pool.GetTransactionAncestry(tc->GetHash(), ancestors, descendants);
|
||||
BOOST_CHECK_EQUAL(ancestors, 3ULL);
|
||||
BOOST_CHECK_EQUAL(descendants, 4ULL);
|
||||
pool.GetTransactionAncestry(td->GetHash(), ancestors, descendants);
|
||||
BOOST_CHECK_EQUAL(ancestors, 4ULL);
|
||||
BOOST_CHECK_EQUAL(descendants, 4ULL);
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
|
Loading…
Add table
Reference in a new issue