|
|
@ -51,8 +51,8 @@ public: |
|
|
|
|
|
|
|
void IncrementNoteWitnesses(const CBlockIndex* pindex, |
|
|
|
const CBlock* pblock, |
|
|
|
ZCIncrementalMerkleTree& sproutTree, |
|
|
|
ZCSaplingIncrementalMerkleTree& saplingTree) { |
|
|
|
SproutMerkleTree& sproutTree, |
|
|
|
SaplingMerkleTree& saplingTree) { |
|
|
|
CWallet::IncrementNoteWitnesses(pindex, pblock, sproutTree, saplingTree); |
|
|
|
} |
|
|
|
void DecrementNoteWitnesses(const CBlockIndex* pindex) { |
|
|
@ -97,8 +97,8 @@ std::pair<JSOutPoint, SaplingOutPoint> CreateValidBlock(TestWallet& wallet, |
|
|
|
const libzcash::SproutSpendingKey& sk, |
|
|
|
const CBlockIndex& index, |
|
|
|
CBlock& block, |
|
|
|
ZCIncrementalMerkleTree& sproutTree, |
|
|
|
ZCSaplingIncrementalMerkleTree& saplingTree) { |
|
|
|
SproutMerkleTree& sproutTree, |
|
|
|
SaplingMerkleTree& saplingTree) { |
|
|
|
auto wtx = GetValidReceive(sk, 50, true, 4); |
|
|
|
auto note = GetNote(sk, wtx, 0, 1); |
|
|
|
auto nullifier = note.nullifier(sk); |
|
|
@ -147,7 +147,7 @@ TEST(wallet_tests, note_data_serialisation) { |
|
|
|
mapSproutNoteData_t noteData; |
|
|
|
JSOutPoint jsoutpt {wtx.GetHash(), 0, 1}; |
|
|
|
SproutNoteData nd {sk.address(), nullifier}; |
|
|
|
ZCIncrementalMerkleTree tree; |
|
|
|
SproutMerkleTree tree; |
|
|
|
nd.witnesses.push_front(tree.witness()); |
|
|
|
noteData[jsoutpt] = nd; |
|
|
|
|
|
|
@ -605,8 +605,8 @@ TEST(wallet_tests, cached_witnesses_empty_chain) { |
|
|
|
CBlock block; |
|
|
|
block.vtx.push_back(wtx); |
|
|
|
CBlockIndex index(block); |
|
|
|
ZCIncrementalMerkleTree sproutTree; |
|
|
|
ZCSaplingIncrementalMerkleTree saplingTree; |
|
|
|
SproutMerkleTree sproutTree; |
|
|
|
SaplingMerkleTree saplingTree; |
|
|
|
wallet.IncrementNoteWitnesses(&index, &block, sproutTree, saplingTree); |
|
|
|
|
|
|
|
::GetWitnessesAndAnchors(wallet, sproutNotes, saplingNotes, sproutWitnesses, saplingWitnesses); |
|
|
@ -624,8 +624,8 @@ TEST(wallet_tests, cached_witnesses_chain_tip) { |
|
|
|
TestWallet wallet; |
|
|
|
std::pair<uint256, uint256> anchors1; |
|
|
|
CBlock block1; |
|
|
|
ZCIncrementalMerkleTree sproutTree; |
|
|
|
ZCSaplingIncrementalMerkleTree saplingTree; |
|
|
|
SproutMerkleTree sproutTree; |
|
|
|
SaplingMerkleTree saplingTree; |
|
|
|
|
|
|
|
auto sk = libzcash::SproutSpendingKey::random(); |
|
|
|
wallet.AddSpendingKey(sk); |
|
|
@ -675,8 +675,8 @@ TEST(wallet_tests, cached_witnesses_chain_tip) { |
|
|
|
block2.vtx.push_back(wtx); |
|
|
|
CBlockIndex index2(block2); |
|
|
|
index2.nHeight = 2; |
|
|
|
ZCIncrementalMerkleTree sproutTree2 {sproutTree}; |
|
|
|
ZCSaplingIncrementalMerkleTree saplingTree2 {saplingTree}; |
|
|
|
SproutMerkleTree sproutTree2 {sproutTree}; |
|
|
|
SaplingMerkleTree saplingTree2 {saplingTree}; |
|
|
|
wallet.IncrementNoteWitnesses(&index2, &block2, sproutTree2, saplingTree2); |
|
|
|
|
|
|
|
auto anchors2 = GetWitnessesAndAnchors(wallet, sproutNotes, saplingNotes, sproutWitnesses, saplingWitnesses); |
|
|
@ -724,8 +724,8 @@ TEST(wallet_tests, cached_witnesses_chain_tip) { |
|
|
|
|
|
|
|
TEST(wallet_tests, CachedWitnessesDecrementFirst) { |
|
|
|
TestWallet wallet; |
|
|
|
ZCIncrementalMerkleTree sproutTree; |
|
|
|
ZCSaplingIncrementalMerkleTree saplingTree; |
|
|
|
SproutMerkleTree sproutTree; |
|
|
|
SaplingMerkleTree saplingTree; |
|
|
|
|
|
|
|
auto sk = libzcash::SproutSpendingKey::random(); |
|
|
|
wallet.AddSpendingKey(sk); |
|
|
@ -810,10 +810,10 @@ TEST(wallet_tests, CachedWitnessesCleanIndex) { |
|
|
|
std::vector<SaplingOutPoint> saplingNotes; |
|
|
|
std::vector<uint256> sproutAnchors; |
|
|
|
std::vector<uint256> saplingAnchors; |
|
|
|
ZCIncrementalMerkleTree sproutTree; |
|
|
|
ZCIncrementalMerkleTree sproutRiTree = sproutTree; |
|
|
|
ZCSaplingIncrementalMerkleTree saplingTree; |
|
|
|
ZCSaplingIncrementalMerkleTree saplingRiTree = saplingTree; |
|
|
|
SproutMerkleTree sproutTree; |
|
|
|
SproutMerkleTree sproutRiTree = sproutTree; |
|
|
|
SaplingMerkleTree saplingTree; |
|
|
|
SaplingMerkleTree saplingRiTree = saplingTree; |
|
|
|
std::vector<boost::optional<ZCIncrementalWitness>> sproutWitnesses; |
|
|
|
std::vector<boost::optional<ZCSaplingIncrementalWitness>> saplingWitnesses; |
|
|
|
|
|
|
@ -846,8 +846,8 @@ TEST(wallet_tests, CachedWitnessesCleanIndex) { |
|
|
|
// Now pretend we are reindexing: the chain is cleared, and each block is
|
|
|
|
// used to increment witnesses again.
|
|
|
|
for (size_t i = 0; i < numBlocks; i++) { |
|
|
|
ZCIncrementalMerkleTree sproutRiPrevTree {sproutRiTree}; |
|
|
|
ZCSaplingIncrementalMerkleTree saplingRiPrevTree {saplingRiTree}; |
|
|
|
SproutMerkleTree sproutRiPrevTree {sproutRiTree}; |
|
|
|
SaplingMerkleTree saplingRiPrevTree {saplingRiTree}; |
|
|
|
wallet.IncrementNoteWitnesses(&(indices[i]), &(blocks[i]), sproutRiTree, saplingRiTree); |
|
|
|
|
|
|
|
auto anchors = GetWitnessesAndAnchors(wallet, sproutNotes, saplingNotes, sproutWitnesses, saplingWitnesses); |
|
|
@ -909,12 +909,12 @@ TEST(wallet_tests, ClearNoteWitnessCache) { |
|
|
|
auto saplingNotes = SetSaplingNoteData(wtx); |
|
|
|
|
|
|
|
// Pretend we mined the tx by adding a fake witness
|
|
|
|
ZCIncrementalMerkleTree sproutTree; |
|
|
|
SproutMerkleTree sproutTree; |
|
|
|
wtx.mapSproutNoteData[jsoutpt].witnesses.push_front(sproutTree.witness()); |
|
|
|
wtx.mapSproutNoteData[jsoutpt].witnessHeight = 1; |
|
|
|
wallet.nWitnessCacheSize = 1; |
|
|
|
|
|
|
|
ZCSaplingIncrementalMerkleTree saplingTree; |
|
|
|
SaplingMerkleTree saplingTree; |
|
|
|
wtx.mapSaplingNoteData[saplingNotes[0]].witnesses.push_front(saplingTree.witness()); |
|
|
|
wtx.mapSaplingNoteData[saplingNotes[0]].witnessHeight = 1; |
|
|
|
wallet.nWitnessCacheSize = 2; |
|
|
@ -1081,7 +1081,7 @@ TEST(wallet_tests, UpdatedNoteData) { |
|
|
|
wtx.SetSproutNoteData(noteData); |
|
|
|
|
|
|
|
// Pretend we mined the tx by adding a fake witness
|
|
|
|
ZCIncrementalMerkleTree tree; |
|
|
|
SproutMerkleTree tree; |
|
|
|
wtx.mapSproutNoteData[jsoutpt].witnesses.push_front(tree.witness()); |
|
|
|
wtx.mapSproutNoteData[jsoutpt].witnessHeight = 100; |
|
|
|
|
|
|
|