mirror of
https://github.com/ipfs/kubo.git
synced 2025-06-29 17:36:38 +08:00
Merge pull request #4727 from ipfs/fix/4726
fix race in TestWantlistClearsOnCancel
This commit is contained in:
@ -8,6 +8,7 @@ import (
|
|||||||
|
|
||||||
blocksutil "github.com/ipfs/go-ipfs/blocks/blocksutil"
|
blocksutil "github.com/ipfs/go-ipfs/blocks/blocksutil"
|
||||||
|
|
||||||
|
tu "gx/ipfs/QmVvkK7s5imCiq3JVbL3pGfnhcCnf3LrFJPF4GE2sAoGZf/go-testutil"
|
||||||
cid "gx/ipfs/QmcZfnkapfECQGcLZaf9B79NRg7cRa9EnZh4LSbkCzwNvY/go-cid"
|
cid "gx/ipfs/QmcZfnkapfECQGcLZaf9B79NRg7cRa9EnZh4LSbkCzwNvY/go-cid"
|
||||||
blocks "gx/ipfs/Qmej7nf81hi2x2tvjRBF3mcp74sQyuDH4VMYDGd1YtXjb2/go-block-format"
|
blocks "gx/ipfs/Qmej7nf81hi2x2tvjRBF3mcp74sQyuDH4VMYDGd1YtXjb2/go-block-format"
|
||||||
)
|
)
|
||||||
@ -287,7 +288,7 @@ func TestMultipleSessions(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestWantlistClearsOnCancel(t *testing.T) {
|
func TestWantlistClearsOnCancel(t *testing.T) {
|
||||||
ctx, cancel := context.WithCancel(context.Background())
|
ctx, cancel := context.WithTimeout(context.Background(), time.Second*5)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
vnet := getVirtualNetwork()
|
vnet := getVirtualNetwork()
|
||||||
@ -314,7 +315,12 @@ func TestWantlistClearsOnCancel(t *testing.T) {
|
|||||||
}
|
}
|
||||||
cancel1()
|
cancel1()
|
||||||
|
|
||||||
if len(a.Exchange.GetWantlist()) > 0 {
|
if err := tu.WaitFor(ctx, func() error {
|
||||||
t.Fatal("expected empty wantlist")
|
if len(a.Exchange.GetWantlist()) > 0 {
|
||||||
|
return fmt.Errorf("expected empty wantlist")
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user