mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-10 05:57:59 +01:00
Merge bitcoin/bitcoin#29845: rpc: return warnings as an array instead of just a single one
42fb5311b1rpc: return warnings as an array instead of just a single one (stickies-v) Pull request description: The RPC documentation for `getblockchaininfo`, `getmininginfo` and `getnetworkinfo` states that "warnings" returns "any network and blockchain warnings". In practice, only a single warning (i.e. the latest one that is set) is returned, the other ones are ignored. Fix that by returning all warnings as an array. As a side benefit, clean up the GetWarnings() logic. Since this PR changes the RPC result schema, I've added release notes. Users can temporarily revert to the old results by using `-deprecatedrpc=warnings`, until it's removed in a future version. --- Some historical context from git log: - when `GetWarnings` was introduced in401926283a, it was used in the `getinfo` RPC, where only a [single error/warning was returned](401926283a (diff-7442c48d42cd5455a79915a0f00cce5e13359db46437a32b812876edb0a5ccddR250)) (similar to how it is now). - later on, "warnings" RPC response fields were introduced, e.g. inef2a3de25c, with the description [stating](ef2a3de25c (diff-1021bd3c74415ad9719bd764ad6ca35af5dfb33b1cd863c0be49bdf52518af54R411)) that it returned "any network warnings" but in practice still only a single warning was returned ACKs for top commit: achow101: re-ACK42fb5311b1tdb3: Re ACK for42fb5311b1TheCharlatan: ACK42fb5311b1maflcko: ACK42fb5311b1🔺 Tree-SHA512: 4225ed8979cd5f030dec785a80e7452a041ad5703445da79d2906ada983ed0bbe7b15889d663d75aae4a77d92e302c93e93eca185c7bd47c9cce29e12f752bd3
This commit is contained in:
@@ -73,8 +73,8 @@ class VersionBitsWarningTest(BitcoinTestFramework):
|
||||
self.generatetoaddress(node, VB_PERIOD - VB_THRESHOLD + 1, node_deterministic_address)
|
||||
|
||||
# Check that we're not getting any versionbit-related errors in get*info()
|
||||
assert not VB_PATTERN.match(node.getmininginfo()["warnings"])
|
||||
assert not VB_PATTERN.match(node.getnetworkinfo()["warnings"])
|
||||
assert not VB_PATTERN.match(",".join(node.getmininginfo()["warnings"]))
|
||||
assert not VB_PATTERN.match(",".join(node.getnetworkinfo()["warnings"]))
|
||||
|
||||
# Build one period of blocks with VB_THRESHOLD blocks signaling some unknown bit
|
||||
self.send_blocks_with_version(peer, VB_THRESHOLD, VB_UNKNOWN_VERSION)
|
||||
@@ -94,8 +94,8 @@ class VersionBitsWarningTest(BitcoinTestFramework):
|
||||
# Generating one more block will be enough to generate an error.
|
||||
self.generatetoaddress(node, 1, node_deterministic_address)
|
||||
# Check that get*info() shows the versionbits unknown rules warning
|
||||
assert WARN_UNKNOWN_RULES_ACTIVE in node.getmininginfo()["warnings"]
|
||||
assert WARN_UNKNOWN_RULES_ACTIVE in node.getnetworkinfo()["warnings"]
|
||||
assert WARN_UNKNOWN_RULES_ACTIVE in ",".join(node.getmininginfo()["warnings"])
|
||||
assert WARN_UNKNOWN_RULES_ACTIVE in ",".join(node.getnetworkinfo()["warnings"])
|
||||
# Check that the alert file shows the versionbits unknown rules warning
|
||||
self.wait_until(lambda: self.versionbits_in_alert_file())
|
||||
|
||||
|
||||
Reference in New Issue
Block a user