Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions tests/load2/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,7 @@ func (l LoadGenerator) Run(
default:
}

ctx, cancel := context.WithTimeout(ctx, testTimeout)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved to execTestWithRecovery to ensure that cancelation is localized to test execution rather than only being performed on goroutine exit.

defer cancel()

execTestWithRecovery(ctx, log, l.test, l.wallets[i])
execTestWithRecovery(ctx, log, l.test, l.wallets[i], testTimeout)
}
})
}
Expand All @@ -98,8 +95,10 @@ func (l LoadGenerator) Run(

// execTestWithRecovery ensures assertion-related panics encountered during test execution are recovered
// and that deferred cleanups are always executed before returning.
func execTestWithRecovery(ctx context.Context, log logging.Logger, test Test, wallet *Wallet) {
func execTestWithRecovery(ctx context.Context, log logging.Logger, test Test, wallet *Wallet, testTimeout time.Duration) {
tc := tests.NewTestContext(log)
Copy link
Contributor

@maru-ava maru-ava Jul 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Creating a new TestContext here ensures that recovery executes only the cleanups registered to this context.

defer tc.Recover()
test.Run(tc, ctx, wallet)
contextWithTimeout, cancel := context.WithTimeout(ctx, testTimeout)
defer cancel()
test.Run(tc, contextWithTimeout, wallet)
}