mirror of
https://github.com/ipfs/kubo.git
synced 2025-06-30 01:52:26 +08:00
refac(bitswap:notif) replace block generating func
This commit is contained in:
@ -6,12 +6,13 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
context "github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/go.net/context"
|
context "github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/go.net/context"
|
||||||
|
testutil "github.com/jbenet/go-ipfs/util/testutil"
|
||||||
|
|
||||||
blocks "github.com/jbenet/go-ipfs/blocks"
|
blocks "github.com/jbenet/go-ipfs/blocks"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestPublishSubscribe(t *testing.T) {
|
func TestPublishSubscribe(t *testing.T) {
|
||||||
blockSent := getBlockOrFail(t, "Greetings from The Interval")
|
blockSent := testutil.NewBlockOrFail(t, "Greetings from The Interval")
|
||||||
|
|
||||||
n := New()
|
n := New()
|
||||||
defer n.Shutdown()
|
defer n.Shutdown()
|
||||||
@ -34,7 +35,7 @@ func TestCarryOnWhenDeadlineExpires(t *testing.T) {
|
|||||||
|
|
||||||
n := New()
|
n := New()
|
||||||
defer n.Shutdown()
|
defer n.Shutdown()
|
||||||
block := getBlockOrFail(t, "A Missed Connection")
|
block := testutil.NewBlockOrFail(t, "A Missed Connection")
|
||||||
blockChannel := n.Subscribe(fastExpiringCtx, block.Key())
|
blockChannel := n.Subscribe(fastExpiringCtx, block.Key())
|
||||||
|
|
||||||
assertBlockChannelNil(t, blockChannel)
|
assertBlockChannelNil(t, blockChannel)
|
||||||
@ -55,11 +56,3 @@ func assertBlocksEqual(t *testing.T, a, b blocks.Block) {
|
|||||||
t.Fail()
|
t.Fail()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func getBlockOrFail(t *testing.T, msg string) blocks.Block {
|
|
||||||
block, blockCreationErr := blocks.NewBlock([]byte(msg))
|
|
||||||
if blockCreationErr != nil {
|
|
||||||
t.Fail()
|
|
||||||
}
|
|
||||||
return *block
|
|
||||||
}
|
|
||||||
|
Reference in New Issue
Block a user