diff --git a/itests/kit/ensemble.go b/itests/kit/ensemble.go index 29b8416cb..956d243a3 100644 --- a/itests/kit/ensemble.go +++ b/itests/kit/ensemble.go @@ -462,6 +462,17 @@ func (n *Ensemble) Start() *Ensemble { require.NoError(n.t, err) var rpcShutdownOnce sync.Once + var stopOnce sync.Once + var stopErr error + + stopFunc := stop + stop = func(ctx context.Context) error { + stopOnce.Do(func() { + stopErr = stopFunc(ctx) + }) + return stopErr + } + // Are we hitting this node through its RPC? if full.options.rpc { withRPC, rpcCloser := fullRpc(n.t, full) @@ -470,12 +481,11 @@ func (n *Ensemble) Start() *Ensemble { rpcShutdownOnce.Do(rpcCloser) return stop(ctx) } - //n.t.Cleanup(func() { rpcShutdownOnce.Do(rpcCloser) }) + n.t.Cleanup(func() { rpcShutdownOnce.Do(rpcCloser) }) } n.t.Cleanup(func() { _ = stop(context.Background()) - }) n.active.fullnodes = append(n.active.fullnodes, full) diff --git a/itests/kit/rpc.go b/itests/kit/rpc.go index 86d052e17..684742ad3 100644 --- a/itests/kit/rpc.go +++ b/itests/kit/rpc.go @@ -50,7 +50,6 @@ func fullRpc(t *testing.T, f *TestFullNode) (*TestFullNode, Closer) { cl, stop, err := client.NewFullNodeRPCV1(context.Background(), "ws://"+srv.Listener.Addr().String()+"/rpc/v1", nil) require.NoError(t, err) - t.Cleanup(stop) f.ListenAddr, f.ListenURL, f.FullNode = maddr, srv.URL, cl return f, func() { stop(); rpcCloser() }