Skip to content

Commit

Permalink
fix: Add delay in P2P test util execution (#1093)
Browse files Browse the repository at this point in the history
Relevant issue(s)
Resolves #1092

Description
This PR add a time delay to the execution of the P2P test utility in order to ensure the collection subscription has time to complete before we get to the create and update functions.

Additionally, this PR fixes a potential early return in the addPubSubTopic function.
  • Loading branch information
fredcarle authored Feb 14, 2023
1 parent 5881187 commit 0b18706
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 2 additions & 1 deletion net/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,8 +274,9 @@ func (s *server) addPubSubTopic(topic string, subscribe bool) error {
if err := t.Close(); err != nil {
return err
}
} else {
return nil
}
return nil
}

t, err := rpc.NewTopic(s.peer.ctx, s.peer.ps, s.peer.host.ID(), topic, subscribe)
Expand Down
6 changes: 6 additions & 0 deletions tests/integration/net/state/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,12 @@ func ExecuteTestCase(
require.NoError(t, err)
}

// The `n.Peer.AddP2PCollections(colIDs)` call above is calling some asynchronous functions
// for the pubsub subscription and those functions can take a bit of time to complete.
// Since it is possible to get to the create and update functions bellow before the subscription
// completes, we add a 100ms sleep to ensure the subsciption has time to finish.
time.Sleep(100 * time.Millisecond)

docInNodes := mapNodesToDoc(test)

wg := &sync.WaitGroup{}
Expand Down

0 comments on commit 0b18706

Please sign in to comment.