Skip to content

Commit

Permalink
test: fix flaky test TestSessionBetweenPeers
Browse files Browse the repository at this point in the history
This commit was moved from ipfs/go-bitswap@373033e
  • Loading branch information
dirkmc committed May 1, 2020
1 parent d56f8df commit 522cdcc
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion bitswap/bitswap_with_sessions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ import (
bitswap "github.com/ipfs/go-bitswap"
bssession "github.com/ipfs/go-bitswap/internal/session"
testinstance "github.com/ipfs/go-bitswap/testinstance"
tn "github.com/ipfs/go-bitswap/testnet"
blocks "github.com/ipfs/go-block-format"
cid "github.com/ipfs/go-cid"
blocksutil "github.com/ipfs/go-ipfs-blocksutil"
delay "github.com/ipfs/go-ipfs-delay"
mockrouting "github.com/ipfs/go-ipfs-routing/mock"
tu "github.com/libp2p/go-libp2p-testing/etc"
)

Expand Down Expand Up @@ -71,7 +73,7 @@ func TestSessionBetweenPeers(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()

vnet := getVirtualNetwork()
vnet := tn.VirtualNetwork(mockrouting.NewServer(), delay.Fixed(time.Millisecond))
ig := testinstance.NewTestInstanceGenerator(vnet, nil, nil)
defer ig.Close()
bgen := blocksutil.NewBlockGenerator()
Expand Down Expand Up @@ -112,6 +114,10 @@ func TestSessionBetweenPeers(t *testing.T) {
t.Fatal(err)
}
}

// Uninvolved nodes should receive
// - initial broadcast want-have of root block
// - CANCEL (when Peer A receives the root block from Peer B)
for _, is := range inst[2:] {
stat, err := is.Exchange.Stat()
if err != nil {
Expand Down

0 comments on commit 522cdcc

Please sign in to comment.