mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-06-30 02:31:05 +02:00
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.
This commit is contained in:
@ -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")
|
||||
|
||||
|
Reference in New Issue
Block a user