test(network): fix race in TestNetworkIntegration_PrivateTransaction/event_received - #4512
Open
stevenvegt wants to merge 1 commit into
Open
test(network): fix race in TestNetworkIntegration_PrivateTransaction/event_received#4512stevenvegt wants to merge 1 commit into
stevenvegt wants to merge 1 commit into
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
stevenvegt
requested review from
Dirklectisch,
JorisHeadease,
gerardsn,
reinkrul and
woutslakhorst
as code owners
September 9, 2026 13:05
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.
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 wait did not time out, which is why only the ack error shows up in the log.The subtest now waits for the private TX event specifically (payload
private TX), 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 todefaultTimeoutbecause the private TX event is only emitted after node2 has fetched the payload, which takes a round trip. Verified withgo test -race -count=10onTestNetworkIntegration_PrivateTransaction.Backports to V6.2 and V5.4 follow, both branches have the same subtest.