mirror of
https://github.com/dashpay/dash.git
synced 2024-12-26 12:32:48 +01:00
8368bd795e
fa1cd9e1ddc6918c3d600d36eadea71eebb242b6 test: Remove unused lock arg from BitcoinTestFramework.wait_until (MarcoFalke) fad2794e93b4f5976e81793a4a63aa03a2c8c686 test: Rename wait until helper to wait_until_helper (MarcoFalke) facb41bf1d1b7ee552c627f9829b4494b817ce28 test: Remove unused p2p_lock in VersionBitsWarningTest (MarcoFalke) Pull request description: This avoids confusion with the `wait_until` member functions, which should be preferred because they take the appropriate locks and scale the timeout appropriately on their own. ACKs for top commit: laanwj: Code review ACK fa1cd9e1ddc6918c3d600d36eadea71eebb242b6 hebasto: ACK fa1cd9e1ddc6918c3d600d36eadea71eebb242b6, I have reviewed the code and it looks OK, I agree it can be merged. Tree-SHA512: 319d400085606a4c738e314824037f72998e6657d8622b363726842aba968744f23c56d27275dfe506b8cbbb6e97fc39ca1d325db05d4d67df0e8b35f2244d5c
64 lines
2.3 KiB
Python
Executable File
64 lines
2.3 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
# Copyright (c) 2018-2023 The Dash Core developers
|
|
# Distributed under the MIT software license, see the accompanying
|
|
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
from test_framework.test_framework import BitcoinTestFramework
|
|
|
|
'''
|
|
'''
|
|
|
|
class SporkTest(BitcoinTestFramework):
|
|
def set_test_params(self):
|
|
self.num_nodes = 3
|
|
self.setup_clean_chain = True
|
|
self.extra_args = [["-sporkkey=cP4EKFyJsHT39LDqgdcB43Y3YXjNyjb5Fuas1GQSeAtjnZWmZEQK"], [], []]
|
|
|
|
def setup_network(self):
|
|
self.disable_mocktime()
|
|
self.setup_nodes()
|
|
# connect only 2 first nodes at start
|
|
self.connect_nodes(0, 1)
|
|
|
|
def get_test_spork_state(self, node):
|
|
info = node.spork('active')
|
|
# use InstantSend spork for tests
|
|
return info['SPORK_2_INSTANTSEND_ENABLED']
|
|
|
|
def set_test_spork_state(self, node, state):
|
|
if state:
|
|
value = 0
|
|
else:
|
|
value = 4070908800
|
|
# use InstantSend spork for tests
|
|
node.sporkupdate("SPORK_2_INSTANTSEND_ENABLED", value)
|
|
|
|
def run_test(self):
|
|
spork_default_state = self.get_test_spork_state(self.nodes[0])
|
|
# check test spork default state matches on all nodes
|
|
assert self.get_test_spork_state(self.nodes[1]) == spork_default_state
|
|
assert self.get_test_spork_state(self.nodes[2]) == spork_default_state
|
|
|
|
# check spork propagation for connected nodes
|
|
spork_new_state = not spork_default_state
|
|
self.set_test_spork_state(self.nodes[0], spork_new_state)
|
|
self.wait_until(lambda: self.get_test_spork_state(self.nodes[1]), timeout=10)
|
|
|
|
# restart nodes to check spork persistence
|
|
self.stop_node(0)
|
|
self.stop_node(1)
|
|
self.start_node(0)
|
|
self.start_node(1)
|
|
assert self.get_test_spork_state(self.nodes[0]) == spork_new_state
|
|
assert self.get_test_spork_state(self.nodes[1]) == spork_new_state
|
|
|
|
# Generate one block to kick off masternode sync, which also starts sporks syncing for node2
|
|
self.nodes[1].generate(1)
|
|
|
|
# connect new node and check spork propagation after restoring from cache
|
|
self.connect_nodes(1, 2)
|
|
self.wait_until(lambda: self.get_test_spork_state(self.nodes[2]), timeout=10)
|
|
|
|
if __name__ == '__main__':
|
|
SporkTest().main()
|