@@ -749,91 +749,4 @@ BOOST_AUTO_TEST_CASE(MempoolAncestryTests)
749749 BOOST_CHECK_EQUAL (descendants, 6ULL );
750750}
751751
752- // ELEMENTS:
753- BOOST_AUTO_TEST_CASE (PeginSpentTest)
754- {
755- CBlockPolicyEstimator feeEst;
756- CTxMemPool pool (&feeEst);
757- LOCK2 (cs_main, pool.cs );
758-
759- std::set<std::pair<uint256, COutPoint> > setPeginsSpent;
760- TestMemPoolEntryHelper entry;
761-
762- std::pair<uint256, COutPoint> pegin1, pegin2, pegin3;
763- GetRandBytes (pegin1.first .begin (), pegin1.first .size ());
764- GetRandBytes (pegin2.first .begin (), pegin2.first .size ());
765- GetRandBytes (pegin3.first .begin (), pegin3.first .size ());
766- GetRandBytes (pegin1.second .hash .begin (), pegin1.second .hash .size ());
767- GetRandBytes (pegin2.second .hash .begin (), pegin2.second .hash .size ());
768- pegin3.second .hash = pegin2.second .hash ;
769- pegin1.second .n = 0 ;
770- pegin2.second .n = 0 ;
771- pegin3.second .n = 1 ;
772-
773- CMutableTransaction tx;
774- tx.vin .resize (1 );
775- tx.vout .resize (1 );
776- tx.vout [0 ].nValue = 0 ;
777- pool.addUnchecked (entry.PeginsSpent (setPeginsSpent).FromTx (tx));
778- BOOST_CHECK (pool.mapPeginsSpentToTxid .empty ());
779-
780- setPeginsSpent = {pegin1};
781- GetRandBytes (tx.vin [0 ].prevout .hash .begin (), tx.vin [0 ].prevout .hash .size ());
782- tx.vout .resize (2 );
783- tx.vout [1 ].nValue = 0 ;
784- const uint256 tx2Hash (tx.GetHash ());
785- pool.addUnchecked (entry.PeginsSpent (setPeginsSpent).FromTx (tx));
786- BOOST_CHECK_EQUAL (pool.mapPeginsSpentToTxid [pegin1].ToString (), tx2Hash.ToString ());
787-
788- setPeginsSpent = {pegin2};
789- GetRandBytes (tx.vin [0 ].prevout .hash .begin (), tx.vin [0 ].prevout .hash .size ());
790- tx.vout .resize (3 );
791- tx.vout [2 ].nValue = 0 ;
792- const uint256 tx3Hash (tx.GetHash ());
793- pool.addUnchecked (entry.PeginsSpent (setPeginsSpent).FromTx (tx));
794- BOOST_CHECK_EQUAL (pool.mapPeginsSpentToTxid [pegin2].ToString (), tx3Hash.ToString ());
795-
796- setPeginsSpent = {pegin3};
797- GetRandBytes (tx.vin [0 ].prevout .hash .begin (), tx.vin [0 ].prevout .hash .size ());
798- tx.vout .resize (4 );
799- tx.vout [3 ].nValue = 0 ;
800- CTransactionRef txref (MakeTransactionRef (tx));
801- pool.removeForBlock ({txref}, 1 , setPeginsSpent);
802-
803- BOOST_CHECK_EQUAL (pool.size (), 3 );
804- BOOST_CHECK_EQUAL (pool.mapPeginsSpentToTxid .size (), 2 );
805- BOOST_CHECK_EQUAL (pool.mapPeginsSpentToTxid [pegin1].ToString (), tx2Hash.ToString ());
806- BOOST_CHECK_EQUAL (pool.mapPeginsSpentToTxid [pegin2].ToString (), tx3Hash.ToString ());
807-
808- setPeginsSpent = {pegin1};
809- GetRandBytes (tx.vin [0 ].prevout .hash .begin (), tx.vin [0 ].prevout .hash .size ());
810- tx.vout .resize (5 );
811- tx.vout [4 ].nValue = 0 ;
812- txref = MakeTransactionRef (tx);
813- pool.removeForBlock ({txref}, 2 , setPeginsSpent);
814-
815- BOOST_CHECK_EQUAL (pool.size (), 2 );
816- BOOST_CHECK_EQUAL (pool.mapPeginsSpentToTxid .size (), 1 );
817- BOOST_CHECK_EQUAL (pool.mapPeginsSpentToTxid [pegin2].ToString (), tx3Hash.ToString ());
818-
819- setPeginsSpent = {pegin1, pegin3};
820- GetRandBytes (tx.vin [0 ].prevout .hash .begin (), tx.vin [0 ].prevout .hash .size ());
821- tx.vout .resize (6 );
822- tx.vout [5 ].nValue = 0 ;
823- const uint256 tx4Hash (tx.GetHash ());
824- pool.addUnchecked (entry.PeginsSpent (setPeginsSpent).FromTx (tx));
825- BOOST_CHECK_EQUAL (pool.mapPeginsSpentToTxid [pegin1].ToString (), tx4Hash.ToString ());
826- BOOST_CHECK_EQUAL (pool.mapPeginsSpentToTxid [pegin3].ToString (), tx4Hash.ToString ());
827-
828- setPeginsSpent = {pegin2, pegin3};
829- GetRandBytes (tx.vin [0 ].prevout .hash .begin (), tx.vin [0 ].prevout .hash .size ());
830- tx.vout .resize (7 );
831- tx.vout [6 ].nValue = 0 ;
832- txref = MakeTransactionRef (tx);
833- pool.removeForBlock ({txref}, 3 , setPeginsSpent);
834-
835- BOOST_CHECK_EQUAL (pool.size (), 1 );
836- BOOST_CHECK (pool.mapPeginsSpentToTxid .empty ());
837- }
838-
839752BOOST_AUTO_TEST_SUITE_END ()
0 commit comments