diff --git a/graphql/graphql_test.go b/graphql/graphql_test.go index 540a56778c..f760106d35 100644 --- a/graphql/graphql_test.go +++ b/graphql/graphql_test.go @@ -153,6 +153,18 @@ func TestGraphQLBlockSerialization(t *testing.T) { want: `{"errors":[{"message":"from block number must be specified","path":["blocks"]}],"data":null}`, code: 400, }, + // invalid block range + { + body: `{"query": "{blocks(from: 5 to: 1 ){number}}"}`, + want: `{"errors":[{"message":"error [-32602]: invalid from and to block combination: from \u003e to","path":["blocks"],"extensions":{"errorCode":-32602,"errorMessage":"invalid from and to block combination: from \u003e to"}}],"data":null}`, + code: 400, + }, + // both hash and number + { + body: `{"query": "{block(number: 1 hash: \"0xd864c9d7d37fade6b70164740540c06dd58bb9c3f6b46101908d6339db6a6a7b\"){number}}"}`, + want: `{"errors":[{"message":"error [-32602]: only one of number or hash must be specified","path":["block"],"extensions":{"errorCode":-32602,"errorMessage":"only one of number or hash must be specified"}}],"data":{"block":null}}`, + code: 400, + }, } { resp, err := http.Post(fmt.Sprintf("%s/graphql", stack.HTTPEndpoint()), "application/json", strings.NewReader(tt.body)) if err != nil {