mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 12:02:48 +01:00
refactor: use CTransaction for immutable tx in evo_assetlocks_tests
This commit is contained in:
parent
ca0fe8c208
commit
d9f0e93498
@ -134,7 +134,7 @@ BOOST_FIXTURE_TEST_CASE(evo_assetlock, TestChain100Setup)
|
||||
CKey key;
|
||||
key.MakeNewKey(true);
|
||||
|
||||
const CMutableTransaction tx = CreateAssetLockTx(keystore, coins, key);
|
||||
const CTransaction tx = CreateAssetLockTx(keystore, coins, key);
|
||||
std::string reason;
|
||||
BOOST_CHECK(IsStandardTx(CTransaction(tx), reason));
|
||||
|
||||
@ -159,7 +159,7 @@ BOOST_FIXTURE_TEST_CASE(evo_assetlock, TestChain100Setup)
|
||||
|
||||
{
|
||||
// Wrong type "Asset Unlock TX" instead "Asset Lock TX"
|
||||
CMutableTransaction txWrongType = tx;
|
||||
CMutableTransaction txWrongType(tx);
|
||||
txWrongType.nType = TRANSACTION_ASSET_UNLOCK;
|
||||
BOOST_CHECK(!CheckAssetLockTx(CTransaction(txWrongType), tx_state));
|
||||
BOOST_CHECK(tx_state.GetRejectReason() == "bad-assetlocktx-type");
|
||||
@ -175,13 +175,13 @@ BOOST_FIXTURE_TEST_CASE(evo_assetlock, TestChain100Setup)
|
||||
BOOST_CHECK(inSum == outSum);
|
||||
|
||||
// Outputs should not be bigger than inputs
|
||||
CMutableTransaction txBigOutput = tx;
|
||||
CMutableTransaction txBigOutput(tx);
|
||||
txBigOutput.vout[0].nValue += 1;
|
||||
BOOST_CHECK(!CheckAssetLockTx(CTransaction(txBigOutput), tx_state));
|
||||
BOOST_CHECK(tx_state.GetRejectReason() == "bad-assetlocktx-creditamount");
|
||||
|
||||
// Smaller outputs are allown
|
||||
CMutableTransaction txSmallOutput = tx;
|
||||
CMutableTransaction txSmallOutput(tx);
|
||||
txSmallOutput.vout[1].nValue -= 1;
|
||||
BOOST_CHECK(CheckAssetLockTx(CTransaction(txSmallOutput), tx_state));
|
||||
}
|
||||
@ -195,7 +195,7 @@ BOOST_FIXTURE_TEST_CASE(evo_assetlock, TestChain100Setup)
|
||||
wrongOutput[0].nValue += CENT;
|
||||
CAssetLockPayload greaterCreditsPayload(wrongOutput);
|
||||
|
||||
CMutableTransaction txGreaterCredits = tx;
|
||||
CMutableTransaction txGreaterCredits(tx);
|
||||
SetTxPayload(txGreaterCredits, greaterCreditsPayload);
|
||||
|
||||
BOOST_CHECK(!CheckAssetLockTx(CTransaction(txGreaterCredits), tx_state));
|
||||
@ -205,7 +205,7 @@ BOOST_FIXTURE_TEST_CASE(evo_assetlock, TestChain100Setup)
|
||||
wrongOutput[1].nValue -= 2 * CENT;
|
||||
CAssetLockPayload lessCreditsPayload(wrongOutput);
|
||||
|
||||
CMutableTransaction txLessCredits = tx;
|
||||
CMutableTransaction txLessCredits(tx);
|
||||
SetTxPayload(txLessCredits, lessCreditsPayload);
|
||||
|
||||
BOOST_CHECK(!CheckAssetLockTx(CTransaction(txLessCredits), tx_state));
|
||||
@ -218,7 +218,7 @@ BOOST_FIXTURE_TEST_CASE(evo_assetlock, TestChain100Setup)
|
||||
creditOutputsOutOfRange[0].nValue = 0;
|
||||
CAssetLockPayload invalidOutputsPayload(creditOutputsOutOfRange);
|
||||
|
||||
CMutableTransaction txInvalidOutputs = tx;
|
||||
CMutableTransaction txInvalidOutputs(tx);
|
||||
SetTxPayload(txInvalidOutputs, invalidOutputsPayload);
|
||||
|
||||
BOOST_CHECK(!CheckAssetLockTx(CTransaction(txInvalidOutputs), tx_state));
|
||||
@ -243,7 +243,7 @@ BOOST_FIXTURE_TEST_CASE(evo_assetlock, TestChain100Setup)
|
||||
creditOutputsNotPubkey[0].scriptPubKey = CScript() << OP_1;
|
||||
CAssetLockPayload notPubkeyPayload(creditOutputsNotPubkey);
|
||||
|
||||
CMutableTransaction txNotPubkey = tx;
|
||||
CMutableTransaction txNotPubkey(tx);
|
||||
SetTxPayload(txNotPubkey, notPubkeyPayload);
|
||||
|
||||
BOOST_CHECK(!CheckAssetLockTx(CTransaction(txNotPubkey), tx_state));
|
||||
@ -253,7 +253,7 @@ BOOST_FIXTURE_TEST_CASE(evo_assetlock, TestChain100Setup)
|
||||
|
||||
{
|
||||
// OP_RETURN must be only one, not more
|
||||
CMutableTransaction txMultipleReturn = tx;
|
||||
CMutableTransaction txMultipleReturn(tx);
|
||||
txMultipleReturn.vout[1].scriptPubKey = CScript() << OP_RETURN << ParseHex("");
|
||||
|
||||
BOOST_CHECK(!CheckAssetLockTx(CTransaction(txMultipleReturn), tx_state));
|
||||
@ -263,7 +263,7 @@ BOOST_FIXTURE_TEST_CASE(evo_assetlock, TestChain100Setup)
|
||||
|
||||
{
|
||||
// zero/negative OP_RETURN
|
||||
CMutableTransaction txReturnOutOfRange = tx;
|
||||
CMutableTransaction txReturnOutOfRange(tx);
|
||||
txReturnOutOfRange.vout[0].nValue = 0;
|
||||
|
||||
BOOST_CHECK(!CheckAssetLockTx(CTransaction(txReturnOutOfRange), tx_state));
|
||||
@ -278,7 +278,7 @@ BOOST_FIXTURE_TEST_CASE(evo_assetlock, TestChain100Setup)
|
||||
|
||||
{
|
||||
// OP_RETURN is missing
|
||||
CMutableTransaction txNoReturn = tx;
|
||||
CMutableTransaction txNoReturn(tx);
|
||||
txNoReturn.vout[0].scriptPubKey = GetScriptForDestination(PKHash(key.GetPubKey()));
|
||||
|
||||
BOOST_CHECK(!CheckAssetLockTx(CTransaction(txNoReturn), tx_state));
|
||||
@ -287,7 +287,7 @@ BOOST_FIXTURE_TEST_CASE(evo_assetlock, TestChain100Setup)
|
||||
|
||||
{
|
||||
// OP_RETURN should not have any data
|
||||
CMutableTransaction txReturnData = tx;
|
||||
CMutableTransaction txReturnData(tx);
|
||||
txReturnData.vout[0].scriptPubKey = CScript() << OP_RETURN << ParseHex("abc");
|
||||
|
||||
BOOST_CHECK(!CheckAssetLockTx(CTransaction(txReturnData), tx_state));
|
||||
@ -303,7 +303,7 @@ BOOST_FIXTURE_TEST_CASE(evo_assetunlock, TestChain100Setup)
|
||||
CKey key;
|
||||
key.MakeNewKey(true);
|
||||
|
||||
const CMutableTransaction tx = CreateAssetUnlockTx(keystore, key);
|
||||
const CTransaction tx = CreateAssetUnlockTx(keystore, key);
|
||||
std::string reason;
|
||||
BOOST_CHECK(IsStandardTx(CTransaction(tx), reason));
|
||||
|
||||
@ -322,7 +322,7 @@ BOOST_FIXTURE_TEST_CASE(evo_assetunlock, TestChain100Setup)
|
||||
CCoinsViewCache coins(&coinsDummy);
|
||||
std::vector<CMutableTransaction> dummyTransactions = SetupDummyInputs(keystore, coins);
|
||||
|
||||
CMutableTransaction txNonemptyInput = tx;
|
||||
CMutableTransaction txNonemptyInput(tx);
|
||||
txNonemptyInput.vin.resize(1);
|
||||
txNonemptyInput.vin[0].prevout.hash = dummyTransactions[0].GetHash();
|
||||
txNonemptyInput.vin[0].prevout.n = 1;
|
||||
@ -344,7 +344,7 @@ BOOST_FIXTURE_TEST_CASE(evo_assetunlock, TestChain100Setup)
|
||||
BOOST_CHECK(unlockPayload->getIndex() == 0x001122334455667788L);
|
||||
|
||||
// Wrong type "Asset Lock TX" instead "Asset Unlock TX"
|
||||
CMutableTransaction txWrongType = tx;
|
||||
CMutableTransaction txWrongType(tx);
|
||||
txWrongType.nType = TRANSACTION_ASSET_LOCK;
|
||||
BOOST_CHECK(!CheckAssetUnlockTx(CTransaction(txWrongType), block_index, std::nullopt, tx_state));
|
||||
BOOST_CHECK(tx_state.GetRejectReason() == "bad-assetunlocktx-type");
|
||||
@ -358,7 +358,7 @@ BOOST_FIXTURE_TEST_CASE(evo_assetunlock, TestChain100Setup)
|
||||
unlockPayload->getRequestedHeight(),
|
||||
unlockPayload->getQuorumHash(),
|
||||
unlockPayload->getQuorumSig()};
|
||||
CMutableTransaction txWrongVersion = tx;
|
||||
CMutableTransaction txWrongVersion(tx);
|
||||
SetTxPayload(txWrongVersion, unlockPayload_tmp);
|
||||
if (payload_version != 1) {
|
||||
BOOST_CHECK(!CheckAssetUnlockTx(CTransaction(txWrongVersion), block_index, std::nullopt, tx_state));
|
||||
@ -372,7 +372,7 @@ BOOST_FIXTURE_TEST_CASE(evo_assetunlock, TestChain100Setup)
|
||||
|
||||
{
|
||||
// Exactly 32 withdrawal is fine
|
||||
CMutableTransaction txManyOutputs = tx;
|
||||
CMutableTransaction txManyOutputs(tx);
|
||||
int outputsLimit = 32;
|
||||
txManyOutputs.vout.resize(outputsLimit);
|
||||
for (auto& out : txManyOutputs.vout) {
|
||||
|
Loading…
Reference in New Issue
Block a user