aboutsummaryrefslogtreecommitdiff
path: root/src/test/transaction_tests.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/transaction_tests.cpp')
-rw-r--r--src/test/transaction_tests.cpp30
1 files changed, 15 insertions, 15 deletions
diff --git a/src/test/transaction_tests.cpp b/src/test/transaction_tests.cpp
index 1dacdeaa23..17b925c340 100644
--- a/src/test/transaction_tests.cpp
+++ b/src/test/transaction_tests.cpp
@@ -173,7 +173,7 @@ BOOST_AUTO_TEST_CASE(basic_transaction_tests)
// paid to a TX_PUBKEYHASH.
//
static std::vector<CTransaction>
-SetupDummyInputs(CBasicKeyStore& keystoreRet, MapPrevTx& inputsRet)
+SetupDummyInputs(CBasicKeyStore& keystoreRet, CCoinsView & coinsRet)
{
std::vector<CTransaction> dummyTransactions;
dummyTransactions.resize(2);
@@ -192,14 +192,14 @@ SetupDummyInputs(CBasicKeyStore& keystoreRet, MapPrevTx& inputsRet)
dummyTransactions[0].vout[0].scriptPubKey << key[0].GetPubKey() << OP_CHECKSIG;
dummyTransactions[0].vout[1].nValue = 50*CENT;
dummyTransactions[0].vout[1].scriptPubKey << key[1].GetPubKey() << OP_CHECKSIG;
- inputsRet[dummyTransactions[0].GetHash()] = make_pair(CTxIndex(), dummyTransactions[0]);
+ coinsRet.SetCoins(dummyTransactions[0].GetHash(), CCoins(dummyTransactions[0], 0));
dummyTransactions[1].vout.resize(2);
dummyTransactions[1].vout[0].nValue = 21*CENT;
dummyTransactions[1].vout[0].scriptPubKey.SetDestination(key[2].GetPubKey().GetID());
dummyTransactions[1].vout[1].nValue = 22*CENT;
dummyTransactions[1].vout[1].scriptPubKey.SetDestination(key[3].GetPubKey().GetID());
- inputsRet[dummyTransactions[1].GetHash()] = make_pair(CTxIndex(), dummyTransactions[1]);
+ coinsRet.SetCoins(dummyTransactions[1].GetHash(), CCoins(dummyTransactions[1], 0));
return dummyTransactions;
}
@@ -207,8 +207,9 @@ SetupDummyInputs(CBasicKeyStore& keystoreRet, MapPrevTx& inputsRet)
BOOST_AUTO_TEST_CASE(test_Get)
{
CBasicKeyStore keystore;
- MapPrevTx dummyInputs;
- std::vector<CTransaction> dummyTransactions = SetupDummyInputs(keystore, dummyInputs);
+ CCoinsView coinsDummy;
+ CCoinsViewCache coins(coinsDummy);
+ std::vector<CTransaction> dummyTransactions = SetupDummyInputs(keystore, coins);
CTransaction t1;
t1.vin.resize(3);
@@ -225,25 +226,24 @@ BOOST_AUTO_TEST_CASE(test_Get)
t1.vout[0].nValue = 90*CENT;
t1.vout[0].scriptPubKey << OP_1;
- BOOST_CHECK(t1.AreInputsStandard(dummyInputs));
- BOOST_CHECK_EQUAL(t1.GetValueIn(dummyInputs), (50+21+22)*CENT);
+ BOOST_CHECK(t1.AreInputsStandard(coins));
+ BOOST_CHECK_EQUAL(t1.GetValueIn(coins), (50+21+22)*CENT);
// Adding extra junk to the scriptSig should make it non-standard:
t1.vin[0].scriptSig << OP_11;
- BOOST_CHECK(!t1.AreInputsStandard(dummyInputs));
+ BOOST_CHECK(!t1.AreInputsStandard(coins));
// ... as should not having enough:
t1.vin[0].scriptSig = CScript();
- BOOST_CHECK(!t1.AreInputsStandard(dummyInputs));
+ BOOST_CHECK(!t1.AreInputsStandard(coins));
}
BOOST_AUTO_TEST_CASE(test_GetThrow)
{
CBasicKeyStore keystore;
- MapPrevTx dummyInputs;
- std::vector<CTransaction> dummyTransactions = SetupDummyInputs(keystore, dummyInputs);
-
- MapPrevTx missingInputs;
+ CCoinsView coinsDummy;
+ CCoinsViewCache coins(coinsDummy);
+ std::vector<CTransaction> dummyTransactions = SetupDummyInputs(keystore, coins);
CTransaction t1;
t1.vin.resize(3);
@@ -257,8 +257,8 @@ BOOST_AUTO_TEST_CASE(test_GetThrow)
t1.vout[0].nValue = 90*CENT;
t1.vout[0].scriptPubKey << OP_1;
- BOOST_CHECK_THROW(t1.AreInputsStandard(missingInputs), runtime_error);
- BOOST_CHECK_THROW(t1.GetValueIn(missingInputs), runtime_error);
+ BOOST_CHECK_THROW(t1.AreInputsStandard(coinsDummy), runtime_error);
+ BOOST_CHECK_THROW(t1.GetValueIn(coinsDummy), runtime_error);
}
BOOST_AUTO_TEST_SUITE_END()