!5346ci/flake-sweep-2026-11-09 → develop7c189e02f2

Widen XMR delivery budgets in three flaky observer tests

AI-generatedEverything on this page was written by an AI agent from the diff: the summaries, the narration, the diagrams, the flags and the glossary. It can be wrong or incomplete, so check it against the code before you rely on it.

1commits
2files
32lines changed
0lines to read
0production lines
3tests fixed
20/50→500msPeerTimeout in tests

Where the diff is

Look here first

Slow auth must still outlast the deadlineslowAuthDelay = timeout + 250ms keeps the expired-deadline path tested; check 250ms margin survives the same CI stalls.attestation_cancellation_integration_test.go:28 ↗careful
1919
20+// The XMR delivery deadline starts before the handler takes s.mu, and the
21+// attestation is dropped if that deadline has already passed once the lock is
22+// held. A 50ms budget was shorter than scheduler/GC stalls on a loaded CI
23+// runner, so the import was sometimes never attempted. Keep the budget well
24+// above such stalls, and make the slow authorization outlast it so the
25+// deadline has really expired by the time authorization returns.
26+const (
27+ slowAuthDeliveryTimeout = 500 * time.Millisecond
28+ slowAuthDelay = slowAuthDeliveryTimeout + 250*time.Millisecond
29+ slowAuthImportWait = 5 * time.Second
30+)
31+
2032 func TestStateCancellationPreservesOrdinaryXMRSlowAuthorization(t *testing.T) {
21− for _, delay := range []time.Duration{0, 150 * time.Millisecond} {
33+ for _, delay := range []time.Duration{0, slowAuthDelay} {
2234 t.Run(delay.String(), func(t *testing.T) {
2335 s, _, _, _, legacy, _ := setupTestGossip(t)
24− s.config.PeerTimeout = 50 * time.Millisecond
36+ s.config.PeerTimeout = slowAuthDeliveryTimeout
2537 tx, plan := observerTestXMRPlan(t)
2638 key := secp256k1.GenPrivKey()
2739 vault := observerTestVaultFunc(tx.ObservedPubKey, observerTestPubKey(t, key))
Timeout path still exercisedStub blocks on ctx.Done(), so DeadlineExceeded is still reached; test now takes ~500ms instead of 20ms.attestation_state_import_test.go:359 ↗careful
350+// deadline fires, so this budget only needs to outlast the pre-submission
351+// path, not the submission itself.
352+g.config.PeerTimeout = 500 * time.Millisecond
347353 tx, _ := observerTestXMRPlan(t)
348354 key := secp256k1.GenPrivKey()
349355 batch := signedCancellationBatch(t, tx, key)
350356 g.activeVals = map[peer.ID]bool{"one-validator": true}
351357 var submissionErr error
352358 client.sendQuorumTxFunc = func(ctx context.Context, _ *common.QuorumTx, _ ...grpc.CallOption) (*ebifrost.SendQuorumTxResult, error) {
353359 <-ctx.Done()
354360 submissionErr = ctx.Err()
355361 return nil, submissionErr
356362 }
357363 data, err := batch.Marshal()
358364 require.NoError(t, err)
359365 result := g.askStreamForState(stateSyncImportStream(t, "peer", data))
360366 require.ErrorIs(t, submissionErr, context.DeadlineExceeded)
361367 require.True(t, result.completed)
362368 require.NoError(t, result.err)
363369 require.Equal(t, 1, result.items)
364370 state := g.observedTxs[observedTxKey(tx, false, false)]
365371 require.Len(t, state.UnsentAttestations(), 1)
366372 require.False(t, state.spentRefsApplied)
PeerTimeout stays under block-time clampxmrAttestationTimeout clamps to ThorchainBlockTime; 500ms is below it, so the configured budget is used as-is.attestation_cancellation_integration_test.go:36 ↗look
29+ slowAuthImportWait = 5 * time.Second
30+)
31+
2032 func TestStateCancellationPreservesOrdinaryXMRSlowAuthorization(t *testing.T) {
21− for _, delay := range []time.Duration{0, 150 * time.Millisecond} {
33+ for _, delay := range []time.Duration{0, slowAuthDelay} {
2234 t.Run(delay.String(), func(t *testing.T) {
2335 s, _, _, _, legacy, _ := setupTestGossip(t)
24− s.config.PeerTimeout = 50 * time.Millisecond
36+ s.config.PeerTimeout = slowAuthDeliveryTimeout
2537 tx, plan := observerTestXMRPlan(t)
2638 key := secp256k1.GenPrivKey()
2739 vault := observerTestVaultFunc(tx.ObservedPubKey, observerTestPubKey(t, key))
2840 legacy.getVaultFunc = func(pk string) (thortypes.Vault, error) {
2941 // Authorization runs after the delivery critical section. The
3042 // delivery deadline must not discard a later successful import.
3143 time.Sleep(delay)
3244 return vault(pk)
3345 }
3446 legacy.getKeysignFunc = observerTestKeysignFunc(plan)
3547 imported := make(chan struct{}, 1)
3648 s.SetObserverApplySpentOutputRefs(func(_ spentOutputRefsImport, outcome func(bool)) {
3749 outcome(true)
Import wait raised 1s→5sOnly lengthens the failure path; passing runs return as soon as the import signals.attestation_cancellation_integration_test.go:56 ↗look
3648 s.SetObserverApplySpentOutputRefs(func(_ spentOutputRefsImport, outcome func(bool)) {
3749 outcome(true)
3850 imported <- struct{}{}
3951 })
4052 batch := signedCancellationBatch(t, tx, key)
4153 s.handleObservedTxAttestation(context.Background(), common.AttestTx{ObsTx: tx, Attestation: batch.QuoTxs[0].Attestations[0]})
4254 select {
4355 case <-imported:
44− case <-time.After(time.Second):
56+ case <-time.After(slowAuthImportWait):
4557 t.Fatal("ordinary delivery discarded a successful authorization after its delivery deadline")
4658 }
4759 state, exists := observerTestConflictState(s, tx)
4860 require.True(t, exists)
4961 require.Equal(t, xmrSpentRefsImportConfirmed, state)
5062 })
5163 }
5264 }
5365
5466 func TestStateCancellationXMRSlowAuthorizationUsesTransferDeadline(t *testing.T) {
55− for _, delay := range []time.Duration{0, 150 * time.Millisecond} {
67+ for _, delay := range []time.Duration{0, slowAuthDelay} {
5668 t.Run(delay.String(), func(t *testing.T) {

Ask an AI about this change

Chat assistantClaude, ChatGPT, … (reads a link)

Coding agentClaude Code, Cursor, … (reads the repo)

The context file is context.md. Use Copy with context for an AI that can't open links; it pastes the whole file in.

Glossary

Flake
A test that fails intermittently on the same code, here from scheduler or GC stalls on busy CI runners.
PeerTimeout
Gossip config budget; for XMR it also sets the delivery deadline started before the handler takes s.mu. attestation_gossip.go ↗
xmrAttestationTimeout
Clamps the configured PeerTimeout to at most one THORChain block time for XMR attestation delivery. attestation_handlers_impl.go ↗