Changeset View
Changeset View
Standalone View
Standalone View
test/functional/abc-get-invalid-block.py
Show All 15 Lines | |||||
from test_framework.test_framework import BitcoinTestFramework | from test_framework.test_framework import BitcoinTestFramework | ||||
from test_framework.util import assert_equal | from test_framework.util import assert_equal | ||||
class GetInvalidBlockTest(BitcoinTestFramework): | class GetInvalidBlockTest(BitcoinTestFramework): | ||||
def set_test_params(self): | def set_test_params(self): | ||||
self.num_nodes = 1 | self.num_nodes = 1 | ||||
def skip_test_if_missing_module(self): | |||||
self.skip_if_no_wallet() | |||||
def run_test(self): | def run_test(self): | ||||
node = self.nodes[0] | node = self.nodes[0] | ||||
node.add_p2p_connection(P2PInterface()) | node.add_p2p_connection(P2PInterface()) | ||||
chaintip = node.getbestblockhash() | chaintip = node.getbestblockhash() | ||||
# Mine some blocks and invalidate them | # Mine some blocks and invalidate them | ||||
blocks = node.generate(nblocks=3) | blocks = node.generatetoaddress( | ||||
3, node.get_deterministic_priv_key().address) | |||||
assert_equal(blocks[-1], node.getbestblockhash()) | assert_equal(blocks[-1], node.getbestblockhash()) | ||||
node.invalidateblock(blocks[0]) | node.invalidateblock(blocks[0]) | ||||
assert_equal(chaintip, node.getbestblockhash()) | assert_equal(chaintip, node.getbestblockhash()) | ||||
# Clear any old messages | # Clear any old messages | ||||
with mininode_lock: | with mininode_lock: | ||||
node.p2p.last_message.pop("block", None) | node.p2p.last_message.pop("block", None) | ||||
node.p2p.last_message.pop("cmpctblock", None) | node.p2p.last_message.pop("cmpctblock", None) | ||||
Show All 37 Lines |