Changeset View
Changeset View
Standalone View
Standalone View
test/functional/example_test.py
Show First 20 Lines • Show All 163 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
self.log.info("Calling a custom method") | self.log.info("Calling a custom method") | ||||
self.custom_method() | self.custom_method() | ||||
self.log.info("Create some blocks") | self.log.info("Create some blocks") | ||||
self.tip = int(self.nodes[0].getbestblockhash(), 16) | self.tip = int(self.nodes[0].getbestblockhash(), 16) | ||||
self.block_time = self.nodes[0].getblock( | self.block_time = self.nodes[0].getblock( | ||||
self.nodes[0].getbestblockhash())['time'] + 1 | self.nodes[0].getbestblockhash())['time'] + 1 | ||||
height = 1 | height = self.nodes[0].getblockcount() | ||||
for i in range(10): | for i in range(10): | ||||
# Use the mininode and blocktools functionality to manually build a block | # Use the mininode and blocktools functionality to manually build a block | ||||
# Calling the generate() rpc is easier, but this allows us to exactly | # Calling the generate() rpc is easier, but this allows us to exactly | ||||
# control the blocks and transactions. | # control the blocks and transactions. | ||||
block = create_block( | block = create_block( | ||||
self.tip, create_coinbase(height), self.block_time) | self.tip, create_coinbase( | ||||
height + 1), self.block_time) | |||||
block.solve() | block.solve() | ||||
block_message = msg_block(block) | block_message = msg_block(block) | ||||
# Send message is used to send a P2P message to the node over our | # Send message is used to send a P2P message to the node over our | ||||
# P2PInterface | # P2PInterface | ||||
self.nodes[0].p2p.send_message(block_message) | self.nodes[0].p2p.send_message(block_message) | ||||
self.tip = block.sha256 | self.tip = block.sha256 | ||||
blocks.append(self.tip) | blocks.append(self.tip) | ||||
self.block_time += 1 | self.block_time += 1 | ||||
▲ Show 20 Lines • Show All 41 Lines • Show Last 20 Lines |