fix functional tests to work with txindex on by default

This commit is contained in:
Brannon King 2020-03-12 13:06:24 -06:00 committed by Anthony Fieroni
parent 49f3e519f7
commit 8c1ec659f2
9 changed files with 12 additions and 7 deletions

View file

@ -196,7 +196,6 @@ CBlockTreeDB::CBlockTreeDB(size_t nCacheSize, bool fMemory, bool fWipe)
if (fWipe) { if (fWipe) {
db << "DELETE FROM block_file"; db << "DELETE FROM block_file";
db << "DELETE FROM block_info"; db << "DELETE FROM block_info";
db << "DELETE FROM tx_to_block";
db << "DELETE FROM flag"; db << "DELETE FROM flag";
} }

View file

@ -321,7 +321,8 @@ static UniValue setlabel(const JSONRPCRequest& request)
static CTransactionRef SendMoney(interfaces::Chain::Lock& locked_chain, CWallet * const pwallet, const CTxDestination &address, CAmount nValue, bool fSubtractFeeFromAmount, const CCoinControl& coin_control, mapValue_t mapValue, const CScript& prefix = CScript()) static CTransactionRef SendMoney(interfaces::Chain::Lock& locked_chain, CWallet * const pwallet, const CTxDestination &address, CAmount nValue, bool fSubtractFeeFromAmount, const CCoinControl& coin_control, mapValue_t mapValue, const CScript& prefix = CScript())
{ {
CAmount curBalance = pwallet->GetBalance(ISMINE_NO, 0, coin_control.m_avoid_address_reuse).m_mine_trusted; CAmount maxNeeded = nValue + (fSubtractFeeFromAmount ? 0 : pwallet->m_default_max_tx_fee);
CAmount curBalance = pwallet->GetBalance(ISMINE_NO, 0, coin_control.m_avoid_address_reuse, maxNeeded).m_mine_trusted;
// Check amount // Check amount
if (nValue <= 0) if (nValue <= 0)

View file

@ -2465,7 +2465,7 @@ void MaybeResendWalletTxs()
*/ */
CWallet::Balance CWallet::GetBalance(isminefilter filter, const int min_depth, bool avoid_reuse) const CWallet::Balance CWallet::GetBalance(isminefilter filter, const int min_depth, bool avoid_reuse, CAmount earlyExit) const
{ {
Balance ret; Balance ret;
if (!avoid_reuse) if (!avoid_reuse)
@ -2491,6 +2491,8 @@ CWallet::Balance CWallet::GetBalance(isminefilter filter, const int min_depth, b
} }
ret.m_mine_immature += wtx.GetImmatureCredit(*locked_chain); ret.m_mine_immature += wtx.GetImmatureCredit(*locked_chain);
ret.m_watchonly_immature += wtx.GetImmatureWatchOnlyCredit(*locked_chain); ret.m_watchonly_immature += wtx.GetImmatureWatchOnlyCredit(*locked_chain);
if (earlyExit > 0 && ret.m_mine_trusted >= earlyExit)
break;
} }
} }
return ret; return ret;

View file

@ -1132,7 +1132,7 @@ public:
CAmount m_watchonly_untrusted_pending{0}; CAmount m_watchonly_untrusted_pending{0};
CAmount m_watchonly_immature{0}; CAmount m_watchonly_immature{0};
}; };
Balance GetBalance(isminefilter filter = ISMINE_NO, int min_depth = 0, bool avoid_reuse = true) const; Balance GetBalance(isminefilter filter = ISMINE_NO, int min_depth = 0, bool avoid_reuse = true, CAmount earlyExit = 0) const;
CAmount GetAvailableBalance(const CCoinControl* coinControl = nullptr) const; CAmount GetAvailableBalance(const CCoinControl* coinControl = nullptr) const;
OutputType TransactionChangeType(OutputType change_type, const std::vector<CRecipient>& vecSend); OutputType TransactionChangeType(OutputType change_type, const std::vector<CRecipient>& vecSend);

View file

@ -36,6 +36,7 @@ class MempoolAcceptanceTest(BitcoinTestFramework):
self.num_nodes = 1 self.num_nodes = 1
self.extra_args = [[ self.extra_args = [[
'-permitbaremultisig=0', '-permitbaremultisig=0',
'-txindex=1'
]] * self.num_nodes ]] * self.num_nodes
self.supports_cli = False self.supports_cli = False

View file

@ -153,13 +153,13 @@ class InvalidMessagesTest(BitcoinTestFramework):
def test_magic_bytes(self): def test_magic_bytes(self):
conn = self.nodes[0].add_p2p_connection(P2PDataStore()) conn = self.nodes[0].add_p2p_connection(P2PDataStore())
def swap_magic_bytes(): async def swap_magic_bytes():
conn._on_data = lambda: None # Need to ignore all incoming messages from now, since they come with "invalid" magic bytes conn._on_data = lambda: None # Need to ignore all incoming messages from now, since they come with "invalid" magic bytes
conn.magic_bytes = b'\x00\x11\x22\x32' conn.magic_bytes = b'\x00\x11\x22\x32'
# Call .result() to block until the atomic swap is complete, otherwise # Call .result() to block until the atomic swap is complete, otherwise
# we might run into races later on # we might run into races later on
asyncio.run_coroutine_threadsafe(asyncio.coroutine(swap_magic_bytes)(), NetworkThread.network_event_loop).result() asyncio.run_coroutine_threadsafe(swap_magic_bytes(), NetworkThread.network_event_loop).result()
with self.nodes[0].assert_debug_log(['PROCESSMESSAGE: INVALID MESSAGESTART ping']): with self.nodes[0].assert_debug_log(['PROCESSMESSAGE: INVALID MESSAGESTART ping']):
conn.send_message(messages.msg_ping(nonce=0xff)) conn.send_message(messages.msg_ping(nonce=0xff))

View file

@ -48,6 +48,7 @@ class RawTransactionsTest(BitcoinTestFramework):
def set_test_params(self): def set_test_params(self):
self.setup_clean_chain = True self.setup_clean_chain = True
self.num_nodes = 3 self.num_nodes = 3
self.extra_args = [['-txindex=1']] * self.num_nodes
def skip_test_if_missing_module(self): def skip_test_if_missing_module(self):
self.skip_if_no_wallet() self.skip_if_no_wallet()

View file

@ -13,7 +13,7 @@ class MerkleBlockTest(BitcoinTestFramework):
self.num_nodes = 4 self.num_nodes = 4
self.setup_clean_chain = True self.setup_clean_chain = True
# Nodes 0/1 are "wallet" nodes, Nodes 2/3 are used for testing # Nodes 0/1 are "wallet" nodes, Nodes 2/3 are used for testing
self.extra_args = [[], [], [], []] self.extra_args = [['-txindex=1']] * self.num_nodes
def skip_test_if_missing_module(self): def skip_test_if_missing_module(self):
self.skip_if_no_wallet() self.skip_if_no_wallet()

View file

@ -92,6 +92,7 @@ class TestNode():
"-logtimemicros", "-logtimemicros",
"-logthreadnames", "-logthreadnames",
"-debug", "-debug",
"-txindex=0",
"-debugexclude=libevent", "-debugexclude=libevent",
"-uacomment=testnode%d" % i, "-uacomment=testnode%d" % i,
] ]