Changeset View
Changeset View
Standalone View
Standalone View
test/functional/feature_block.py
Show First 20 Lines • Show All 776 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
# | # | ||||
# tx with prevout.n out of range | # tx with prevout.n out of range | ||||
self.log.info( | self.log.info( | ||||
"Reject a block with a transaction with prevout.n out of range") | "Reject a block with a transaction with prevout.n out of range") | ||||
self.move_tip(57) | self.move_tip(57) | ||||
b58 = self.next_block(58, spend=out[17]) | b58 = self.next_block(58, spend=out[17]) | ||||
tx = CTransaction() | tx = CTransaction() | ||||
assert(len(out[17].tx.vout) < 42) | assert len(out[17].tx.vout) < 42 | ||||
tx.vin.append( | tx.vin.append( | ||||
CTxIn(COutPoint(out[17].tx.sha256, 42), CScript([OP_TRUE]), 0xffffffff)) | CTxIn(COutPoint(out[17].tx.sha256, 42), CScript([OP_TRUE]), 0xffffffff)) | ||||
tx.vout.append(CTxOut(0, b"")) | tx.vout.append(CTxOut(0, b"")) | ||||
pad_tx(tx) | pad_tx(tx) | ||||
tx.calc_sha256() | tx.calc_sha256() | ||||
b58 = self.update_block(58, [tx]) | b58 = self.update_block(58, [tx]) | ||||
self.sync_blocks([b58], success=False, | self.sync_blocks([b58], success=False, | ||||
reject_reason='bad-txns-inputs-missingorspent', reconnect=True) | reject_reason='bad-txns-inputs-missingorspent', reconnect=True) | ||||
▲ Show 20 Lines • Show All 41 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
# \-> b62 (18) | # \-> b62 (18) | ||||
# | # | ||||
self.log.info( | self.log.info( | ||||
"Reject a block with a transaction with a nonfinal locktime") | "Reject a block with a transaction with a nonfinal locktime") | ||||
self.move_tip(60) | self.move_tip(60) | ||||
b62 = self.next_block(62) | b62 = self.next_block(62) | ||||
tx = CTransaction() | tx = CTransaction() | ||||
tx.nLockTime = 0xffffffff # this locktime is non-final | tx.nLockTime = 0xffffffff # this locktime is non-final | ||||
assert(out[18].n < len(out[18].tx.vout)) | assert out[18].n < len(out[18].tx.vout) | ||||
# don't set nSequence | # don't set nSequence | ||||
tx.vin.append(CTxIn(COutPoint(out[18].tx.sha256, out[18].n))) | tx.vin.append(CTxIn(COutPoint(out[18].tx.sha256, out[18].n))) | ||||
tx.vout.append(CTxOut(0, CScript([OP_TRUE]))) | tx.vout.append(CTxOut(0, CScript([OP_TRUE]))) | ||||
assert(tx.vin[0].nSequence < 0xffffffff) | assert tx.vin[0].nSequence < 0xffffffff | ||||
tx.calc_sha256() | tx.calc_sha256() | ||||
b62 = self.update_block(62, [tx]) | b62 = self.update_block(62, [tx]) | ||||
self.sync_blocks([b62], success=False, | self.sync_blocks([b62], success=False, | ||||
reject_reason='bad-txns-nonfinal') | reject_reason='bad-txns-nonfinal') | ||||
# Test a non-final coinbase is also rejected | # Test a non-final coinbase is also rejected | ||||
# | # | ||||
# -> b39 (11) -> b42 (12) -> b43 (13) -> b53 (14) -> b55 (15) -> b57 (16) -> b60 (17) | # -> b39 (11) -> b42 (12) -> b43 (13) -> b53 (14) -> b55 (15) -> b57 (16) -> b60 (17) | ||||
▲ Show 20 Lines • Show All 325 Lines • ▼ Show 20 Lines | |||||
# now this chain is longer, triggers re-org | # now this chain is longer, triggers re-org | ||||
self.sync_blocks([b82], True) | self.sync_blocks([b82], True) | ||||
self.save_spendable_output() | self.save_spendable_output() | ||||
# now check that tx78 and tx79 have been put back into the peer's | # now check that tx78 and tx79 have been put back into the peer's | ||||
# mempool | # mempool | ||||
mempool = self.nodes[0].getrawmempool() | mempool = self.nodes[0].getrawmempool() | ||||
assert_equal(len(mempool), 2) | assert_equal(len(mempool), 2) | ||||
assert(tx78.hash in mempool) | assert tx78.hash in mempool | ||||
assert(tx79.hash in mempool) | assert tx79.hash in mempool | ||||
# Test invalid opcodes in dead execution paths. | # Test invalid opcodes in dead execution paths. | ||||
# | # | ||||
# -> b81 (26) -> b82 (27) -> b83 (28) | # -> b81 (26) -> b82 (27) -> b83 (28) | ||||
# | # | ||||
self.log.info( | self.log.info( | ||||
"Accept a block with invalid opcodes in dead execution paths") | "Accept a block with invalid opcodes in dead execution paths") | ||||
b83 = self.next_block(83) | b83 = self.next_block(83) | ||||
▲ Show 20 Lines • Show All 232 Lines • Show Last 20 Lines |