Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/test/wallet_tests.cpp
Show First 20 Lines • Show All 153 Lines • ▼ Show 20 Lines | // Import key into wallet and call dumpwallet to create backup file. | ||||
KEY_TIME; | KEY_TIME; | ||||
wallet.AddKeyPubKey(coinbaseKey, coinbaseKey.GetPubKey()); | wallet.AddKeyPubKey(coinbaseKey, coinbaseKey.GetPubKey()); | ||||
JSONRPCRequest request; | JSONRPCRequest request; | ||||
request.params.setArray(); | request.params.setArray(); | ||||
request.params.push_back((pathTemp / "wallet.backup").string()); | request.params.push_back((pathTemp / "wallet.backup").string()); | ||||
vpwallets.insert(vpwallets.begin(), &wallet); | vpwallets.insert(vpwallets.begin(), &wallet); | ||||
::dumpwallet(GetConfig(), request); | ::dumpwallet(GetConfig(), request); | ||||
vpwallets.erase(vpwallets.begin()); | |||||
} | } | ||||
// Call importwallet RPC and verify all blocks with timestamps >= BLOCK_TIME | // Call importwallet RPC and verify all blocks with timestamps >= BLOCK_TIME | ||||
// were scanned, and no prior blocks were scanned. | // were scanned, and no prior blocks were scanned. | ||||
{ | { | ||||
CWallet wallet(Params(), "dummy", CWalletDBWrapper::CreateDummy()); | CWallet wallet(Params(), "dummy", CWalletDBWrapper::CreateDummy()); | ||||
JSONRPCRequest request; | JSONRPCRequest request; | ||||
request.params.setArray(); | request.params.setArray(); | ||||
request.params.push_back((pathTemp / "wallet.backup").string()); | request.params.push_back((pathTemp / "wallet.backup").string()); | ||||
vpwallets[0] = &wallet; | vpwallets.insert(vpwallets.begin(), &wallet); | ||||
::importwallet(GetConfig(), request); | ::importwallet(GetConfig(), request); | ||||
vpwallets.erase(vpwallets.begin()); | |||||
LOCK(wallet.cs_wallet); | LOCK(wallet.cs_wallet); | ||||
BOOST_CHECK_EQUAL(wallet.mapWallet.size(), 3U); | BOOST_CHECK_EQUAL(wallet.mapWallet.size(), 3U); | ||||
BOOST_CHECK_EQUAL(m_coinbase_txns.size(), 103U); | BOOST_CHECK_EQUAL(m_coinbase_txns.size(), 103U); | ||||
for (size_t i = 0; i < m_coinbase_txns.size(); ++i) { | for (size_t i = 0; i < m_coinbase_txns.size(); ++i) { | ||||
bool found = wallet.GetWalletTx(m_coinbase_txns[i]->GetId()); | bool found = wallet.GetWalletTx(m_coinbase_txns[i]->GetId()); | ||||
bool expected = i >= 100; | bool expected = i >= 100; | ||||
BOOST_CHECK_EQUAL(found, expected); | BOOST_CHECK_EQUAL(found, expected); | ||||
} | } | ||||
} | } | ||||
SetMockTime(0); | SetMockTime(0); | ||||
vpwallets.erase(vpwallets.begin()); | |||||
} | } | ||||
// Check that GetImmatureCredit() returns a newly calculated value instead of | // Check that GetImmatureCredit() returns a newly calculated value instead of | ||||
// the cached value after a MarkDirty() call. | // the cached value after a MarkDirty() call. | ||||
// | // | ||||
// This is a regression test written to verify a bugfix for the immature credit | // This is a regression test written to verify a bugfix for the immature credit | ||||
// function. Similar tests probably should be written for the other credit and | // function. Similar tests probably should be written for the other credit and | ||||
// debit functions. | // debit functions. | ||||
▲ Show 20 Lines • Show All 189 Lines • Show Last 20 Lines |