diff --git a/src/utiltest.cpp b/src/utiltest.cpp index 80ff9ef0d..f2cd7f584 100644 --- a/src/utiltest.cpp +++ b/src/utiltest.cpp @@ -10,9 +10,10 @@ CWalletTx GetValidReceive(ZCJoinSplit& params, const libzcash::SproutSpendingKey& sk, CAmount value, - bool randomInputs) { + bool randomInputs, + int32_t version /* = 2 */) { CMutableTransaction mtx; - mtx.nVersion = 2; // Enable JoinSplits + mtx.nVersion = version; mtx.vin.resize(2); if (randomInputs) { mtx.vin[0].prevout.hash = GetRandHash(); @@ -46,9 +47,11 @@ CWalletTx GetValidReceive(ZCJoinSplit& params, inputs, outputs, 2*value, 0, false}; mtx.vjoinsplit.push_back(jsdesc); - // Shielded Output - OutputDescription od; - mtx.vShieldedOutput.push_back(od); + if (version >= 4) { + // Shielded Output + OutputDescription od; + mtx.vShieldedOutput.push_back(od); + } // Empty output script. uint32_t consensusBranchId = SPROUT_BRANCH_ID; diff --git a/src/utiltest.h b/src/utiltest.h index 722930609..327dc7be4 100644 --- a/src/utiltest.h +++ b/src/utiltest.h @@ -9,7 +9,8 @@ CWalletTx GetValidReceive(ZCJoinSplit& params, const libzcash::SproutSpendingKey& sk, CAmount value, - bool randomInputs); + bool randomInputs, + int32_t version = 2); libzcash::SproutNote GetNote(ZCJoinSplit& params, const libzcash::SproutSpendingKey& sk, const CTransaction& tx, size_t js, size_t n); diff --git a/src/wallet/gtest/test_wallet.cpp b/src/wallet/gtest/test_wallet.cpp index 7ba91e2f4..83807986e 100644 --- a/src/wallet/gtest/test_wallet.cpp +++ b/src/wallet/gtest/test_wallet.cpp @@ -69,8 +69,8 @@ public: } }; -CWalletTx GetValidReceive(const libzcash::SproutSpendingKey& sk, CAmount value, bool randomInputs) { - return GetValidReceive(*params, sk, value, randomInputs); +CWalletTx GetValidReceive(const libzcash::SproutSpendingKey& sk, CAmount value, bool randomInputs, int32_t version = 2) { + return GetValidReceive(*params, sk, value, randomInputs, version); } libzcash::SproutNote GetNote(const libzcash::SproutSpendingKey& sk, @@ -99,7 +99,7 @@ std::pair CreateValidBlock(TestWallet& wallet, CBlock& block, ZCIncrementalMerkleTree& sproutTree, ZCSaplingIncrementalMerkleTree& saplingTree) { - auto wtx = GetValidReceive(sk, 50, true); + auto wtx = GetValidReceive(sk, 50, true, 4); auto note = GetNote(sk, wtx, 0, 1); auto nullifier = note.nullifier(sk); @@ -567,7 +567,7 @@ TEST(wallet_tests, cached_witnesses_empty_chain) { auto sk = libzcash::SproutSpendingKey::random(); wallet.AddSpendingKey(sk); - auto wtx = GetValidReceive(sk, 10, true); + auto wtx = GetValidReceive(sk, 10, true, 4); auto note = GetNote(sk, wtx, 0, 0); auto note2 = GetNote(sk, wtx, 0, 1); auto nullifier = note.nullifier(sk); @@ -648,7 +648,7 @@ TEST(wallet_tests, cached_witnesses_chain_tip) { { // Second transaction - auto wtx = GetValidReceive(sk, 50, true); + auto wtx = GetValidReceive(sk, 50, true, 4); auto note = GetNote(sk, wtx, 0, 1); auto nullifier = note.nullifier(sk); @@ -757,7 +757,7 @@ TEST(wallet_tests, CachedWitnessesDecrementFirst) { { // Third transaction - never mined - auto wtx = GetValidReceive(sk, 20, true); + auto wtx = GetValidReceive(sk, 20, true, 4); auto note = GetNote(sk, wtx, 0, 1); auto nullifier = note.nullifier(sk); @@ -895,7 +895,7 @@ TEST(wallet_tests, ClearNoteWitnessCache) { auto sk = libzcash::SproutSpendingKey::random(); wallet.AddSpendingKey(sk); - auto wtx = GetValidReceive(sk, 10, true); + auto wtx = GetValidReceive(sk, 10, true, 4); auto hash = wtx.GetHash(); auto note = GetNote(sk, wtx, 0, 0); auto nullifier = note.nullifier(sk);