move check_node_log framework test to a new file
This commit is contained in:
parent
aa89d3c342
commit
461047ac99
|
@ -82,6 +82,7 @@ testScripts=(
|
|||
'sprout_sapling_migration.py'
|
||||
'turnstile.py'
|
||||
'mining_shielded_coinbase.py'
|
||||
'framework.py'
|
||||
);
|
||||
testScriptsExt=(
|
||||
'getblocktemplate_longpoll.py'
|
||||
|
|
|
@ -0,0 +1,52 @@
|
|||
#!/usr/bin/env python3
|
||||
# Copyright (c) 2020 The Zcash developers
|
||||
# Distributed under the MIT software license, see the accompanying
|
||||
# file COPYING or https://www.opensource.org/licenses/mit-license.php .
|
||||
|
||||
from test_framework.test_framework import BitcoinTestFramework
|
||||
from test_framework.util import (
|
||||
assert_raises,
|
||||
bitcoind_processes,
|
||||
connect_nodes,
|
||||
initialize_chain_clean,
|
||||
start_node,
|
||||
check_node_log,
|
||||
)
|
||||
|
||||
class FrameworkTest (BitcoinTestFramework):
|
||||
|
||||
def setup_chain(self):
|
||||
print("Initializing test directory "+self.options.tmpdir)
|
||||
initialize_chain_clean(self.options.tmpdir, 4)
|
||||
|
||||
def start_node_with(self, index, extra_args=[]):
|
||||
args = []
|
||||
return start_node(index, self.options.tmpdir, args + extra_args)
|
||||
|
||||
def setup_network(self, split=False):
|
||||
self.nodes = []
|
||||
self.nodes.append(self.start_node_with(0))
|
||||
self.nodes.append(self.start_node_with(1))
|
||||
connect_nodes(self.nodes[1], 0)
|
||||
self.is_network_split=False
|
||||
self.sync_all()
|
||||
|
||||
def run_test (self):
|
||||
|
||||
# Test the check_node_log utility function
|
||||
string_to_find = "Zcash version"
|
||||
check_node_log(self, 1, string_to_find)
|
||||
|
||||
# Node 1 was stopped to check the logs, need to be restarted
|
||||
self.nodes[1] = self.start_node_with(1, [])
|
||||
connect_nodes(self.nodes[1], 0)
|
||||
|
||||
assert_raises(AssertionError, check_node_log, self, 1, "Will not be found")
|
||||
|
||||
# Need to start node 1 before leaving the test
|
||||
self.nodes[1] = self.start_node_with(1, [])
|
||||
connect_nodes(self.nodes[1], 0)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
FrameworkTest().main()
|
|
@ -67,17 +67,11 @@ class ShieldCoinbaseTest (BitcoinTestFramework):
|
|||
|
||||
# Stop node 1 and check logs to verify the block was rejected correctly
|
||||
string_to_find = "CheckTransaction(): coinbase has output descriptions"
|
||||
check_node_log(self, 1, ["-mineraddress=%s" % node1_zaddr], string_to_find)
|
||||
check_node_log(self, 1, string_to_find)
|
||||
|
||||
# Test assert in check_node_log
|
||||
try:
|
||||
string_to_find = "Will not be found"
|
||||
check_node_log(self, 1, ["-mineraddress=%s" % node1_zaddr], string_to_find)
|
||||
except AssertionError:
|
||||
print("Assert OK")
|
||||
# Restart node 1
|
||||
self.nodes[1] = self.start_node_with(1, ["-mineraddress=%s" % node1_zaddr])
|
||||
connect_nodes(self.nodes[1], 0)
|
||||
# Restart node 1
|
||||
self.nodes[1] = self.start_node_with(1, ["-mineraddress=%s" % node1_zaddr])
|
||||
connect_nodes(self.nodes[1], 0)
|
||||
|
||||
# Activate Heartwood
|
||||
print("Activating Heartwood")
|
||||
|
|
|
@ -495,7 +495,7 @@ def get_coinbase_address(node, expected_utxos=None):
|
|||
assert(len(addrs) > 0)
|
||||
return addrs[0]
|
||||
|
||||
def check_node_log(self, node_number, restart_arguments, line_to_check):
|
||||
def check_node_log(self, node_number, line_to_check):
|
||||
print("Checking node " + str(node_number) + " logs")
|
||||
self.nodes[node_number].stop()
|
||||
bitcoind_processes[node_number].wait()
|
||||
|
@ -508,6 +508,3 @@ def check_node_log(self, node_number, restart_arguments, line_to_check):
|
|||
foundErrorMsg = True
|
||||
break
|
||||
assert(foundErrorMsg)
|
||||
|
||||
self.nodes[node_number] = self.start_node_with(node_number, restart_arguments)
|
||||
connect_nodes(self.nodes[node_number], node_number - 1)
|
||||
|
|
Loading…
Reference in New Issue