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
6896d8f0
Commit
6896d8f0
authored
Feb 17, 2015
by
Jeromy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add a test to make sure duplicate subscriptions to the same block dont have weird side effects
parent
55523af9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
0 deletions
+24
-0
notifications/notifications_test.go
notifications/notifications_test.go
+24
-0
No files found.
notifications/notifications_test.go
View file @
6896d8f0
...
@@ -76,6 +76,30 @@ func TestSubscribeMany(t *testing.T) {
...
@@ -76,6 +76,30 @@ func TestSubscribeMany(t *testing.T) {
assertBlocksEqual
(
t
,
e2
,
r2
)
assertBlocksEqual
(
t
,
e2
,
r2
)
}
}
// TestDuplicateSubscribe tests a scenario where a given block
// would be requested twice at the same time.
func
TestDuplicateSubscribe
(
t
*
testing
.
T
)
{
e1
:=
blocks
.
NewBlock
([]
byte
(
"1"
))
n
:=
New
()
defer
n
.
Shutdown
()
ch1
:=
n
.
Subscribe
(
context
.
Background
(),
e1
.
Key
())
ch2
:=
n
.
Subscribe
(
context
.
Background
(),
e1
.
Key
())
n
.
Publish
(
e1
)
r1
,
ok
:=
<-
ch1
if
!
ok
{
t
.
Fatal
(
"didn't receive first expected block"
)
}
assertBlocksEqual
(
t
,
e1
,
r1
)
r2
,
ok
:=
<-
ch2
if
!
ok
{
t
.
Fatal
(
"didn't receive second expected block"
)
}
assertBlocksEqual
(
t
,
e1
,
r2
)
}
func
TestSubscribeIsANoopWhenCalledWithNoKeys
(
t
*
testing
.
T
)
{
func
TestSubscribeIsANoopWhenCalledWithNoKeys
(
t
*
testing
.
T
)
{
n
:=
New
()
n
:=
New
()
defer
n
.
Shutdown
()
defer
n
.
Shutdown
()
...
...
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