Skip to content

test(network): fix race in TestNetworkIntegration_PrivateTransaction/event_received (backport of #4512) - #4514

Open
stevenvegt wants to merge 1 commit into
V5.4from
V5_4/fix-flaky-private-tx-event-received
Open

test(network): fix race in TestNetworkIntegration_PrivateTransaction/event_received (backport of #4512)#4514
stevenvegt wants to merge 1 commit into
V5.4from
V5_4/fix-flaky-private-tx-event-received

Conversation

@stevenvegt

Copy link
Copy Markdown
Member

Backport of #4512 to V5.4. Fixes the flaky TestNetworkIntegration_PrivateTransaction/event_received (nats: connection closed on msg.Ack() in the subscription callback), first seen on V6.2 in #4494. V5.4 has the same subtest with the same race.

node2 publishes a NATS event for every transaction it receives, so the subtest gets two messages: the bootstrap DID document transaction and the private TX. The subtest waited for any message, returned on the first one and closed the connection through the deferred conn.Close(). The second message's msg.Ack() then failed with nats: connection closed, and the callback called require against a test that had already completed.

The subtest now waits for the private TX event specifically, records its ack error under the mutex and asserts it on the test goroutine. Other messages are acked without asserting. The wait timeout is raised from 100ms to defaultTimeout. Applied by hand because the transaction setup differs from master. Verified with go test -race -count=5 on TestNetworkIntegration_PrivateTransaction.

…event_received

node2 publishes a NATS event for every transaction it receives, so the
subtest gets two messages: the bootstrap DID document and the private
TX. The test waited for any message, returned on the first one and
closed the connection, after which the second message's ack failed with
"nats: connection closed" and asserted against a completed test.

Wait for the private TX event specifically, record its ack error under
the mutex and assert it on the test goroutine.

Assisted-by: AI
(cherry picked from commit b788cd3)
@stevenvegt
stevenvegt force-pushed the V5_4/fix-flaky-private-tx-event-received branch from dbc7185 to 014bf49 Compare September 9, 2026 13:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant