What changed, and why it matters
This commit only adds a new integration test that sends a null value for the optional verbosity parameter of the getblock RPC and checks that the server returns a normal verbose block response. It does not change any production code. The test is described as covering a previously fixed server panic, but the fix itself is not present in this commit.
No action required; this is a benign test-only commit. If reviewing the related fix, examine PR #2600 separately.
Security signals we found
Regression test for a prior RPC server panic (#2600)
No production code changes; defensive test coverage only
Evidence from the diff
The diff adds testGetBlockNullVerbosity to integration/rpcserver_test.go and registers it in the RPC test case list. The test uses RawRequest to send getblock with a block hash and json.RawMessage(“null”) as the verbosity argument, then unmarshals the response into btcjson.GetBlockVerboseResult and asserts the returned hash and transaction list. No server-side logic is modified. The commit message references #2600 as the prior fix for the panic this test exercises.
Changed components
integration/rpcserver_test.goInspect captured patch +36 / −0
### integration/rpcserver_test.go
@@ -10,13 +10,15 @@ package integration
import (
"bytes"
+ "encoding/json"
"fmt"
"os"
"runtime/debug"
"testing"
"time"
"github.com/btcsuite/btcd/blockchain"
+ "github.com/btcsuite/btcd/btcjson"
"github.com/btcsuite/btcd/chaincfg/v2"
"github.com/btcsuite/btcd/chainhash/v2"
"github.com/btcsuite/btcd/integration/rpctest"
@@ -99,6 +101,39 @@ func testGetBlockHash(r *rpctest.Harness, t *testing.T) {
}
}
+func testGetBlockNullVerbosity(r *rpctest.Harness, t *testing.T) {
+ hash, err := r.Client.GetBestBlockHash()
+ if err != nil {
+ t.Fatalf("Unable to get best block hash: %v", err)
+ }
+
+ hashJSON, err := json.Marshal(hash.String())
+ if err != nil {
+ t.Fatalf("Unable to marshal block hash: %v", err)
+ }
+
+ resultJSON, err := r.Client.RawRequest(
+ "getblock", []json.RawMessage{
+ hashJSON, json.RawMessage("null"),
+ },
+ )
+ if err != nil {
+ t.Fatalf("Unable to get block with null verbosity: %v", err)
+ }
+
+ var result btcjson.GetBlockVerboseResult
+ if err := json.Unmarshal(resultJSON, &result); err != nil {
+ t.Fatalf("Unable to unmarshal verbose block result: %v", err)
+ }
+ if result.Hash != hash.String() {
+ t.Fatalf("Block hashes do not match. Got %v, wanted %v",
+ result.Hash, hash)
+ }
+ if len(result.Tx) == 0 {
+ t.Fatal("Verbose block result contains no transactions")
+ }
+}
+
func testBulkClient(r *rpctest.Harness, t *testing.T) {
// Create a new block connecting to the current tip.
generatedBlockHashes, err := r.Client.Generate(20)
@@ -293,6 +328,7 @@ var rpcTestCases = []rpctest.HarnessTestCase{
testGetBestBlock,
testGetBlockCount,
testGetBlockHash,
+ testGetBlockNullVerbosity,
testBulkClient,
testGetNetworkHashPS,
testGetNetworkHashPS2,Why this scored 12/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.