Add Sapling test cases

This commit is contained in:
Jack Grigg 2018-12-01 15:55:34 +00:00
parent c3eaffdb48
commit 7afb23ef31
No known key found for this signature in database
GPG Key ID: 1B8D649257DB0829
1 changed files with 25 additions and 0 deletions

View File

@ -1667,6 +1667,27 @@ TEST(WalletTests, SetBestChainIgnoresTxsWithoutShieldedData) {
CWalletTx wtxSproutTransparent {nullptr, mtx}; CWalletTx wtxSproutTransparent {nullptr, mtx};
wallet.AddToWallet(wtxSproutTransparent, true, nullptr); wallet.AddToWallet(wtxSproutTransparent, true, nullptr);
// Generate a fake Sapling transaction
CMutableTransaction mtxSapling;
mtxSapling.fOverwintered = true;
mtxSapling.nVersion = SAPLING_TX_VERSION;
mtxSapling.nVersionGroupId = SAPLING_VERSION_GROUP_ID;
mtxSapling.vShieldedOutput.resize(1);
mtxSapling.vShieldedOutput[0].cv = libzcash::random_uint256();
CWalletTx wtxSapling {nullptr, mtxSapling};
SetSaplingNoteData(wtxSapling);
wallet.AddToWallet(wtxSapling, true, nullptr);
// Generate a fake Sapling transaction that would only involve our transparent addresses
CMutableTransaction mtxSaplingTransparent;
mtxSaplingTransparent.fOverwintered = true;
mtxSaplingTransparent.nVersion = SAPLING_TX_VERSION;
mtxSaplingTransparent.nVersionGroupId = SAPLING_VERSION_GROUP_ID;
mtxSaplingTransparent.vShieldedOutput.resize(1);
mtxSaplingTransparent.vShieldedOutput[0].cv = libzcash::random_uint256();
CWalletTx wtxSaplingTransparent {nullptr, mtxSaplingTransparent};
wallet.AddToWallet(wtxSaplingTransparent, true, nullptr);
EXPECT_CALL(walletdb, TxnBegin()) EXPECT_CALL(walletdb, TxnBegin())
.WillOnce(Return(true)); .WillOnce(Return(true));
EXPECT_CALL(walletdb, WriteTx(wtxTransparent.GetHash(), wtxTransparent)) EXPECT_CALL(walletdb, WriteTx(wtxTransparent.GetHash(), wtxTransparent))
@ -1675,6 +1696,10 @@ TEST(WalletTests, SetBestChainIgnoresTxsWithoutShieldedData) {
.Times(1).WillOnce(Return(true)); .Times(1).WillOnce(Return(true));
EXPECT_CALL(walletdb, WriteTx(wtxSproutTransparent.GetHash(), wtxSproutTransparent)) EXPECT_CALL(walletdb, WriteTx(wtxSproutTransparent.GetHash(), wtxSproutTransparent))
.Times(0); .Times(0);
EXPECT_CALL(walletdb, WriteTx(wtxSapling.GetHash(), wtxSapling))
.Times(1).WillOnce(Return(true));
EXPECT_CALL(walletdb, WriteTx(wtxSaplingTransparent.GetHash(), wtxSaplingTransparent))
.Times(0);
EXPECT_CALL(walletdb, WriteWitnessCacheSize(0)) EXPECT_CALL(walletdb, WriteWitnessCacheSize(0))
.WillOnce(Return(true)); .WillOnce(Return(true));
EXPECT_CALL(walletdb, WriteBestBlock(loc)) EXPECT_CALL(walletdb, WriteBestBlock(loc))