Changeset View
Changeset View
Standalone View
Standalone View
test/functional/abc-replay-protection.py
#!/usr/bin/env python3 | #!/usr/bin/env python3 | ||||
# Copyright (c) 2015-2016 The Bitcoin Core developers | # Copyright (c) 2015-2016 The Bitcoin Core developers | ||||
# Copyright (c) 2017 The Bitcoin developers | # Copyright (c) 2017 The Bitcoin developers | ||||
# Distributed under the MIT software license, see the accompanying | # Distributed under the MIT software license, see the accompanying | ||||
# file COPYING or http://www.opensource.org/licenses/mit-license.php. | # file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
""" | """ | ||||
This test checks activation of UAHF and the different consensus | This test checks activation of UAHF and the different consensus | ||||
related to this activation. | related to this activation. | ||||
It is derived from the much more complex p2p-fullblocktest. | It is derived from the much more complex p2p-fullblocktest. | ||||
""" | """ | ||||
from test_framework.cdefs import GREAT_WALL_ACTIVATION_TIME | |||||
from test_framework.test_framework import ComparisonTestFramework | from test_framework.test_framework import ComparisonTestFramework | ||||
from test_framework.util import assert_equal, assert_raises_rpc_error | from test_framework.util import assert_equal, assert_raises_rpc_error | ||||
from test_framework.comptool import TestManager, TestInstance, RejectResult | from test_framework.comptool import TestManager, TestInstance, RejectResult | ||||
from test_framework.blocktools import * | from test_framework.blocktools import * | ||||
import time | import time | ||||
from test_framework.key import CECKey | from test_framework.key import CECKey | ||||
from test_framework.script import * | from test_framework.script import * | ||||
Show All 29 Lines | def run_test(self): | ||||
self.test.add_all_connections(self.nodes) | self.test.add_all_connections(self.nodes) | ||||
network_thread_start() | network_thread_start() | ||||
self.nodes[0].setmocktime(REPLAY_PROTECTION_START_TIME) | self.nodes[0].setmocktime(REPLAY_PROTECTION_START_TIME) | ||||
self.test.run() | self.test.run() | ||||
def next_block(self, number): | def next_block(self, number): | ||||
if self.tip == None: | if self.tip == None: | ||||
base_block_hash = self.genesis_hash | base_block_hash = self.genesis_hash | ||||
block_time = int(time.time()) + 1 | |||||
# Activation of GREAT_WALL_ACTIVATION_TIME clears the mempool, so | |||||
# to avoid this, the tip is set to start after this upgrade. | |||||
block_time = max(int(time.time() + 1), GREAT_WALL_ACTIVATION_TIME) | |||||
deadalnix: Just launch the node with GREAT_WALL_ACTIVATION_TIME set absurdly far away in the future. | |||||
dagurvalUnsubmitted Not Done Inline ActionsThat's worse, not better. dagurval: That's worse, not better. | |||||
else: | else: | ||||
base_block_hash = self.tip.sha256 | base_block_hash = self.tip.sha256 | ||||
block_time = self.tip.nTime + 1 | block_time = self.tip.nTime + 1 | ||||
# First create the coinbase | # First create the coinbase | ||||
height = self.block_heights[base_block_hash] + 1 | height = self.block_heights[base_block_hash] + 1 | ||||
coinbase = create_coinbase(height) | coinbase = create_coinbase(height) | ||||
coinbase.rehash() | coinbase.rehash() | ||||
block = create_block(base_block_hash, coinbase, block_time) | block = create_block(base_block_hash, coinbase, block_time) | ||||
▲ Show 20 Lines • Show All 216 Lines • Show Last 20 Lines |
Just launch the node with GREAT_WALL_ACTIVATION_TIME set absurdly far away in the future.