mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
graphql: add testcase for errorCode
Signed-off-by: jsvisa <delweng@gmail.com>
This commit is contained in:
parent
31705c5d74
commit
eee6dfc9f1
1 changed files with 12 additions and 0 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Reference in a new issue