Skip to content

Commit dbc1981

Browse files
committed
test: check that _all_ invalid-CLTV txs are allowed in a block pre-BIP65
1 parent 8d0ce50 commit dbc1981

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

test/functional/feature_cltv.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -118,18 +118,22 @@ def run_test(self):
118118
self.coinbase_txids = [self.nodes[0].getblock(b)['tx'][0] for b in self.nodes[0].generate(CLTV_HEIGHT - 2)]
119119
self.nodeaddress = self.nodes[0].getnewaddress()
120120

121-
self.log.info("Test that an invalid-according-to-CLTV transaction can still appear in a block")
121+
self.log.info("Test that invalid-according-to-CLTV transactions can still appear in a block")
122122

123-
spendtx = create_transaction(self.nodes[0], self.coinbase_txids[0],
124-
self.nodeaddress, amount=1.0)
125-
spendtx = cltv_invalidate(self.nodes[0], spendtx, 1)
126-
spendtx.rehash()
123+
# create one invalid tx per CLTV failure reason (5 in total) and collect them
124+
invalid_ctlv_txs = []
125+
for i in range(5):
126+
spendtx = create_transaction(self.nodes[0], self.coinbase_txids[i],
127+
self.nodeaddress, amount=1.0)
128+
spendtx = cltv_invalidate(self.nodes[0], spendtx, i)
129+
spendtx.rehash()
130+
invalid_ctlv_txs.append(spendtx)
127131

128132
tip = self.nodes[0].getbestblockhash()
129133
block_time = self.nodes[0].getblockheader(tip)['mediantime'] + 1
130134
block = create_block(int(tip, 16), create_coinbase(CLTV_HEIGHT - 1), block_time)
131135
block.nVersion = 3
132-
block.vtx.append(spendtx)
136+
block.vtx.extend(invalid_ctlv_txs)
133137
block.hashMerkleRoot = block.calc_merkle_root()
134138
block.solve()
135139

@@ -153,7 +157,7 @@ def run_test(self):
153157
self.log.info("Test that invalid-according-to-cltv transactions cannot appear in a block")
154158
block.nVersion = 4
155159

156-
spendtx = create_transaction(self.nodes[0], self.coinbase_txids[1],
160+
spendtx = create_transaction(self.nodes[0], self.coinbase_txids[10],
157161
self.nodeaddress, amount=1.0)
158162
spendtx = cltv_invalidate(self.nodes[0], spendtx, 1)
159163
spendtx.rehash()

0 commit comments

Comments
 (0)