7
7
#include < FakeBlockIndexChain.h>
8
8
#include < primitives/block.h>
9
9
#include < chain.h>
10
+ #include < MockUtxoHasher.h>
10
11
#include < MockVaultManagerDatabase.h>
11
12
#include < WalletTx.h>
12
13
#include < streams.h>
@@ -21,6 +22,7 @@ using ::testing::Invoke;
21
22
struct VaultManagerTestFixture
22
23
{
23
24
public:
25
+ MockUtxoHasher utxoHasher;
24
26
std::unique_ptr<NiceMock<MockVaultManagerDatabase>> mockPtr;
25
27
std::unique_ptr<FakeBlockIndexWithHashes> fakeBlockIndexWithHashesResource;
26
28
std::unique_ptr<I_MerkleTxConfirmationNumberCalculator> confirmationsCalculator;
@@ -36,7 +38,7 @@ struct VaultManagerTestFixture
36
38
*(fakeBlockIndexWithHashesResource->blockIndexByHash)
37
39
))
38
40
, scriptGenerator()
39
- , manager( new VaultManager(*confirmationsCalculator,*mockPtr ))
41
+ , manager( new VaultManager(*confirmationsCalculator, utxoHasher, *mockPtr))
40
42
{
41
43
}
42
44
~VaultManagerTestFixture ()
@@ -190,7 +192,7 @@ BOOST_AUTO_TEST_CASE(willDiscountSpentUTXOs)
190
192
manager->addTransaction (tx,&blockMiningFirstTx, true );
191
193
192
194
CMutableTransaction otherTx;
193
- otherTx.vin .emplace_back ( COutPoint (tx. GetHash ( ), 1u ) );
195
+ otherTx.vin .emplace_back ( COutPoint (utxoHasher. GetUtxoHash (tx ), 1u ) );
194
196
otherTx.vout .push_back (CTxOut (100 ,managedScript));
195
197
otherTx.vout .push_back (CTxOut (100 ,managedScript));
196
198
otherTx.vout .push_back (CTxOut (100 ,managedScript));
@@ -245,7 +247,7 @@ BOOST_AUTO_TEST_CASE(willCheckThatCoinstakeTransactionsAreDeepEnoughToSpend)
245
247
manager->addTransaction (fundingTransaction,&blockMiningFundingTx, true );
246
248
247
249
CMutableTransaction tx;
248
- tx.vin .push_back (CTxIn (fundingTransaction. GetHash ( ),0u ));
250
+ tx.vin .push_back (CTxIn (utxoHasher. GetUtxoHash (fundingTransaction ),0u ));
249
251
CTxOut emptyFirstOutput;
250
252
emptyFirstOutput.SetEmpty ();
251
253
tx.vout .push_back (emptyFirstOutput);
@@ -271,7 +273,7 @@ BOOST_AUTO_TEST_CASE(willLoadTransactionsFromDatabase)
271
273
dummyTransaction.vout .push_back (CTxOut (100 ,scriptGenerator (10 )));
272
274
273
275
CMutableTransaction tx;
274
- tx.vin .push_back (CTxIn (dummyTransaction. GetHash ( ),0u ));
276
+ tx.vin .push_back (CTxIn (utxoHasher. GetUtxoHash (dummyTransaction ),0u ));
275
277
tx.vout .push_back (CTxOut (100 ,managedScript));
276
278
tx.vout .push_back (CTxOut (100 ,managedScript));
277
279
tx.vout .push_back (CTxOut (100 ,managedScript));
@@ -309,7 +311,7 @@ BOOST_AUTO_TEST_CASE(willLoadTransactionsFromDatabase)
309
311
return true ;
310
312
}
311
313
));
312
- manager.reset (new VaultManager (*confirmationsCalculator, *mockPtr ));
314
+ manager.reset (new VaultManager (*confirmationsCalculator, utxoHasher, *mockPtr ));
313
315
314
316
BOOST_CHECK_EQUAL (manager->getManagedUTXOs ().size (), 4u );
315
317
BOOST_CHECK (expectedTx==manager->getTransaction (tx.GetHash ()));
@@ -329,7 +331,7 @@ BOOST_AUTO_TEST_CASE(willLoadManyTransactionsFromDatabase)
329
331
CMutableTransaction dummyTransaction;
330
332
dummyTransaction.vout .push_back (CTxOut (100 ,scriptGenerator (10 )));
331
333
CMutableTransaction tx;
332
- tx.vin .push_back (CTxIn (dummyTransaction. GetHash ( ),0u ));
334
+ tx.vin .push_back (CTxIn (utxoHasher. GetUtxoHash (dummyTransaction ),0u ));
333
335
tx.vout .push_back (CTxOut (randomSentAmount,scriptGenerator (10 )));
334
336
335
337
dummyTransactions.emplace_back (tx);
@@ -352,7 +354,7 @@ BOOST_AUTO_TEST_CASE(willLoadManyTransactionsFromDatabase)
352
354
return false ;
353
355
}
354
356
));
355
- manager.reset (new VaultManager (*confirmationsCalculator, *mockPtr ));
357
+ manager.reset (new VaultManager (*confirmationsCalculator, utxoHasher, *mockPtr ));
356
358
357
359
for (unsigned txCount =0 ; txCount < 10u ; ++txCount)
358
360
{
@@ -698,7 +700,7 @@ BOOST_AUTO_TEST_CASE(willUpdatingDepositStatusWillPersist)
698
700
manager->addTransaction (tx,&blockMiningFirstTx, true );
699
701
BOOST_CHECK_EQUAL (manager->getTransaction (tx.GetHash ()).mapValue .count (" isVaultDeposit" ),1u );
700
702
701
- manager.reset ( new VaultManager (*confirmationsCalculator,*mockPtr ));
703
+ manager.reset ( new VaultManager (*confirmationsCalculator, utxoHasher, *mockPtr));
702
704
BOOST_CHECK_EQUAL (manager->getTransaction (tx.GetHash ()).mapValue .count (" isVaultDeposit" ),1u );
703
705
}
704
706
@@ -966,4 +968,4 @@ BOOST_AUTO_TEST_CASE(willNotEraseManagedScriptToBackendOnRemovalMoreThanOnce)
966
968
manager->removeManagedScript (managedScript);
967
969
}
968
970
969
- BOOST_AUTO_TEST_SUITE_END ()
971
+ BOOST_AUTO_TEST_SUITE_END ()
0 commit comments