diff options
| author | Ross Nicoll <[email protected]> | 2021-03-03 21:22:15 +0000 |
|---|---|---|
| committer | Ross Nicoll <[email protected]> | 2021-05-20 12:02:35 +0100 |
| commit | 3f8289a113ad2fb629c787528c809aa7d5b91610 (patch) | |
| tree | 073b9f822df735b78b18cc1de6b40991f568f07d /src/wallet/test | |
| parent | Update miner confirmation window (diff) | |
| download | discoin-3f8289a113ad2fb629c787528c809aa7d5b91610.tar.xz discoin-3f8289a113ad2fb629c787528c809aa7d5b91610.zip | |
Dogecoin: Update coinbase maturity
* Change coinbase maturity to 240 blocks in most cases, with main/test early chains allowing 30 blocks. I've kept the 240 consistent in regtest to avoid having to redesign a lot of the test cases.
* Disabled mining unit test which require COINBASE_MATURITY worth of pre-calculated blocks, as we'd otherwise be constantly refactoring them.
* Moved functional test which uses the Bitcoin testnet block data as its reference, as it completely breaks as we introduce Dogecoin data.
* Updated standard blockchains for tests from 100/200 to 240/480 as appropriate.
Diffstat (limited to 'src/wallet/test')
| -rw-r--r-- | src/wallet/test/wallet_tests.cpp | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/src/wallet/test/wallet_tests.cpp b/src/wallet/test/wallet_tests.cpp index 4911af08c..f0682fc97 100644 --- a/src/wallet/test/wallet_tests.cpp +++ b/src/wallet/test/wallet_tests.cpp @@ -75,7 +75,7 @@ static void AddKey(CWallet& wallet, const CKey& key) spk_man->AddKeyPubKey(key, key.GetPubKey()); } -BOOST_FIXTURE_TEST_CASE(scan_for_wallet_transactions, TestChain100Setup) +BOOST_FIXTURE_TEST_CASE(scan_for_wallet_transactions, TestChain240Setup) { // Cap last block file size, and mine new block in a new block file. CBlockIndex* oldTip = ::ChainActive().Tip(); @@ -120,7 +120,8 @@ BOOST_FIXTURE_TEST_CASE(scan_for_wallet_transactions, TestChain100Setup) BOOST_CHECK(result.last_failed_block.IsNull()); BOOST_CHECK_EQUAL(result.last_scanned_block, newTip->GetBlockHash()); BOOST_CHECK_EQUAL(*result.last_scanned_height, newTip->nHeight); - BOOST_CHECK_EQUAL(wallet.GetBalance().m_mine_immature, 100 * COIN); + // Dogecoin: Immature balance varies due to random rewards + BOOST_CHECK(wallet.GetBalance().m_mine_immature <= (240 * 1000000 * COIN)); } // Prune the older block file. @@ -146,7 +147,7 @@ BOOST_FIXTURE_TEST_CASE(scan_for_wallet_transactions, TestChain100Setup) BOOST_CHECK_EQUAL(result.last_failed_block, oldTip->GetBlockHash()); BOOST_CHECK_EQUAL(result.last_scanned_block, newTip->GetBlockHash()); BOOST_CHECK_EQUAL(*result.last_scanned_height, newTip->nHeight); - BOOST_CHECK_EQUAL(wallet.GetBalance().m_mine_immature, 50 * COIN); + BOOST_CHECK_EQUAL(wallet.GetBalance().m_mine_immature, 25 * COIN); } // Prune the remaining block file. @@ -175,7 +176,7 @@ BOOST_FIXTURE_TEST_CASE(scan_for_wallet_transactions, TestChain100Setup) } } -BOOST_FIXTURE_TEST_CASE(importmulti_rescan, TestChain100Setup) +BOOST_FIXTURE_TEST_CASE(importmulti_rescan, TestChain240Setup) { // Cap last block file size, and mine new block in a new block file. CBlockIndex* oldTip = ::ChainActive().Tip(); @@ -240,7 +241,7 @@ BOOST_FIXTURE_TEST_CASE(importmulti_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. @@ -298,10 +299,10 @@ BOOST_FIXTURE_TEST_CASE(importwallet_rescan, TestChain100Setup) RemoveWallet(wallet, nullopt); 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); } } @@ -315,7 +316,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) { NodeContext node; auto chain = interfaces::MakeChain(node); @@ -338,7 +339,7 @@ BOOST_FIXTURE_TEST_CASE(coin_mark_dirty_immature_credit, TestChain100Setup) // credit amount is calculated. wtx.MarkDirty(); BOOST_CHECK(spk_man->AddKeyPubKey(coinbaseKey, coinbaseKey.GetPubKey())); - BOOST_CHECK_EQUAL(wtx.GetImmatureCredit(), 50*COIN); + BOOST_CHECK_EQUAL(wtx.GetImmatureCredit(), 25*COIN); } static int64_t AddTx(ChainstateManager& chainman, CWallet& wallet, uint32_t lockTime, int64_t mockTime, int64_t blockTime) @@ -489,7 +490,7 @@ BOOST_AUTO_TEST_CASE(WatchOnlyPubKeys) TestWatchOnlyPubKey(spk_man, pubkey); } -class ListCoinsTestingSetup : public TestChain100Setup +class ListCoinsTestingSetup : public TestChain240Setup { public: ListCoinsTestingSetup() @@ -565,7 +566,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 @@ -610,7 +612,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) { NodeContext node; auto chain = interfaces::MakeChain(node); @@ -661,7 +663,7 @@ static size_t CalculateNestedKeyhashInputSize(bool use_max_sig) return (size_t)GetVirtualTransactionInputSize(tx_in); } -BOOST_FIXTURE_TEST_CASE(dummy_input_size_test, TestChain100Setup) +BOOST_FIXTURE_TEST_CASE(dummy_input_size_test, TestChain240Setup) { BOOST_CHECK_EQUAL(CalculateNestedKeyhashInputSize(false), DUMMY_NESTED_P2WPKH_INPUT_SIZE); BOOST_CHECK_EQUAL(CalculateNestedKeyhashInputSize(true), DUMMY_NESTED_P2WPKH_INPUT_SIZE); @@ -706,7 +708,7 @@ BOOST_FIXTURE_TEST_CASE(wallet_descriptor_test, BasicTestingSetup) //! wallet rescan and notifications are immediately synced, to verify the wallet //! must already have a handler in place for them, and there's no gap after //! rescanning where new transactions in new blocks could be lost. -BOOST_FIXTURE_TEST_CASE(CreateWallet, TestChain100Setup) +BOOST_FIXTURE_TEST_CASE(CreateWallet, TestChain240Setup) { // Create new wallet with known key and unload it. auto chain = interfaces::MakeChain(m_node); @@ -800,7 +802,7 @@ BOOST_FIXTURE_TEST_CASE(CreateWallet, TestChain100Setup) TestUnloadWallet(std::move(wallet)); } -BOOST_FIXTURE_TEST_CASE(ZapSelectTx, TestChain100Setup) +BOOST_FIXTURE_TEST_CASE(ZapSelectTx, TestChain240Setup) { auto chain = interfaces::MakeChain(m_node); auto wallet = TestLoadWallet(*chain); |