mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 03:52:49 +01:00
Merge #19350: test: Refactor tests using restart_node
20b6e959449d0c07639599b99ba917d2cac62493 test: refactor functional tests to use restart_node (Christopher Coverdale) Pull request description: fixes #19345 This PR replaces consecutive calls to `stop_node()` and `start_node()` with `restart_node()` where appropriate in the functional tests. The commit messages are repetitive but focused on each file changed with the intention of squashing if applicable. ACKs for top commit: laanwj: ACK 20b6e959449d0c07639599b99ba917d2cac62493 Tree-SHA512: 1cfa1fb8c5f01a7b00fe44e80dbef072147f21e3891098817acd4275b0c5d91dc1c787594209e117edd418f2fa3a7b2dfcbafdf87efc07f740040938d641f3a9
This commit is contained in:
parent
98322e44a9
commit
d90a46175b
@ -88,8 +88,7 @@ class LLMQChainLocksTest(DashTestFramework):
|
||||
self.log.info("Keep node connected and let it try to reorg the chain")
|
||||
good_tip = self.nodes[0].getbestblockhash()
|
||||
self.log.info("Restart it so that it forgets all the chainlock messages from the past")
|
||||
self.stop_node(0)
|
||||
self.start_node(0)
|
||||
self.restart_node(0)
|
||||
self.connect_nodes(0, 1)
|
||||
assert self.nodes[0].getbestblockhash() == good_tip
|
||||
self.nodes[0].invalidateblock(good_tip)
|
||||
@ -119,11 +118,9 @@ class LLMQChainLocksTest(DashTestFramework):
|
||||
|
||||
self.log.info("Should switch to the best non-conflicting tip (not to the most work chain) on restart")
|
||||
assert int(self.nodes[0].getblock(bad_tip)["chainwork"], 16) > int(self.nodes[1].getblock(good_tip)["chainwork"], 16)
|
||||
self.stop_node(0)
|
||||
self.start_node(0)
|
||||
self.restart_node(0)
|
||||
self.nodes[0].invalidateblock(good_fork)
|
||||
self.stop_node(0)
|
||||
self.start_node(0)
|
||||
self.restart_node(0)
|
||||
time.sleep(1)
|
||||
assert self.nodes[0].getbestblockhash() == good_tip
|
||||
|
||||
|
@ -71,8 +71,7 @@ class LoadblockTest(BitcoinTestFramework):
|
||||
check=True)
|
||||
|
||||
self.log.info("Restart second, unsynced node with bootstrap file")
|
||||
self.stop_node(1)
|
||||
self.start_node(1, ["-loadblock=" + bootstrap_file])
|
||||
self.restart_node(1, extra_args=["-loadblock=" + bootstrap_file])
|
||||
assert_equal(self.nodes[1].getblockcount(), 100) # start_node is blocking on all block files being imported
|
||||
|
||||
assert_equal(self.nodes[1].getblockchaininfo()['blocks'], 100)
|
||||
|
@ -67,8 +67,7 @@ class LoggingTest(BitcoinTestFramework):
|
||||
assert not os.path.isfile(default_log_path)
|
||||
|
||||
# just sanity check no crash here
|
||||
self.stop_node(0)
|
||||
self.start_node(0, ["-debuglogfile=%s" % os.devnull])
|
||||
self.restart_node(0, ["-debuglogfile=%s" % os.devnull])
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
@ -257,8 +257,7 @@ class PruneTest(BitcoinTestFramework):
|
||||
assert_raises_rpc_error(-1, "Cannot prune blocks because node is not in prune mode", node.pruneblockchain, 500)
|
||||
|
||||
# now re-start in manual pruning mode
|
||||
self.stop_node(node_number, expected_stderr='Warning: You are starting with governance validation disabled.')
|
||||
self.start_node(node_number, extra_args=["-dip3params=2000:2000", "-dip8params=2000", "-disablegovernance", "-txindex=0", "-prune=1"])
|
||||
self.restart_node(node_number, extra_args=["-dip3params=2000:2000", "-dip8params=2000", "-disablegovernance", "-txindex=0", "-prune=1"])
|
||||
node = self.nodes[node_number]
|
||||
assert_equal(node.getblockcount(), 995)
|
||||
|
||||
@ -327,16 +326,14 @@ class PruneTest(BitcoinTestFramework):
|
||||
assert not has_block(3), "blk00003.dat is still there, should be pruned by now"
|
||||
|
||||
# stop node, start back up with auto-prune at 550 MiB, make sure still runs
|
||||
self.stop_node(node_number, expected_stderr='Warning: You are starting with governance validation disabled. This is expected because you are running a pruned node.')
|
||||
self.start_node(node_number, extra_args=["-dip3params=2000:2000", "-dip8params=2000", "-disablegovernance", "-txindex=0", "-prune=550"])
|
||||
self.restart_node(node_number, extra_args=["-dip3params=2000:2000", "-dip8params=2000", "-disablegovernance", "-txindex=0", "-prune=550"])
|
||||
|
||||
self.log.info("Success")
|
||||
|
||||
def wallet_test(self):
|
||||
# check that the pruning node's wallet is still in good shape
|
||||
self.log.info("Stop and start pruning node to trigger wallet rescan")
|
||||
self.stop_node(2, expected_stderr='Warning: You are starting with governance validation disabled. This is expected because you are running a pruned node.')
|
||||
self.start_node(2, extra_args=["-dip3params=2000:2000", "-dip8params=2000", "-disablegovernance", "-txindex=0", "-prune=550"])
|
||||
self.restart_node(2, extra_args=["-dip3params=2000:2000", "-dip8params=2000", "-disablegovernance", "-txindex=0", "-prune=550"])
|
||||
self.log.info("Success")
|
||||
|
||||
# check that wallet loads successfully when restarting a pruned node after IBD.
|
||||
@ -345,8 +342,7 @@ class PruneTest(BitcoinTestFramework):
|
||||
self.connect_nodes(0, 5)
|
||||
nds = [self.nodes[0], self.nodes[5]]
|
||||
self.sync_blocks(nds, wait=5, timeout=300)
|
||||
self.stop_node(5, expected_stderr='Warning: You are starting with governance validation disabled. This is expected because you are running a pruned node.') # stop and start to trigger rescan
|
||||
self.start_node(5, extra_args=["-dip3params=2000:2000", "-dip8params=2000", "-disablegovernance", "-txindex=0", "-prune=550"])
|
||||
self.restart_node(5, extra_args=["-dip3params=2000:2000", "-dip8params=2000", "-disablegovernance", "-txindex=0", "-prune=550"]) # restart to trigger rescan
|
||||
self.log.info("Success")
|
||||
|
||||
def run_test(self):
|
||||
|
@ -63,8 +63,7 @@ class DisconnectBanTest(BitcoinTestFramework):
|
||||
self.bump_mocktime(2)
|
||||
wait_until(lambda: len(self.nodes[1].listbanned()) == 3, timeout=10)
|
||||
|
||||
self.stop_node(1)
|
||||
self.start_node(1)
|
||||
self.restart_node(1)
|
||||
|
||||
listAfterShutdown = self.nodes[1].listbanned()
|
||||
assert_equal("127.0.0.0/24", listAfterShutdown[0]['address'])
|
||||
|
@ -93,8 +93,7 @@ class AbandonConflictTest(BitcoinTestFramework):
|
||||
|
||||
# Restart the node with a higher min relay fee so the parent tx is no longer in mempool
|
||||
# TODO: redo with eviction
|
||||
self.stop_node(0)
|
||||
self.start_node(0, extra_args=["-minrelaytxfee=0.0001"])
|
||||
self.restart_node(0, extra_args=["-minrelaytxfee=0.0001"])
|
||||
assert self.nodes[0].getmempoolinfo()['loaded']
|
||||
|
||||
# Verify txs no longer in either node's mempool
|
||||
@ -129,8 +128,7 @@ class AbandonConflictTest(BitcoinTestFramework):
|
||||
assert_equal(tx['trusted'], False)
|
||||
|
||||
# Verify that even with a low min relay fee, the tx is not reaccepted from wallet on startup once abandoned
|
||||
self.stop_node(0)
|
||||
self.start_node(0, extra_args=["-minrelaytxfee=0.00001"])
|
||||
self.restart_node(0, extra_args=["-minrelaytxfee=0.00001"])
|
||||
assert self.nodes[0].getmempoolinfo()['loaded']
|
||||
|
||||
assert_equal(len(self.nodes[0].getrawmempool()), 0)
|
||||
@ -151,8 +149,7 @@ class AbandonConflictTest(BitcoinTestFramework):
|
||||
balance = newbalance
|
||||
|
||||
# Remove using high relay fee again
|
||||
self.stop_node(0)
|
||||
self.start_node(0, extra_args=["-minrelaytxfee=0.0001"])
|
||||
self.restart_node(0, extra_args=["-minrelaytxfee=0.0001"])
|
||||
assert self.nodes[0].getmempoolinfo()['loaded']
|
||||
assert_equal(len(self.nodes[0].getrawmempool()), 0)
|
||||
newbalance = self.nodes[0].getbalance()
|
||||
|
@ -107,8 +107,7 @@ class AvoidReuseTest(BitcoinTestFramework):
|
||||
assert_equal(self.nodes[1].getwalletinfo()["avoid_reuse"], True)
|
||||
|
||||
# Stop and restart node 1
|
||||
self.stop_node(1)
|
||||
self.start_node(1)
|
||||
self.restart_node(1)
|
||||
self.connect_nodes(0, 1)
|
||||
|
||||
# Flags should still be node1.avoid_reuse=false, node2.avoid_reuse=true
|
||||
|
@ -450,8 +450,7 @@ class WalletTest(BitcoinTestFramework):
|
||||
|
||||
# Try with walletrejectlongchains
|
||||
# Double chain limit but require combining inputs, so we pass SelectCoinsMinConf
|
||||
self.stop_node(0)
|
||||
self.start_node(0, extra_args=["-walletrejectlongchains", "-limitancestorcount=" + str(2 * chainlimit)])
|
||||
self.restart_node(0, extra_args=["-walletrejectlongchains", "-limitancestorcount=" + str(2 * chainlimit)])
|
||||
|
||||
# wait until the wallet has submitted all transactions to the mempool
|
||||
wait_until(lambda: len(self.nodes[0].getrawmempool()) == chainlimit * 2)
|
||||
|
@ -99,8 +99,7 @@ class WalletHDTest(BitcoinTestFramework):
|
||||
self.sync_all()
|
||||
|
||||
# Needs rescan
|
||||
self.stop_node(1)
|
||||
self.start_node(1, extra_args=self.extra_args[1] + ['-rescan'])
|
||||
self.restart_node(1, extra_args=self.extra_args[1] + ['-rescan'])
|
||||
assert_equal(self.nodes[1].getbalance(), NUM_HD_ADDS + 1)
|
||||
|
||||
# Try a RPC based rescan
|
||||
|
@ -75,8 +75,7 @@ class ReorgsRestoreTest(BitcoinTestFramework):
|
||||
assert_equal(conflicted["walletconflicts"][0], conflicting["txid"])
|
||||
|
||||
# Node0 wallet is shutdown
|
||||
self.stop_node(0)
|
||||
self.start_node(0)
|
||||
self.restart_node(0)
|
||||
|
||||
# The block chain re-orgs and the tx is included in a different block
|
||||
self.nodes[1].generate(9)
|
||||
|
@ -91,8 +91,7 @@ class WalletUpgradeToHDTest(BitcoinTestFramework):
|
||||
self.recover_non_hd()
|
||||
|
||||
self.log.info("No mnemonic, no mnemonic passphrase, no wallet passphrase, should result in completely different keys")
|
||||
self.stop_node(0)
|
||||
self.start_node(0, extra_args=['-keypool=10'])
|
||||
self.restart_node(0, extra_args=['-keypool=10'])
|
||||
assert node.upgradetohd("", "", "", True)
|
||||
# Completely different keys, no HD coins should be recovered
|
||||
assert mnemonic != node.dumphdinfo()['mnemonic']
|
||||
@ -141,8 +140,7 @@ class WalletUpgradeToHDTest(BitcoinTestFramework):
|
||||
self.recover_non_hd()
|
||||
|
||||
self.log.info("Same mnemonic, no mnemonic passphrase, no wallet passphrase, large enough keepool, should recover all coins with no extra rescan")
|
||||
self.stop_node(0)
|
||||
self.start_node(0, extra_args=['-keypool=10'])
|
||||
self.restart_node(0, extra_args=['-keypool=10'])
|
||||
assert node.upgradetohd(mnemonic)
|
||||
assert_equal(mnemonic, node.dumphdinfo()['mnemonic'])
|
||||
assert_equal(chainid, node.getwalletinfo()['hdchainid'])
|
||||
@ -152,8 +150,7 @@ class WalletUpgradeToHDTest(BitcoinTestFramework):
|
||||
self.recover_non_hd()
|
||||
|
||||
self.log.info("Same mnemonic, no mnemonic passphrase, no wallet passphrase, large enough keepool, rescan is skipped initially, should recover all coins after rescanblockchain")
|
||||
self.stop_node(0)
|
||||
self.start_node(0, extra_args=['-keypool=10'])
|
||||
self.restart_node(0, extra_args=['-keypool=10'])
|
||||
assert node.upgradetohd(mnemonic, "", "", False)
|
||||
assert_equal(mnemonic, node.dumphdinfo()['mnemonic'])
|
||||
assert_equal(chainid, node.getwalletinfo()['hdchainid'])
|
||||
|
Loading…
Reference in New Issue
Block a user