From 2707e6ff6c14dfba715e2ea6451aa06b3cfc369f Mon Sep 17 00:00:00 2001 From: Alfredo Garcia Date: Wed, 18 Mar 2020 19:34:32 -0300 Subject: [PATCH] preserve test semantics Co-authored-by: Daira Hopwood --- qa/rpc-tests/test_framework/util.py | 8 +++----- qa/rpc-tests/turnstile.py | 4 ++-- qa/rpc-tests/wallet_shieldingcoinbase.py | 9 +++------ 3 files changed, 8 insertions(+), 13 deletions(-) diff --git a/qa/rpc-tests/test_framework/util.py b/qa/rpc-tests/test_framework/util.py index 518d8b4c3..99f42028f 100644 --- a/qa/rpc-tests/test_framework/util.py +++ b/qa/rpc-tests/test_framework/util.py @@ -501,11 +501,9 @@ def check_node_log(self, node_number, line_to_check, stop_node = True): self.nodes[node_number].stop() bitcoind_processes[node_number].wait() logpath = self.options.tmpdir + "/node" + str(node_number) + "/regtest/debug.log" - foundErrorMsg = False with open(logpath, "r") as myfile: logdata = myfile.readlines() - for logline in logdata: + for (n, logline) in enumerate(logdata): if line_to_check in logline: - foundErrorMsg = True - break - assert(foundErrorMsg) + return n + raise AssertionError(repr(line_to_check) + " not found") diff --git a/qa/rpc-tests/turnstile.py b/qa/rpc-tests/turnstile.py index 06fdc0c80..18cd34629 100755 --- a/qa/rpc-tests/turnstile.py +++ b/qa/rpc-tests/turnstile.py @@ -166,9 +166,9 @@ class TurnstileTest (BitcoinTestFramework): string_to_find1 = "ConnectBlock(): turnstile violation in " + POOL_NAME.capitalize() + " shielded value pool" string_to_find2 = "InvalidChainFound: invalid block=" string_to_find3 = "ConnectTip(): ConnectBlock " + newhash + " failed" - check_node_log(self, 0, string_to_find1, False) + check_node_log(self, 0, string_to_find1, True) check_node_log(self, 0, string_to_find2, False) - check_node_log(self, 0, string_to_find3) + check_node_log(self, 0, string_to_find3, False) self.start_and_sync_node(0) assert_equal(newhash, self.nodes[0].getbestblockhash()) diff --git a/qa/rpc-tests/wallet_shieldingcoinbase.py b/qa/rpc-tests/wallet_shieldingcoinbase.py index 5cfaec227..910cec65c 100755 --- a/qa/rpc-tests/wallet_shieldingcoinbase.py +++ b/qa/rpc-tests/wallet_shieldingcoinbase.py @@ -154,12 +154,9 @@ class WalletShieldingCoinbaseTest (BitcoinTestFramework): assert_equal("Invalid parameter, spending key for address does not belong to wallet" in errorString, True) # Verify that debug=zrpcunsafe logs params, and that full txid is associated with opid - logcounter = 0 - check_node_log(self, 0, myopid + ": z_sendmany initialized", False) - logcounter = logcounter + 1 - check_node_log(self, 0, myopid + ": z_sendmany finished", False) - logcounter = logcounter + 1 - assert_equal(logcounter, 2) + initialized_line = check_node_log(self, 0, myopid + ": z_sendmany initialized", False) + finished_line = check_node_log(self, 0, myopid + ": z_sendmany finished", False) + assert(initialized_line < finished_line) # check balances (the z_sendmany consumes 3 coinbase utxos) resp = self.nodes[0].z_gettotalbalance()