@@ -8,10 +8,8 @@ import (
88 "net/http"
99 "os"
1010 "path"
11- "path/filepath"
1211 "reflect"
1312 "strconv"
14- "strings"
1513 "sync"
1614
1715 "github.com/ethereum/hive/hivesim"
@@ -50,8 +48,8 @@ the client launched by this test.`,
5048 "HIVE_SHANGHAI_TIMESTAMP" : "1444660030" ,
5149 },
5250 Files : map [string ]string {
53- "/genesis.json" : "./init/testGenesis .json" ,
54- "/chain.rlp" : "./init/testBlockchain.blocks " ,
51+ "/genesis.json" : "./tests/genesis .json" ,
52+ "/chain.rlp" : "./tests/chain.rlp " ,
5553 },
5654 Run : graphqlTest ,
5755 })
@@ -75,7 +73,7 @@ func graphqlTest(t *hivesim.T, c *hivesim.Client) {
7573 go func () {
7674 defer wg .Done ()
7775 for test := range testCh {
78- url := "https://github.com/ethereum/hive /blob/master/simulators/ethereum/ graphql/testcases "
76+ url := "https://github.com/ethereum/execution-apis /blob/master/graphql/tests "
7977 t .Run (hivesim.TestSpec {
8078 Name : fmt .Sprintf ("%s (%s)" , test .name , c .Type ),
8179 Description : fmt .Sprintf ("Test case source: %s/%v.json" , url , test .name ),
@@ -90,38 +88,55 @@ func graphqlTest(t *hivesim.T, c *hivesim.Client) {
9088// deliverTests reads the test case files, sending them to the output channel.
9189func deliverTests (t * hivesim.T , wg * sync.WaitGroup , limit int ) <- chan * testCase {
9290 out := make (chan * testCase )
91+ root := "tests"
92+ files , err := os .ReadDir (root )
93+ if err != nil {
94+ t .Fatalf ("Warning: can't read test directory %s: %v" , root , err )
95+ }
96+
9397 var i = 0
9498 wg .Add (1 )
9599 go func () {
96100 defer wg .Done ()
97- filepath .Walk ("./testcases" , func (filepath string , info os.FileInfo , err error ) error {
101+
102+ for _ , file := range files {
98103 if limit >= 0 && i >= limit {
99- return nil
104+ return
100105 }
101- if info .IsDir () {
102- return nil
106+ if ! file .IsDir () {
107+ continue
103108 }
104- if fname := info .Name (); ! strings .HasSuffix (fname , ".json" ) {
105- return nil
109+ var (
110+ requestFile = path .Join (root , file .Name (), "request.gql" )
111+ responseFile = path .Join (root , file .Name (), "response.json" )
112+ )
113+
114+ request , err := os .ReadFile (requestFile )
115+ if err != nil {
116+ t .Logf ("Warning: can't read test file %s: %v" , requestFile , err )
117+ continue
106118 }
107- data , err := os .ReadFile (filepath )
119+
120+ response , err := os .ReadFile (responseFile )
108121 if err != nil {
109- t .Logf ("Warning: can't read test file %s: %v" , filepath , err )
110- return nil
122+ t .Logf ("Warning: can't read test file %s: %v" , responseFile , err )
123+ continue
111124 }
125+
112126 var gqlTest graphQLTest
113- if err = json .Unmarshal (data , & gqlTest ); err != nil {
114- t .Logf ("Warning: can't unmarshal test file %s: %v" , filepath , err )
115- return nil
127+ if err = json .Unmarshal (response , & gqlTest ); err != nil {
128+ t .Logf ("Warning: can't unmarshal test file %s: %v" , responseFile , err )
129+ continue
116130 }
131+ gqlTest .Request = string (request )
117132 i = i + 1
118133 t := testCase {
119- name : strings . TrimSuffix ( info . Name (), path . Ext ( info . Name ()) ),
134+ name : file . Name (),
120135 gqlTest : & gqlTest ,
121136 }
122137 out <- & t
123- return nil
124- })
138+ }
139+
125140 close (out )
126141 }()
127142 return out
0 commit comments