@@ -9,16 +9,16 @@ import (
9
9
"fmt"
10
10
"net"
11
11
"net/http"
12
- "sync"
13
12
"time"
14
13
15
14
"connectrpc.com/connect"
16
15
"github.com/onsi/ginkgo/v2"
17
16
"github.com/stretchr/testify/require"
18
17
"go.uber.org/zap"
19
18
"golang.org/x/net/http2"
19
+ "golang.org/x/sync/errgroup"
20
20
21
- "github.com/ava-labs/avalanchego/api/server "
21
+ "github.com/ava-labs/avalanchego/api/connectclient "
22
22
"github.com/ava-labs/avalanchego/connectproto/pb/xsvm"
23
23
"github.com/ava-labs/avalanchego/connectproto/pb/xsvm/xsvmconnect"
24
24
"github.com/ava-labs/avalanchego/ids"
@@ -211,28 +211,30 @@ var _ = ginkgo.Describe("[XSVM]", ginkgo.Label("xsvm"), func() {
211
211
},
212
212
}
213
213
214
- client := xsvmconnect .NewPingClient (httpClient , node .URI )
214
+ chainID := network .GetSubnet (subnetAName ).Chains [0 ].ChainID .String ()
215
+ client := xsvmconnect .NewPingClient (
216
+ httpClient ,
217
+ node .URI ,
218
+ connect .WithInterceptors (
219
+ connectclient.SetRouteHeaderInterceptor {Route : chainID },
220
+ ),
221
+ )
215
222
216
223
tc .By ("serving unary rpc" )
217
224
msg := "foobar"
218
-
219
225
request := & connect.Request [xsvm.PingRequest ]{
220
226
Msg : & xsvm.PingRequest {
221
227
Message : msg ,
222
228
},
223
229
}
224
230
225
- chainID := network .GetSubnet (subnetAName ).Chains [0 ].ChainID
226
- request .Header ().Set (server .HTTPHeaderRoute , chainID .String ())
227
-
228
231
reply , err := client .Ping (tc .DefaultContext (), request )
229
232
require .NoError (err )
230
233
require .Equal (msg , reply .Msg .Message )
231
234
232
235
tc .By ("serving bidirectional streaming rpc" )
233
236
234
237
stream := client .StreamPing (tc .DefaultContext ())
235
- stream .RequestHeader ().Set (server .HTTPHeaderRoute , chainID .String ())
236
238
ginkgo .DeferCleanup (func () {
237
239
require .NoError (stream .CloseRequest ())
238
240
})
@@ -260,8 +262,14 @@ var _ = ginkgo.Describe("[XSVM]", ginkgo.Label("xsvm"), func() {
260
262
eg .Go (func () error {
261
263
for i := 0 ; i < n ; i ++ {
262
264
reply , err := stream .Receive ()
263
- require .NoError (err )
264
- require .Equal (fmt .Sprintf ("ping-%d" , i ), reply .Message )
265
+ if err != nil {
266
+ return err
267
+ }
268
+
269
+ if fmt .Sprintf ("ping-%d" , i ) != reply .Message {
270
+ return fmt .Errorf ("unexpected ping reply: %s" , reply .Message )
271
+ }
272
+
265
273
log .Info ("received message" , zap .String ("msg" , reply .Message ))
266
274
}
267
275
0 commit comments