Skip to content

Commit 1381ddb

Browse files
author
MarcoFalke
committed
Merge bitcoin#16329: test: Add tests for getblockchaininfo.softforks
faf6caf test: Add tests for getblockchaininfo.softforks (MarcoFalke) Pull request description: ACKs for top commit: laanwj: Code review ACK faf6caf Tree-SHA512: 8a0bb3b648f18fdba7a36a960d70c6217fd7312cf2ef52b3b911be0d7f1d27c5c50856946d7e6cb81d96c081913b7308cc5f9d89af34518439ff4ada024441da
2 parents 91c345e + faf6caf commit 1381ddb

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

test/functional/feature_cltv.py

+18
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,23 @@ def set_test_params(self):
6464
def skip_test_if_missing_module(self):
6565
self.skip_if_no_wallet()
6666

67+
def test_cltv_info(self, *, is_active):
68+
assert_equal(
69+
next(s for s in self.nodes[0].getblockchaininfo()['softforks'] if s['id'] == 'bip65'),
70+
{
71+
"id": "bip65",
72+
"version": 4,
73+
"reject": {
74+
"status": is_active
75+
}
76+
},
77+
)
78+
6779
def run_test(self):
6880
self.nodes[0].add_p2p_connection(P2PInterface())
6981

82+
self.test_cltv_info(is_active=False)
83+
7084
self.log.info("Mining %d blocks", CLTV_HEIGHT - 2)
7185
self.coinbase_txids = [self.nodes[0].getblock(b)['tx'][0] for b in self.nodes[0].generate(CLTV_HEIGHT - 2)]
7286
self.nodeaddress = self.nodes[0].getnewaddress()
@@ -86,7 +100,9 @@ def run_test(self):
86100
block.hashMerkleRoot = block.calc_merkle_root()
87101
block.solve()
88102

103+
self.test_cltv_info(is_active=False)
89104
self.nodes[0].p2p.send_and_ping(msg_block(block))
105+
self.test_cltv_info(is_active=False) # Not active as of current tip, but next block must obey rules
90106
assert_equal(self.nodes[0].getbestblockhash(), block.hash)
91107

92108
self.log.info("Test that blocks must now be at least version 4")
@@ -135,7 +151,9 @@ def run_test(self):
135151
block.hashMerkleRoot = block.calc_merkle_root()
136152
block.solve()
137153

154+
self.test_cltv_info(is_active=False) # Not active as of current tip, but next block must obey rules
138155
self.nodes[0].p2p.send_and_ping(msg_block(block))
156+
self.test_cltv_info(is_active=True) # Active as of current tip
139157
assert_equal(int(self.nodes[0].getbestblockhash(), 16), block.sha256)
140158

141159

test/functional/feature_dersig.py

+19
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,23 @@ def set_test_params(self):
5151
def skip_test_if_missing_module(self):
5252
self.skip_if_no_wallet()
5353

54+
def test_dersig_info(self, *, is_active):
55+
assert_equal(
56+
next(s for s in self.nodes[0].getblockchaininfo()['softforks'] if s['id'] == 'bip66'),
57+
{
58+
"id": "bip66",
59+
"version": 3,
60+
"reject": {
61+
"status": is_active
62+
}
63+
},
64+
)
65+
5466
def run_test(self):
5567
self.nodes[0].add_p2p_connection(P2PInterface())
5668

69+
self.test_dersig_info(is_active=False)
70+
5771
self.log.info("Mining %d blocks", DERSIG_HEIGHT - 2)
5872
self.coinbase_txids = [self.nodes[0].getblock(b)['tx'][0] for b in self.nodes[0].generate(DERSIG_HEIGHT - 2)]
5973
self.nodeaddress = self.nodes[0].getnewaddress()
@@ -74,7 +88,9 @@ def run_test(self):
7488
block.rehash()
7589
block.solve()
7690

91+
self.test_dersig_info(is_active=False)
7792
self.nodes[0].p2p.send_and_ping(msg_block(block))
93+
self.test_dersig_info(is_active=False) # Not active as of current tip, but next block must obey rules
7894
assert_equal(self.nodes[0].getbestblockhash(), block.hash)
7995

8096
self.log.info("Test that blocks must now be at least version 3")
@@ -128,8 +144,11 @@ def run_test(self):
128144
block.rehash()
129145
block.solve()
130146

147+
self.test_dersig_info(is_active=False) # Not active as of current tip, but next block must obey rules
131148
self.nodes[0].p2p.send_and_ping(msg_block(block))
149+
self.test_dersig_info(is_active=True) # Active as of current tip
132150
assert_equal(int(self.nodes[0].getbestblockhash(), 16), block.sha256)
133151

152+
134153
if __name__ == '__main__':
135154
BIP66Test().main()

0 commit comments

Comments
 (0)