From fd826130a0a4e67fdc26f8064f4ecb4ff79b3333 Mon Sep 17 00:00:00 2001 From: Anthony Towns Date: Wed, 1 Dec 2021 17:46:21 +1000 Subject: rpc: move softfork info from getblockchaininfo to getdeploymentinfo --- test/functional/rpc_blockchain.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'test/functional/rpc_blockchain.py') diff --git a/test/functional/rpc_blockchain.py b/test/functional/rpc_blockchain.py index 8f7d5114fa..9b9f989b04 100755 --- a/test/functional/rpc_blockchain.py +++ b/test/functional/rpc_blockchain.py @@ -6,6 +6,7 @@ Test the following RPCs: - getblockchaininfo + - getdeploymentinfo - getchaintxstats - gettxoutsetinfo - getblockheader @@ -71,6 +72,7 @@ class BlockchainTest(BitcoinTestFramework): self.restart_node(0, extra_args=['-stopatheight=207', '-prune=1']) # Set extra args with pruning after rescan is complete self._test_getblockchaininfo() + self._test_getdeploymentinfo() self._test_getchaintxstats() self._test_gettxoutsetinfo() self._test_getblockheader() @@ -115,7 +117,6 @@ class BlockchainTest(BitcoinTestFramework): 'mediantime', 'pruned', 'size_on_disk', - 'softforks', 'time', 'verificationprogress', 'warnings', @@ -177,7 +178,12 @@ class BlockchainTest(BitcoinTestFramework): assert_equal(res['prune_target_size'], 576716800) assert_greater_than(res['size_on_disk'], 0) - assert_equal(res['softforks'], { + def _test_getdeploymentinfo(self): + self.log.info("Test getdeploymentinfo") + + res = self.nodes[0].getdeploymentinfo() + assert_equal(res, { + "deployments": { 'bip34': {'type': 'buried', 'active': True, 'height': 2}, 'bip66': {'type': 'buried', 'active': True, 'height': 3}, 'bip65': {'type': 'buried', 'active': True, 'height': 4}, @@ -214,6 +220,7 @@ class BlockchainTest(BitcoinTestFramework): 'height': 0, 'active': True } + } }) def _test_getchaintxstats(self): -- cgit v1.2.3 From a7469bcd35692d56f57e91b3f21d30855bdf6531 Mon Sep 17 00:00:00 2001 From: Anthony Towns Date: Sun, 14 Nov 2021 07:55:34 +1000 Subject: rpc: getdeploymentinfo: change stats to always refer to current period On a period boundary, getdeploymentinfo (and previously getblockchaininfo) would report the status and statistics for the next block rather than the current block. Change this to always report the status/statistics of the current block, but add status-next to report the status for the next block. --- test/functional/rpc_blockchain.py | 53 +++++++++++++++++++++++++++------------ 1 file changed, 37 insertions(+), 16 deletions(-) (limited to 'test/functional/rpc_blockchain.py') diff --git a/test/functional/rpc_blockchain.py b/test/functional/rpc_blockchain.py index 9b9f989b04..2498543bbe 100755 --- a/test/functional/rpc_blockchain.py +++ b/test/functional/rpc_blockchain.py @@ -72,7 +72,6 @@ class BlockchainTest(BitcoinTestFramework): self.restart_node(0, extra_args=['-stopatheight=207', '-prune=1']) # Set extra args with pruning after rescan is complete self._test_getblockchaininfo() - self._test_getdeploymentinfo() self._test_getchaintxstats() self._test_gettxoutsetinfo() self._test_getblockheader() @@ -81,6 +80,7 @@ class BlockchainTest(BitcoinTestFramework): self._test_stopatheight() self._test_waitforblockheight() self._test_getblock() + self._test_getdeploymentinfo() assert self.nodes[0].verifychain(4, 0) def mine_chain(self): @@ -160,11 +160,6 @@ class BlockchainTest(BitcoinTestFramework): self.start_node(0, extra_args=[ '-stopatheight=207', '-prune=550', - '-testactivationheight=bip34@2', - '-testactivationheight=dersig@3', - '-testactivationheight=cltv@4', - '-testactivationheight=csv@5', - '-testactivationheight=segwit@6', ]) res = self.nodes[0].getblockchaininfo() @@ -178,11 +173,10 @@ class BlockchainTest(BitcoinTestFramework): assert_equal(res['prune_target_size'], 576716800) assert_greater_than(res['size_on_disk'], 0) - def _test_getdeploymentinfo(self): - self.log.info("Test getdeploymentinfo") + def check_signalling_deploymentinfo_result(self, gdi_result, height, blockhash, status_next): + assert height >= 144 and height <= 287 - res = self.nodes[0].getdeploymentinfo() - assert_equal(res, { + assert_equal(gdi_result, { "deployments": { 'bip34': {'type': 'buried', 'active': True, 'height': 2}, 'bip66': {'type': 'buried', 'active': True, 'height': 3}, @@ -192,30 +186,32 @@ class BlockchainTest(BitcoinTestFramework): 'testdummy': { 'type': 'bip9', 'bip9': { - 'status': 'started', 'bit': 28, 'start_time': 0, 'timeout': 0x7fffffffffffffff, # testdummy does not have a timeout so is set to the max int64 value + 'min_activation_height': 0, + 'status': 'started', + 'status-next': status_next, 'since': 144, 'statistics': { 'period': 144, 'threshold': 108, - 'elapsed': HEIGHT - 143, - 'count': HEIGHT - 143, + 'elapsed': height - 143, + 'count': height - 143, 'possible': True, }, - 'min_activation_height': 0, }, 'active': False }, 'taproot': { 'type': 'bip9', 'bip9': { - 'status': 'active', 'start_time': -1, 'timeout': 9223372036854775807, - 'since': 0, 'min_activation_height': 0, + 'status': 'active', + 'status-next': 'active', + 'since': 0, }, 'height': 0, 'active': True @@ -223,6 +219,31 @@ class BlockchainTest(BitcoinTestFramework): } }) + def _test_getdeploymentinfo(self): + # Note: continues past -stopatheight height, so must be invoked + # after _test_stopatheight + + self.log.info("Test getdeploymentinfo") + self.stop_node(0) + self.start_node(0, extra_args=[ + '-testactivationheight=bip34@2', + '-testactivationheight=dersig@3', + '-testactivationheight=cltv@4', + '-testactivationheight=csv@5', + '-testactivationheight=segwit@6', + ]) + + gbci207 = self.nodes[0].getblockchaininfo() + self.check_signalling_deploymentinfo_result(self.nodes[0].getdeploymentinfo(), gbci207["blocks"], gbci207["bestblockhash"], "started") + + # block just prior to lock in + self.generate(self.wallet, 287 - gbci207["blocks"]) + gbci287 = self.nodes[0].getblockchaininfo() + self.check_signalling_deploymentinfo_result(self.nodes[0].getdeploymentinfo(), gbci287["blocks"], gbci287["bestblockhash"], "locked_in") + + # calling with an explicit hash works + self.check_signalling_deploymentinfo_result(self.nodes[0].getdeploymentinfo(gbci207["bestblockhash"]), gbci207["blocks"], gbci207["bestblockhash"], "started") + def _test_getchaintxstats(self): self.log.info("Test getchaintxstats") -- cgit v1.2.3 From 376c0c6dae2bebbb3e1352377e71fb1996d09f64 Mon Sep 17 00:00:00 2001 From: Anthony Towns Date: Sun, 14 Nov 2021 08:44:40 +1000 Subject: rpc: getdeploymentinfo: include block hash/height --- test/functional/rpc_blockchain.py | 2 ++ 1 file changed, 2 insertions(+) (limited to 'test/functional/rpc_blockchain.py') diff --git a/test/functional/rpc_blockchain.py b/test/functional/rpc_blockchain.py index 2498543bbe..0e560abc49 100755 --- a/test/functional/rpc_blockchain.py +++ b/test/functional/rpc_blockchain.py @@ -177,6 +177,8 @@ class BlockchainTest(BitcoinTestFramework): assert height >= 144 and height <= 287 assert_equal(gdi_result, { + "hash": blockhash, + "height": height, "deployments": { 'bip34': {'type': 'buried', 'active': True, 'height': 2}, 'bip66': {'type': 'buried', 'active': True, 'height': 3}, -- cgit v1.2.3 From 240cad09baefcf363cce36a4b2795122adfce27f Mon Sep 17 00:00:00 2001 From: Anthony Towns Date: Fri, 12 Nov 2021 07:14:21 +1000 Subject: rpc: getdeploymentinfo: include signalling info --- test/functional/rpc_blockchain.py | 1 + 1 file changed, 1 insertion(+) (limited to 'test/functional/rpc_blockchain.py') diff --git a/test/functional/rpc_blockchain.py b/test/functional/rpc_blockchain.py index 0e560abc49..12814c42bc 100755 --- a/test/functional/rpc_blockchain.py +++ b/test/functional/rpc_blockchain.py @@ -202,6 +202,7 @@ class BlockchainTest(BitcoinTestFramework): 'count': height - 143, 'possible': True, }, + 'signalling': '#'*(height-143), }, 'active': False }, -- cgit v1.2.3