Skip to content

Commit 9810187

Browse files
committed
grqphql: testcase
Signed-off-by: jsvisa <delweng@gmail.com>
1 parent a115bbb commit 9810187

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

simulators/ethereum/graphql/graphql_test.go

+21-8
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,28 @@ type gasPrice struct {
2222
func Test_responseMatch(t *testing.T) {
2323
// create hivesim tester
2424
hivesimT := &hivesim.T{}
25-
// unmarshal JSON test file
26-
fp := "./testcases/07_eth_gasPrice.json"
27-
data, err := os.ReadFile(fp)
28-
if err != nil {
29-
t.Fatalf("Warning: can't read test file %s: %v", fp, err)
30-
}
25+
data := `
26+
{
27+
"request":
28+
"{ gasPrice }",
29+
"responses": [
30+
{
31+
"data" : {
32+
"gasPrice" : "0x10"
33+
}
34+
},
35+
{
36+
"data" : {
37+
"gasPrice" : "0x1"
38+
}
39+
}
40+
],
41+
"statusCode": 200
42+
}
43+
`
3144
var gqlTest graphQLTest
32-
if err = json.Unmarshal(data, &gqlTest); err != nil {
33-
t.Fatalf("Warning: can't unmarshal test file %s: %v", fp, err)
45+
if err := json.Unmarshal([]byte(data), &gqlTest); err != nil {
46+
t.Fatalf("Warning: can't unmarshal test %v", err)
3447
}
3548
// build test case
3649
tc := testCase{

0 commit comments

Comments
 (0)