@@ -88,9 +88,10 @@ func TestDebug(t *testing.T) {
8888
8989 // /storage/range endpoint
9090 for name , tt := range map [string ]func (* testing.T ){
91- "testStorageRangeWithError" : testStorageRangeWithError ,
92- "testStorageRange" : testStorageRange ,
93- "testStorageRangeDefaultOption" : testStorageRangeDefaultOption ,
91+ "testStorageRangeWithError" : testStorageRangeWithError ,
92+ "testStorageRangeWithNonExistingBlockID" : testStorageRangeWithNonExistingBlockID ,
93+ "testStorageRange" : testStorageRange ,
94+ "testStorageRangeDefaultOption" : testStorageRangeDefaultOption ,
9495 } {
9596 t .Run (name , tt )
9697 }
@@ -181,7 +182,7 @@ func testTraceClauseWithNonExistingBlockID(t *testing.T) {
181182 Name : "structLogger" ,
182183 Target : fmt .Sprintf ("%s/x/x" , datagen .RandomHash ()),
183184 }
184- httpPostAndCheckResponseStatus (t , "/debug/tracers" , traceClauseOption , 500 )
185+ httpPostAndCheckResponseStatus (t , "/debug/tracers" , traceClauseOption , 400 )
185186}
186187
187188func testTraceClauseWithBadTxID (t * testing.T ) {
@@ -465,7 +466,7 @@ func testHandleTraceCallWithBadBlockRef(t *testing.T) {
465466 BlockRef : "jh000000000000000" ,
466467 }
467468
468- res := httpPostAndCheckResponseStatus (t , "/debug/tracers/call" , traceCallOption , 500 )
469+ res := httpPostAndCheckResponseStatus (t , "/debug/tracers/call" , traceCallOption , 400 )
469470
470471 assert .Equal (t , "blockRef: hex string without 0x prefix" , strings .TrimSpace (res ))
471472}
@@ -485,7 +486,7 @@ func testHandleTraceCallWithInvalidLengthBlockRef(t *testing.T) {
485486 BlockRef : "0x00" ,
486487 }
487488
488- res := httpPostAndCheckResponseStatus (t , "/debug/tracers/call" , traceCallOption , 500 )
489+ res := httpPostAndCheckResponseStatus (t , "/debug/tracers/call" , traceCallOption , 400 )
489490
490491 assert .Equal (t , "blockRef: invalid length" , strings .TrimSpace (res ))
491492}
@@ -503,6 +504,15 @@ func testStorageRangeWithError(t *testing.T) {
503504 httpPostAndCheckResponseStatus (t , "/debug/storage-range" , badMaxResult , 400 )
504505}
505506
507+ func testStorageRangeWithNonExistingBlockID (t * testing.T ) {
508+ opt := & api.StorageRangeOption {
509+ Address : datagen .RandAddress (),
510+ Target : fmt .Sprintf ("%s/0/0" , datagen .RandomHash ()),
511+ }
512+ res := httpPostAndCheckResponseStatus (t , "/debug/storage-range" , opt , 400 )
513+ assert .Contains (t , res , "target[0]" )
514+ }
515+
506516func testStorageRange (t * testing.T ) {
507517 opt := api.StorageRangeOption {
508518 Address : datagen .RandAddress (),
0 commit comments