Changeset View
Changeset View
Standalone View
Standalone View
test/functional/abc-invalid-chains.py
#!/usr/bin/env python3 | #!/usr/bin/env python3 | ||||
# Copyright (c) 2019 The Bitcoin developers | # Copyright (c) 2019 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-ilncense.php. | # file COPYING or http://www.opensource.org/licenses/mit-ilncense.php. | ||||
import time | import time | ||||
from test_framework.test_framework import BitcoinTestFramework | from test_framework.test_framework import BitcoinTestFramework | ||||
from test_framework.mininode import network_thread_start, P2PDataStore | from test_framework.mininode import P2PDataStore | ||||
from test_framework.util import assert_equal | from test_framework.util import assert_equal | ||||
from test_framework.blocktools import ( | from test_framework.blocktools import ( | ||||
create_block, | create_block, | ||||
create_coinbase, | create_coinbase, | ||||
) | ) | ||||
class InvalidChainsTest(BitcoinTestFramework): | class InvalidChainsTest(BitcoinTestFramework): | ||||
Show All 23 Lines | def next_block(self, number): | ||||
self.block_heights[block.sha256] = height | self.block_heights[block.sha256] = height | ||||
assert number not in self.blocks | assert number not in self.blocks | ||||
self.blocks[number] = block | self.blocks[number] = block | ||||
return block | return block | ||||
def run_test(self): | def run_test(self): | ||||
node = self.nodes[0] | node = self.nodes[0] | ||||
node.add_p2p_connection(P2PDataStore()) | node.add_p2p_connection(P2PDataStore()) | ||||
network_thread_start() | |||||
node.p2p.wait_for_verack() | node.p2p.wait_for_verack() | ||||
self.genesis_hash = int(node.getbestblockhash(), 16) | self.genesis_hash = int(node.getbestblockhash(), 16) | ||||
self.block_heights[self.genesis_hash] = 0 | self.block_heights[self.genesis_hash] = 0 | ||||
# move the tip back to a previous block | # move the tip back to a previous block | ||||
def tip(number): | def tip(number): | ||||
self.tip = self.blocks[number] | self.tip = self.blocks[number] | ||||
▲ Show 20 Lines • Show All 78 Lines • Show Last 20 Lines |