Changeset View
Changeset View
Standalone View
Standalone View
test/functional/p2p_invalid_block.py
Show All 13 Lines | |||||
import copy | import copy | ||||
from test_framework.blocktools import ( | from test_framework.blocktools import ( | ||||
create_block, | create_block, | ||||
create_coinbase, | create_coinbase, | ||||
create_transaction, | create_transaction, | ||||
) | ) | ||||
from test_framework.messages import COIN | from test_framework.messages import COIN | ||||
from test_framework.mininode import network_thread_start, P2PDataStore | from test_framework.mininode import P2PDataStore | ||||
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 InvalidBlockRequestTest(BitcoinTestFramework): | class InvalidBlockRequestTest(BitcoinTestFramework): | ||||
def set_test_params(self): | def set_test_params(self): | ||||
self.num_nodes = 1 | self.num_nodes = 1 | ||||
self.setup_clean_chain = True | self.setup_clean_chain = True | ||||
self.extra_args = [["-whitelist=127.0.0.1"]] | self.extra_args = [["-whitelist=127.0.0.1"]] | ||||
def run_test(self): | def run_test(self): | ||||
# Add p2p connection to node0 | # Add p2p connection to node0 | ||||
node = self.nodes[0] # convenience reference to the node | node = self.nodes[0] # convenience reference to the node | ||||
node.add_p2p_connection(P2PDataStore()) | node.add_p2p_connection(P2PDataStore()) | ||||
network_thread_start() | |||||
node.p2p.wait_for_verack() | node.p2p.wait_for_verack() | ||||
best_block = node.getblock(node.getbestblockhash()) | best_block = node.getblock(node.getbestblockhash()) | ||||
tip = int(node.getbestblockhash(), 16) | tip = int(node.getbestblockhash(), 16) | ||||
height = best_block["height"] + 1 | height = best_block["height"] + 1 | ||||
block_time = best_block["time"] + 1 | block_time = best_block["time"] + 1 | ||||
self.log.info("Create a new block with an anyone-can-spend coinbase") | self.log.info("Create a new block with an anyone-can-spend coinbase") | ||||
▲ Show 20 Lines • Show All 79 Lines • Show Last 20 Lines |