mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-06-14 08:39:35 +02:00
Merge bitcoin/bitcoin#35006: cli, rpc: add -rpcid option for custom request IDs
c54f37c1bacli, rpc: add -rpcid option for custom request IDs (Torkel Rogstad) Pull request description: Add a `-rpcid` CLI argument to `bitcoin-cli` that allows setting a custom string as the JSON-RPC request ID instead of the hardcoded default of 1. This enables correlating requests and responses when debugging or when multiple clients are making concurrent calls. On the server side, include the request ID in the RPC debug log line. Tests are added in `test/functional/interface_bitcoin_cli.py` for this. ACKs for top commit: maflcko: lgtm ACKc54f37c1bastickies-v: ACKc54f37c1basedited: ACKc54f37c1baTree-SHA512: b693a50a2be5dc7797e5b61bddc4c10237888b52065d1b68029d7211542e0dd44f2b3dfb9b3bd7c5e4d9026766817de66a7ef4f29a8d97a268554ba775063e10
This commit is contained in:
@@ -421,6 +421,18 @@ class TestBitcoinCli(BitcoinTestFramework):
|
||||
|
||||
self.test_netinfo()
|
||||
|
||||
self.log.info("Test -rpcid option sets custom JSON-RPC request ID")
|
||||
with self.nodes[0].assert_debug_log(expected_msgs=['id=myrpcid']):
|
||||
self.nodes[0].cli('-rpcid=myrpcid').getblockcount()
|
||||
|
||||
self.log.info("Test default request logs default id=1")
|
||||
with self.nodes[0].assert_debug_log(expected_msgs=["ThreadRPCServer method=getblockcount", "id=1"]):
|
||||
self.nodes[0].cli.getblockcount()
|
||||
|
||||
self.log.info("Test that request ids with unsafe characters are sanitized in the log")
|
||||
with self.nodes[0].assert_debug_log(expected_msgs=["ThreadRPCServer method=getblockcount", "id=abcdef"]):
|
||||
self.nodes[0].cli('-rpcid=abc<\n>def').getblockcount()
|
||||
|
||||
self.log.info("Test -version with node stopped")
|
||||
self.stop_node(0)
|
||||
cli_response = self.nodes[0].cli('-version').send_cli()
|
||||
|
||||
Reference in New Issue
Block a user