Changeset View
Changeset View
Standalone View
Standalone View
test/functional/bip65-cltv-p2p.py
Show First 20 Lines • Show All 112 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
tip = block.sha256 | tip = block.sha256 | ||||
block_time += 1 | block_time += 1 | ||||
block = create_block(tip, create_coinbase(CLTV_HEIGHT), block_time) | block = create_block(tip, create_coinbase(CLTV_HEIGHT), block_time) | ||||
block.nVersion = 3 | block.nVersion = 3 | ||||
block.solve() | block.solve() | ||||
node0.send_and_ping(msg_block(block)) | node0.send_and_ping(msg_block(block)) | ||||
assert_equal(int(self.nodes[0].getbestblockhash(), 16), tip) | assert_equal(int(self.nodes[0].getbestblockhash(), 16), tip) | ||||
assert wait_until(lambda: "reject" in node0.last_message.keys()) | wait_until(lambda: "reject" in node0.last_message.keys(), | ||||
lock=mininode_lock) | |||||
with mininode_lock: | with mininode_lock: | ||||
assert_equal(node0.last_message["reject"].code, REJECT_OBSOLETE) | assert_equal(node0.last_message["reject"].code, REJECT_OBSOLETE) | ||||
assert_equal( | assert_equal( | ||||
node0.last_message["reject"].reason, b'bad-version(0x00000003)') | node0.last_message["reject"].reason, b'bad-version(0x00000003)') | ||||
assert_equal(node0.last_message["reject"].data, block.sha256) | assert_equal(node0.last_message["reject"].data, block.sha256) | ||||
del node0.last_message["reject"] | del node0.last_message["reject"] | ||||
self.log.info( | self.log.info( | ||||
Show All 14 Lines | def run_test(self): | ||||
# Now we verify that a block with this transaction is invalid. | # Now we verify that a block with this transaction is invalid. | ||||
block.vtx.append(spendtx) | block.vtx.append(spendtx) | ||||
block.hashMerkleRoot = block.calc_merkle_root() | block.hashMerkleRoot = block.calc_merkle_root() | ||||
block.solve() | block.solve() | ||||
node0.send_and_ping(msg_block(block)) | node0.send_and_ping(msg_block(block)) | ||||
assert_equal(int(self.nodes[0].getbestblockhash(), 16), tip) | assert_equal(int(self.nodes[0].getbestblockhash(), 16), tip) | ||||
assert wait_until(lambda: "reject" in node0.last_message.keys()) | wait_until(lambda: "reject" in node0.last_message.keys(), | ||||
lock=mininode_lock) | |||||
with mininode_lock: | with mininode_lock: | ||||
assert node0.last_message["reject"].code in [ | assert node0.last_message["reject"].code in [ | ||||
REJECT_INVALID, REJECT_NONSTANDARD] | REJECT_INVALID, REJECT_NONSTANDARD] | ||||
assert_equal(node0.last_message["reject"].data, block.sha256) | assert_equal(node0.last_message["reject"].data, block.sha256) | ||||
if node0.last_message["reject"].code == REJECT_INVALID: | if node0.last_message["reject"].code == REJECT_INVALID: | ||||
# Generic rejection when a block is invalid | # Generic rejection when a block is invalid | ||||
assert_equal( | assert_equal( | ||||
node0.last_message["reject"].reason, b'blk-bad-inputs') | node0.last_message["reject"].reason, b'blk-bad-inputs') | ||||
Show All 19 Lines |