Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: PRT: Attempt on fixing the statistical subscription test fail #1692

Merged
merged 2 commits into from
Sep 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions protocol/chainlib/provider_node_subscription_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ func TestSubscriptionManager_MultipleParallelSubscriptionsWithTheSameParamsAndNo
t.Run(play.name, func(t *testing.T) {
ts := SetupForTests(t, 1, play.specId, "../../")

wg := sync.WaitGroup{}
sentMessageToNodeChannel := make(chan bool, 1)
// msgCount := 0
upgrader := websocket.Upgrader{}
first := true
Expand Down Expand Up @@ -373,7 +373,12 @@ func TestSubscriptionManager_MultipleParallelSubscriptionsWithTheSameParamsAndNo
return
}
utils.LavaFormatDebug("write message")
wg.Done()
select {
case sentMessageToNodeChannel <- true:
utils.LavaFormatDebug("sent message to node")
default:
utils.LavaFormatDebug("unable to communicate with the test")
}

// Write the first reply
err = conn.WriteMessage(messageType, play.subscriptionFirstReply)
Expand Down Expand Up @@ -405,7 +410,6 @@ func TestSubscriptionManager_MultipleParallelSubscriptionsWithTheSameParamsAndNo
mockRpcProvider := &RelayFinalizationBlocksHandlerMock{}
pnsm := NewProviderNodeSubscriptionManager(chainRouter, chainParser, mockRpcProvider, ts.Providers[0].SK)

wg.Add(1)
wgAllIds := sync.WaitGroup{}
wgAllIds.Add(9)
errors := []error{}
Expand All @@ -429,7 +433,11 @@ func TestSubscriptionManager_MultipleParallelSubscriptionsWithTheSameParamsAndNo

utils.LavaFormatDebug("Waiting wait group")
wgAllIds.Wait()
wg.Wait() // Make sure the subscription manager sent a message to the node
select {
case <-sentMessageToNodeChannel: // Make sure the subscription manager sent a message to the node
case <-time.After(time.Second * 10):
require.Fail(t, "timeout waiting for message to node")
}
// make sure we had only one error, on the first subscription attempt
require.Len(t, errors, 1)

Expand Down
Loading