Skip to content

Commit a58cb3b

Browse files
committed
qa: sanity check mined block have their coinbase timelocked to height
1 parent 8f2078a commit a58cb3b

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

test/functional/mining_basic.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,10 @@
2828
COIN,
2929
DEFAULT_BLOCK_RESERVED_WEIGHT,
3030
MAX_BLOCK_WEIGHT,
31+
MAX_SEQUENCE_NONFINAL,
3132
MINIMUM_BLOCK_RESERVED_WEIGHT,
3233
ser_uint256,
33-
WITNESS_SCALE_FACTOR
34+
WITNESS_SCALE_FACTOR,
3435
)
3536
from test_framework.p2p import P2PDataStore
3637
from test_framework.test_framework import BitcoinTestFramework
@@ -362,6 +363,12 @@ def test_block_max_weight(self):
362363
expected_msg=f"Error: Specified -blockmaxweight ({MAX_BLOCK_WEIGHT + 1}) exceeds consensus maximum block weight ({MAX_BLOCK_WEIGHT})",
363364
)
364365

366+
def test_height_in_locktime(self):
367+
self.log.info("Sanity check generated blocks have their coinbase timelocked to their height.")
368+
self.generate(self.nodes[0], 1, sync_fun=self.no_op)
369+
block = self.nodes[0].getblock(self.nodes[0].getbestblockhash(), 2)
370+
assert_equal(block["tx"][0]["locktime"], block["height"] - 1)
371+
assert_equal(block["tx"][0]["vin"][0]["sequence"], MAX_SEQUENCE_NONFINAL)
365372

366373
def run_test(self):
367374
node = self.nodes[0]
@@ -592,6 +599,7 @@ def chain_tip(b_hash, *, status='headers-only', branchlen=1):
592599
self.test_block_max_weight()
593600
self.test_timewarp()
594601
self.test_pruning()
602+
self.test_height_in_locktime()
595603

596604

597605
if __name__ == '__main__':

0 commit comments

Comments
 (0)