23
23
24
24
using namespace std ;
25
25
26
+ std::vector<std::unique_ptr<CWalletTx>> wtxn;
27
+
26
28
typedef set<pair<const CWalletTx*,unsigned int > > CoinSet;
27
29
28
30
BOOST_FIXTURE_TEST_SUITE (wallet_tests, WalletTestingSetup)
@@ -42,21 +44,21 @@ static void add_coin(const CAmount& nValue, int nAge = 6*24, bool fIsFromMe = fa
42
44
// so stop vin being empty, and cache a non-zero Debit to fake out IsFromMe()
43
45
tx.vin .resize (1 );
44
46
}
45
- CWalletTx* wtx = new CWalletTx (&wallet, MakeTransactionRef (std::move (tx)));
47
+ std::unique_ptr< CWalletTx> wtx ( new CWalletTx (&wallet, MakeTransactionRef (std::move (tx) )));
46
48
if (fIsFromMe )
47
49
{
48
50
wtx->fDebitCached = true ;
49
51
wtx->nDebitCached = 1 ;
50
52
}
51
- COutput output (wtx, nInput, nAge, true , true );
53
+ COutput output (wtx. get () , nInput, nAge, true , true );
52
54
vCoins.push_back (output);
55
+ wtxn.emplace_back (std::move (wtx));
53
56
}
54
57
55
58
static void empty_wallet (void )
56
59
{
57
- BOOST_FOREACH (COutput output, vCoins)
58
- delete output.tx ;
59
60
vCoins.clear ();
61
+ wtxn.clear ();
60
62
}
61
63
62
64
static bool equal_sets (CoinSet a, CoinSet b)
@@ -349,6 +351,8 @@ BOOST_AUTO_TEST_CASE(ApproximateBestSubset)
349
351
BOOST_CHECK (wallet.SelectCoinsMinConf (1003 * COIN, 1 , 6 , 0 , vCoins, setCoinsRet, nValueRet));
350
352
BOOST_CHECK_EQUAL (nValueRet, 1003 * COIN);
351
353
BOOST_CHECK_EQUAL (setCoinsRet.size (), 2U );
354
+
355
+ empty_wallet ();
352
356
}
353
357
354
358
BOOST_AUTO_TEST_SUITE_END ()
0 commit comments