77#include < amount.h>
88#include < consensus/tx_check.h>
99#include < evo/assetlocktx.h>
10- #include < evo/creditpool.h>
1110#include < policy/settings.h>
1211#include < script/script.h>
1312#include < script/signingprovider.h>
13+ #include < util/ranges_set.h>
1414#include < validation.h> // for ::ChainActive()
1515
1616#include < boost/test/unit_test.hpp>
1717
18+
19+ #include < optional>
1820//
1921// Helper: create two dummy transactions, each with
2022// two outputs. The first has 11 and 50 CENT outputs
@@ -314,8 +316,7 @@ BOOST_FIXTURE_TEST_CASE(evo_assetunlock, TestChain100Setup)
314316 BOOST_CHECK (tx_state.IsValid ());
315317
316318 const CBlockIndex *block_index = ::ChainActive ().Tip ();
317- CCreditPool pool;
318- BOOST_CHECK (!CheckAssetUnlockTx (CTransaction (tx), block_index, pool, tx_state));
319+ BOOST_CHECK (!CheckAssetUnlockTx (CTransaction (tx), block_index, std::nullopt , tx_state));
319320 BOOST_CHECK (tx_state.GetRejectReason () == " bad-assetunlock-quorum-hash" );
320321
321322 {
@@ -333,7 +334,7 @@ BOOST_FIXTURE_TEST_CASE(evo_assetunlock, TestChain100Setup)
333334 std::string reason;
334335 BOOST_CHECK (IsStandardTx (CTransaction (tx), reason));
335336
336- BOOST_CHECK (!CheckAssetUnlockTx (CTransaction (txNonemptyInput), block_index, pool , tx_state));
337+ BOOST_CHECK (!CheckAssetUnlockTx (CTransaction (txNonemptyInput), block_index, std:: nullopt , tx_state));
337338 BOOST_CHECK (tx_state.GetRejectReason () == " bad-assetunlocktx-have-input" );
338339 }
339340
@@ -348,7 +349,7 @@ BOOST_FIXTURE_TEST_CASE(evo_assetunlock, TestChain100Setup)
348349 // Wrong type "Asset Lock TX" instead "Asset Unlock TX"
349350 CMutableTransaction txWrongType = tx;
350351 txWrongType.nType = TRANSACTION_ASSET_LOCK;
351- BOOST_CHECK (!CheckAssetUnlockTx (CTransaction (txWrongType), block_index, pool , tx_state));
352+ BOOST_CHECK (!CheckAssetUnlockTx (CTransaction (txWrongType), block_index, std:: nullopt , tx_state));
352353 BOOST_CHECK (tx_state.GetRejectReason () == " bad-assetunlocktx-type" );
353354
354355 // Check version of tx and payload
@@ -363,10 +364,10 @@ BOOST_FIXTURE_TEST_CASE(evo_assetunlock, TestChain100Setup)
363364 CMutableTransaction txWrongVersion = tx;
364365 SetTxPayload (txWrongVersion, unlockPayload_tmp);
365366 if (payload_version != 1 ) {
366- BOOST_CHECK (!CheckAssetUnlockTx (CTransaction (txWrongVersion), block_index, pool , tx_state));
367+ BOOST_CHECK (!CheckAssetUnlockTx (CTransaction (txWrongVersion), block_index, std:: nullopt , tx_state));
367368 BOOST_CHECK (tx_state.GetRejectReason () == " bad-assetunlocktx-version" );
368369 } else {
369- BOOST_CHECK (!CheckAssetUnlockTx (CTransaction (txWrongVersion), block_index, pool , tx_state));
370+ BOOST_CHECK (!CheckAssetUnlockTx (CTransaction (txWrongVersion), block_index, std:: nullopt , tx_state));
370371 BOOST_CHECK (tx_state.GetRejectReason () == " bad-assetunlock-quorum-hash" );
371372 }
372373 }
@@ -382,14 +383,23 @@ BOOST_FIXTURE_TEST_CASE(evo_assetunlock, TestChain100Setup)
382383 out.scriptPubKey = GetScriptForDestination (PKHash (key.GetPubKey ()));
383384 }
384385
385- BOOST_CHECK (!CheckAssetUnlockTx (CTransaction (txManyOutputs), block_index, pool, tx_state));
386+ BOOST_CHECK (!CheckAssetUnlockTx (CTransaction (txManyOutputs), block_index, std::nullopt , tx_state));
387+ BOOST_CHECK (tx_state.GetRejectReason () == " bad-assetunlock-quorum-hash" );
388+
389+ // Basic checks for CRangesSet
390+ CRangesSet indexes;
391+ BOOST_CHECK (!CheckAssetUnlockTx (CTransaction (txManyOutputs), block_index, indexes, tx_state));
386392 BOOST_CHECK (tx_state.GetRejectReason () == " bad-assetunlock-quorum-hash" );
393+ BOOST_CHECK (indexes.Add (0x001122334455667788L ));
394+ BOOST_CHECK (!CheckAssetUnlockTx (CTransaction (txManyOutputs), block_index, indexes, tx_state));
395+ BOOST_CHECK (tx_state.GetRejectReason () == " bad-assetunlock-duplicated-index" );
396+
387397
388398 // Should not be more than 32 withdrawal in one transaction
389399 txManyOutputs.vout .resize (outputsLimit + 1 );
390400 txManyOutputs.vout .back ().nValue = CENT;
391401 txManyOutputs.vout .back ().scriptPubKey = GetScriptForDestination (PKHash (key.GetPubKey ()));
392- BOOST_CHECK (!CheckAssetUnlockTx (CTransaction (txManyOutputs), block_index, pool , tx_state));
402+ BOOST_CHECK (!CheckAssetUnlockTx (CTransaction (txManyOutputs), block_index, std:: nullopt , tx_state));
393403 BOOST_CHECK (tx_state.GetRejectReason () == " bad-assetunlocktx-too-many-outs" );
394404 }
395405
0 commit comments