test(network): fix race in TestNetworkIntegration_PrivateTransaction/event_received (backport of #4512) - #4513
Open
stevenvegt wants to merge 1 commit into
Open
Conversation
…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
requested review from
gerardsn,
reinkrul and
woutslakhorst
as code owners
September 9, 2026 13:06
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backport of #4512 to V6.2. Fixes the flaky
TestNetworkIntegration_PrivateTransaction/event_receivedseen on #4494 (nats: connection closedatnetwork_integration_test.go:564).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'smsg.Ack()then failed withnats: connection closed, and the callback asserted 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. Verified withgo test -race -count=5onTestNetworkIntegration_PrivateTransaction.