Skip to content

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

Open
stevenvegt wants to merge 1 commit into
V6.2from
V6_2/fix-flaky-private-tx-event-received
Open

test(network): fix race in TestNetworkIntegration_PrivateTransaction/event_received (backport of #4512)#4513
stevenvegt wants to merge 1 commit into
V6.2from
V6_2/fix-flaky-private-tx-event-received

Conversation

@stevenvegt

Copy link
Copy Markdown
Member

Backport of #4512 to V6.2. Fixes the flaky TestNetworkIntegration_PrivateTransaction/event_received seen on #4494 (nats: connection closed at network_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's msg.Ack() then failed with nats: 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 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)
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