Skip to content

Commit

Permalink
grqphql: testcase
Browse files Browse the repository at this point in the history
Signed-off-by: jsvisa <[email protected]>
  • Loading branch information
jsvisa committed Sep 19, 2023
1 parent a115bbb commit 9810187
Showing 1 changed file with 21 additions and 8 deletions.
29 changes: 21 additions & 8 deletions simulators/ethereum/graphql/graphql_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,28 @@ type gasPrice struct {
func Test_responseMatch(t *testing.T) {
// create hivesim tester
hivesimT := &hivesim.T{}
// unmarshal JSON test file
fp := "./testcases/07_eth_gasPrice.json"
data, err := os.ReadFile(fp)
if err != nil {
t.Fatalf("Warning: can't read test file %s: %v", fp, err)
}
data := `
{
"request":
"{ gasPrice }",
"responses": [
{
"data" : {
"gasPrice" : "0x10"
}
},
{
"data" : {
"gasPrice" : "0x1"
}
}
],
"statusCode": 200
}
`
var gqlTest graphQLTest
if err = json.Unmarshal(data, &gqlTest); err != nil {
t.Fatalf("Warning: can't unmarshal test file %s: %v", fp, err)
if err := json.Unmarshal([]byte(data), &gqlTest); err != nil {
t.Fatalf("Warning: can't unmarshal test %v", err)
}
// build test case
tc := testCase{
Expand Down

0 comments on commit 9810187

Please sign in to comment.