mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-02 09:46:52 -05:00
[test] Restart a node with empty addrman
Currently in tests where we are interested in contents of addrman, addresses which were added to the node's addrman in previous tests leak into the current test. example: addresses added in addpeeraddress test leak into getaddrmaninfo and getrawaddrman tests. It is cleaner to design the tests to be modular and without such leaks so that we don't need to deal with context from previous tests
This commit is contained in:
parent
71c19915c0
commit
a897866109
2 changed files with 9 additions and 8 deletions
|
@ -157,12 +157,7 @@ class AddrmanTest(BitcoinTestFramework):
|
|||
)
|
||||
|
||||
self.log.info("Check that missing addrman is recreated")
|
||||
self.stop_node(0)
|
||||
os.remove(peers_dat)
|
||||
with self.nodes[0].assert_debug_log([
|
||||
f'Creating peers.dat because the file was not found ("{peers_dat}")',
|
||||
]):
|
||||
self.start_node(0)
|
||||
self.restart_node(0, clear_addrman=True)
|
||||
assert_equal(self.nodes[0].getnodeaddresses(), [])
|
||||
|
||||
|
||||
|
|
|
@ -577,10 +577,16 @@ class BitcoinTestFramework(metaclass=BitcoinTestMetaClass):
|
|||
# Wait for nodes to stop
|
||||
node.wait_until_stopped()
|
||||
|
||||
def restart_node(self, i, extra_args=None):
|
||||
def restart_node(self, i, extra_args=None, clear_addrman=False):
|
||||
"""Stop and start a test node"""
|
||||
self.stop_node(i)
|
||||
self.start_node(i, extra_args)
|
||||
if clear_addrman:
|
||||
peers_dat = self.nodes[i].chain_path / "peers.dat"
|
||||
os.remove(peers_dat)
|
||||
with self.nodes[i].assert_debug_log(expected_msgs=[f'Creating peers.dat because the file was not found ("{peers_dat}")']):
|
||||
self.start_node(i, extra_args)
|
||||
else:
|
||||
self.start_node(i, extra_args)
|
||||
|
||||
def wait_for_node_exit(self, i, timeout):
|
||||
self.nodes[i].process.wait(timeout)
|
||||
|
|
Loading…
Add table
Reference in a new issue