@@ -14,6 +14,7 @@ import (
1414 "golang.org/x/sync/errgroup"
1515
1616 "github.com/ava-labs/avalanchego/tests"
17+ "github.com/ava-labs/avalanchego/utils/logging"
1718)
1819
1920type Test interface {
@@ -61,8 +62,8 @@ func NewLoadGenerator(
6162}
6263
6364func (l LoadGenerator ) Run (
64- tc tests.TestContext ,
6565 ctx context.Context ,
66+ log logging.Logger ,
6667 loadTimeout time.Duration ,
6768 testTimeout time.Duration ,
6869) {
@@ -87,10 +88,18 @@ func (l LoadGenerator) Run(
8788 ctx , cancel := context .WithTimeout (ctx , testTimeout )
8889 defer cancel ()
8990
90- l . test . Run ( tc , ctx , l .wallets [i ])
91+ execTestWithRecovery ( ctx , log , l . test , l .wallets [i ])
9192 }
9293 })
9394 }
9495
9596 _ = eg .Wait ()
9697}
98+
99+ // execTestWithRecovery ensures assertion-related panics encountered during test execution are recovered
100+ // and that deferred cleanups are always executed before returning.
101+ func execTestWithRecovery (ctx context.Context , log logging.Logger , test Test , wallet * Wallet ) {
102+ tc := tests .NewTestContext (log )
103+ defer tc .Recover ()
104+ test .Run (tc , ctx , wallet )
105+ }
0 commit comments