mirror of
https://github.com/dashpay/dash.git
synced 2024-12-27 04:52:59 +01:00
4c8e77a48d
d841301010914203fb5ef02627c76fad99cb11f1 test: Add docstring to wait_until() in util.py to warn about its usage (Seleme Topuz) 1343c86c7cc1fc896696b3ed87c12039e4ef3a0c test: Update wait_until usage in tests not to use the one from utils (Seleme Topuz) Pull request description: Replace global (from [test_framework/util.py](https://github.com/bitcoin/bitcoin/blob/master/test/functional/test_framework/util.py#L228)) `wait_until()` usages with the ones provided by `BitcoinTestFramework` and `P2PInterface` classes. The motivation behind this change is that the `util.wait_until()` expects a timeout, timeout_factor and lock and it is not aware of the context of the test framework. `BitcoinTestFramework` offers a `wait_until()` which has an understandable amount of default `timeout` and a shared `timeout_factor`. Moreover, on top of these, `mininode.wait_until()` also has a shared lock. closes #19080 ACKs for top commit: MarcoFalke: ACK d841301010914203fb5ef02627c76fad99cb11f1 🦆 kallewoof: utACK d841301010914203fb5ef02627c76fad99cb11f1 Tree-SHA512: 81604f4cfa87fed98071a80e4afe940b3897fe65cf680a69619a93e97d45f25b313c12227de7040e19517fa9c003291b232f1b40b2567aba0148f22c23c47a88
51 lines
1.6 KiB
Python
Executable File
51 lines
1.6 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
# Copyright (c) 2019-2020 The Bitcoin Core developers
|
|
# Distributed under the MIT software license, see the accompanying
|
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
"""Test dashd aborts if can't disconnect a block.
|
|
|
|
- Start a single node and generate 3 blocks.
|
|
- Delete the undo data.
|
|
- Mine a fork that requires disconnecting the tip.
|
|
- Verify that dashd AbortNode's.
|
|
"""
|
|
|
|
from test_framework.test_framework import BitcoinTestFramework
|
|
from test_framework.util import get_datadir_path
|
|
import os
|
|
|
|
|
|
class AbortNodeTest(BitcoinTestFramework):
|
|
def set_test_params(self):
|
|
self.setup_clean_chain = True
|
|
self.num_nodes = 2
|
|
self.rpc_timeout = 240
|
|
|
|
def setup_network(self):
|
|
self.setup_nodes()
|
|
# We'll connect the nodes later
|
|
|
|
def run_test(self):
|
|
self.nodes[0].generate(3)
|
|
datadir = get_datadir_path(self.options.tmpdir, 0)
|
|
|
|
# Deleting the undo file will result in reorg failure
|
|
os.unlink(os.path.join(datadir, self.chain, 'blocks', 'rev00000.dat'))
|
|
|
|
# Connecting to a node with a more work chain will trigger a reorg
|
|
# attempt.
|
|
self.nodes[1].generate(3)
|
|
with self.nodes[0].assert_debug_log(["Failed to disconnect block"]):
|
|
self.connect_nodes(0, 1)
|
|
self.nodes[1].generate(1)
|
|
|
|
# Check that node0 aborted
|
|
self.log.info("Waiting for crash")
|
|
self.nodes[0].wait_until_stopped(timeout=200)
|
|
self.log.info("Node crashed - now verifying restart fails")
|
|
self.nodes[0].assert_start_raises_init_error()
|
|
|
|
|
|
if __name__ == '__main__':
|
|
AbortNodeTest().main()
|