@ -1383,37 +1383,43 @@ func TestGetBlockBodiesByRangeInvalidParams(t *testing.T) {
node , eth , _ := setupBodies ( t )
node , eth , _ := setupBodies ( t )
api := NewConsensusAPI ( eth )
api := NewConsensusAPI ( eth )
defer node . Close ( )
defer node . Close ( )
tests := [ ] struct {
tests := [ ] struct {
start hexutil . Uint64
start hexutil . Uint64
count hexutil . Uint64
count hexutil . Uint64
want * engine . EngineAPIError
} {
} {
// Genesis
// Genesis
{
{
start : 0 ,
start : 0 ,
count : 1 ,
count : 1 ,
want : engine . InvalidParams ,
} ,
} ,
// No block requested
// No block requested
{
{
start : 1 ,
start : 1 ,
count : 0 ,
count : 0 ,
want : engine . InvalidParams ,
} ,
} ,
// Genesis & no block
// Genesis & no block
{
{
start : 0 ,
start : 0 ,
count : 0 ,
count : 0 ,
want : engine . InvalidParams ,
} ,
} ,
// More than 1024 blocks
// More than 1024 blocks
{
{
start : 1 ,
start : 1 ,
count : 1025 ,
count : 1025 ,
want : engine . TooLargeRequest ,
} ,
} ,
}
}
for i , tc := range tests {
for _ , test := range tests {
result , err := api . GetPayloadBodiesByRangeV1 ( tc . start , tc . count )
result , err := api . GetPayloadBodiesByRangeV1 ( test . start , test . count )
if err == nil {
if err == nil {
t . Fatalf ( "expected error, got %v" , result )
t . Fatalf ( "test %d: expected error, got %v" , i , result )
}
if have , want := err . Error ( ) , tc . want . Error ( ) ; have != want {
t . Fatalf ( "test %d: have %s, want %s" , i , have , want )
}
}
}
}
}
}