Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-bitswap
Commits
6a7c1d4d
Commit
6a7c1d4d
authored
Nov 21, 2014
by
Brian Tiger Chow
Committed by
Jeromy
Dec 05, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test(bs/n) check for duplicates received
License: MIT Signed-off-by:
Brian Tiger Chow
<
brian@perfmode.com
>
parent
365044ce
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
2 deletions
+27
-2
notifications/notifications_test.go
notifications/notifications_test.go
+27
-2
No files found.
notifications/notifications_test.go
View file @
6a7c1d4d
...
...
@@ -9,6 +9,31 @@ import (
blocks
"github.com/jbenet/go-ipfs/blocks"
)
func
TestDuplicates
(
t
*
testing
.
T
)
{
b1
:=
blocks
.
NewBlock
([]
byte
(
"1"
))
b2
:=
blocks
.
NewBlock
([]
byte
(
"2"
))
n
:=
New
()
defer
n
.
Shutdown
()
ch
:=
n
.
Subscribe
(
context
.
Background
(),
b1
.
Key
(),
b2
.
Key
())
n
.
Publish
(
b1
)
blockRecvd
,
ok
:=
<-
ch
if
!
ok
{
t
.
Fail
()
}
assertBlocksEqual
(
t
,
b1
,
blockRecvd
)
n
.
Publish
(
b1
)
// ignored duplicate
n
.
Publish
(
b2
)
blockRecvd
,
ok
=
<-
ch
if
!
ok
{
t
.
Fail
()
}
assertBlocksEqual
(
t
,
b2
,
blockRecvd
)
}
func
TestPublishSubscribe
(
t
*
testing
.
T
)
{
blockSent
:=
blocks
.
NewBlock
([]
byte
(
"Greetings from The Interval"
))
...
...
@@ -80,9 +105,9 @@ func assertBlockChannelNil(t *testing.T, blockChannel <-chan *blocks.Block) {
func
assertBlocksEqual
(
t
*
testing
.
T
,
a
,
b
*
blocks
.
Block
)
{
if
!
bytes
.
Equal
(
a
.
Data
,
b
.
Data
)
{
t
.
Fa
il
(
)
t
.
Fa
tal
(
"blocks aren't equal"
)
}
if
a
.
Key
()
!=
b
.
Key
()
{
t
.
Fa
il
(
)
t
.
Fa
tal
(
"block keys aren't equal"
)
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment