diff options
| author | Ross Nicoll <[email protected]> | 2018-09-30 15:38:37 +0100 |
|---|---|---|
| committer | Ross Nicoll <[email protected]> | 2019-04-03 05:16:26 +0000 |
| commit | 8ef665d5e4765366b1c47a2ce7054d783ccca9d0 (patch) | |
| tree | eb4deddbdbf40cc6e328dc88d3ae21d76332da9a /src/wallet | |
| parent | Add Dogecoin block subsidy calculations. (diff) | |
| download | discoin-8ef665d5e4765366b1c47a2ce7054d783ccca9d0.tar.xz discoin-8ef665d5e4765366b1c47a2ce7054d783ccca9d0.zip | |
Replace test data with Dogecoin values
Replace test data with Dogecoin equivalents in the folowing tests:
* base58
* bip32
* keys
* miner
* pow
* wallet
Replace RPC and deterministic signatures in unit tests with Dogecoin values. While
conventionally I'd use an alternative implementation for these, as RFC 6979
compliant signature generation isn't terribly common, and there's no reason
to suspect we've modified this code, I'm going to assert that it's good enough
to test that the code doesn't provide different values.
Disabled Bitcoin PoW tests, but left code in place to simplify later merges. These are
replaced by the Dogecoin PoW tests.
Diffstat (limited to 'src/wallet')
| -rw-r--r-- | src/wallet/test/wallet_tests.cpp | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/src/wallet/test/wallet_tests.cpp b/src/wallet/test/wallet_tests.cpp index c474547b7..d5b8ff992 100644 --- a/src/wallet/test/wallet_tests.cpp +++ b/src/wallet/test/wallet_tests.cpp @@ -32,8 +32,7 @@ static void AddKey(CWallet& wallet, const CKey& key) LOCK(wallet.cs_wallet); wallet.AddKeyPubKey(key, key.GetPubKey()); } - -BOOST_FIXTURE_TEST_CASE(rescan, TestChain100Setup) +BOOST_FIXTURE_TEST_CASE(rescan, TestChain240Setup) { // Cap last block file size, and mine new block in a new block file. CBlockIndex* const nullBlock = nullptr; @@ -52,7 +51,8 @@ BOOST_FIXTURE_TEST_CASE(rescan, TestChain100Setup) WalletRescanReserver reserver(&wallet); reserver.reserve(); BOOST_CHECK_EQUAL(nullBlock, wallet.ScanForWalletTransactions(oldTip, nullptr, reserver)); - BOOST_CHECK_EQUAL(wallet.GetImmatureBalance(), 100 * COIN); + // Dogecoin: Immature balance varies due to random rewards + BOOST_CHECK(wallet.GetImmatureBalance() <= (240 * 1000000 * COIN)); } // Prune the older block file. @@ -67,7 +67,8 @@ BOOST_FIXTURE_TEST_CASE(rescan, TestChain100Setup) WalletRescanReserver reserver(&wallet); reserver.reserve(); BOOST_CHECK_EQUAL(oldTip, wallet.ScanForWalletTransactions(oldTip, nullptr, reserver)); - BOOST_CHECK_EQUAL(wallet.GetImmatureBalance(), 50 * COIN); + // Dogecoin: Immature balance varies due to random rewards + BOOST_CHECK(wallet.GetImmatureBalance() <= (120 * 1000000 * COIN)); } // Verify importmulti RPC returns failure for a key whose creation time is @@ -114,7 +115,7 @@ BOOST_FIXTURE_TEST_CASE(rescan, TestChain100Setup) // greater or equal than key birthday. Previously there was a bug where // importwallet RPC would start the scan at the latest block with timestamp less // than or equal to key birthday. -BOOST_FIXTURE_TEST_CASE(importwallet_rescan, TestChain100Setup) +BOOST_FIXTURE_TEST_CASE(importwallet_rescan, TestChain240Setup) { // Create two blocks with same timestamp to verify that importwallet rescan // will pick up both blocks, not just the first. @@ -162,10 +163,10 @@ BOOST_FIXTURE_TEST_CASE(importwallet_rescan, TestChain100Setup) LOCK(wallet->cs_wallet); BOOST_CHECK_EQUAL(wallet->mapWallet.size(), 3U); - BOOST_CHECK_EQUAL(m_coinbase_txns.size(), 103U); + BOOST_CHECK_EQUAL(m_coinbase_txns.size(), 243U); for (size_t i = 0; i < m_coinbase_txns.size(); ++i) { bool found = wallet->GetWalletTx(m_coinbase_txns[i]->GetHash()); - bool expected = i >= 100; + bool expected = i >= 240; BOOST_CHECK_EQUAL(found, expected); } } @@ -179,7 +180,7 @@ BOOST_FIXTURE_TEST_CASE(importwallet_rescan, TestChain100Setup) // 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 // debit functions. -BOOST_FIXTURE_TEST_CASE(coin_mark_dirty_immature_credit, TestChain100Setup) +BOOST_FIXTURE_TEST_CASE(coin_mark_dirty_immature_credit, TestChain240Setup) { CWallet wallet("dummy", WalletDatabase::CreateDummy()); CWalletTx wtx(&wallet, m_coinbase_txns.back()); @@ -195,7 +196,8 @@ BOOST_FIXTURE_TEST_CASE(coin_mark_dirty_immature_credit, TestChain100Setup) // credit amount is calculated. wtx.MarkDirty(); wallet.AddKeyPubKey(coinbaseKey, coinbaseKey.GetPubKey()); - BOOST_CHECK_EQUAL(wtx.GetImmatureCredit(), 50*COIN); + // Dogecoin has random rewards so we can only test against maximum + BOOST_CHECK(wtx.GetImmatureCredit() <= 1000000 * COIN); } static int64_t AddTx(CWallet& wallet, uint32_t lockTime, int64_t mockTime, int64_t blockTime) @@ -268,7 +270,7 @@ BOOST_AUTO_TEST_CASE(LoadReceiveRequests) BOOST_CHECK_EQUAL(values[1], "val_rr1"); } -class ListCoinsTestingSetup : public TestChain100Setup +class ListCoinsTestingSetup : public TestChain240Setup { public: ListCoinsTestingSetup() @@ -327,7 +329,8 @@ BOOST_FIXTURE_TEST_CASE(ListCoins, ListCoinsTestingSetup) BOOST_CHECK_EQUAL(list.begin()->second.size(), 1U); // Check initial balance from one mature coinbase transaction. - BOOST_CHECK_EQUAL(50 * COIN, wallet->GetAvailableBalance()); + // Dogecoin has random rewards so we can only test against maximum + BOOST_CHECK(1000000 * COIN >= wallet->GetAvailableBalance()); // Add a transaction creating a change address, and confirm ListCoins still // returns the coin associated with the change address underneath the @@ -366,7 +369,7 @@ BOOST_FIXTURE_TEST_CASE(ListCoins, ListCoinsTestingSetup) BOOST_CHECK_EQUAL(list.begin()->second.size(), 2U); } -BOOST_FIXTURE_TEST_CASE(wallet_disableprivkeys, TestChain100Setup) +BOOST_FIXTURE_TEST_CASE(wallet_disableprivkeys, TestChain240Setup) { std::shared_ptr<CWallet> wallet = std::make_shared<CWallet>("dummy", WalletDatabase::CreateDummy()); wallet->SetWalletFlag(WALLET_FLAG_DISABLE_PRIVATE_KEYS); |