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
c67d48d9
Commit
c67d48d9
authored
Sep 19, 2014
by
Brian Tiger Chow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test(bitswap)
parent
0881636a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
5 deletions
+31
-5
bitswap_test.go
bitswap_test.go
+31
-5
No files found.
bitswap_test.go
View file @
c67d48d9
...
@@ -33,19 +33,45 @@ func TestProviderForKeyButNetworkCannotFind(t *testing.T) {
...
@@ -33,19 +33,45 @@ func TestProviderForKeyButNetworkCannotFind(t *testing.T) {
net
:=
LocalNetwork
()
net
:=
LocalNetwork
()
rs
:=
newRoutingServer
()
rs
:=
newRoutingServer
()
ipfs
:=
session
(
net
,
rs
,
[]
byte
(
"peer id"
))
// ctx := context.Background()
ctx
,
_
:=
context
.
WithTimeout
(
context
.
Background
(),
time
.
Nanosecond
)
block
:=
testutil
.
NewBlockOrFail
(
t
,
"block"
)
block
:=
testutil
.
NewBlockOrFail
(
t
,
"block"
)
rs
.
Announce
(
&
peer
.
Peer
{},
block
.
Key
())
// but not on network
rs
.
Announce
(
&
peer
.
Peer
{},
block
.
Key
())
// but not on network
_
,
err
:=
ipfs
.
exchange
.
Block
(
ctx
,
block
.
Key
())
solo
:=
session
(
net
,
rs
,
[]
byte
(
"peer id"
))
ctx
,
_
:=
context
.
WithTimeout
(
context
.
Background
(),
time
.
Nanosecond
)
_
,
err
:=
solo
.
exchange
.
Block
(
ctx
,
block
.
Key
())
if
err
!=
context
.
DeadlineExceeded
{
if
err
!=
context
.
DeadlineExceeded
{
t
.
Fatal
(
"Expected DeadlineExceeded error"
)
t
.
Fatal
(
"Expected DeadlineExceeded error"
)
}
}
}
}
// TestGetBlockAfterRequesting...
func
TestGetBlockFromPeerAfterPeerAnnounces
(
t
*
testing
.
T
)
{
t
.
Skip
(
"Failing. Work in progress"
)
net
:=
LocalNetwork
()
rs
:=
newRoutingServer
()
block
:=
testutil
.
NewBlockOrFail
(
t
,
"block"
)
hasBlock
:=
session
(
net
,
rs
,
[]
byte
(
"hasBlock"
))
rs
.
Announce
(
hasBlock
.
peer
,
block
.
Key
())
hasBlock
.
blockstore
.
Put
(
block
)
hasBlock
.
exchange
.
HasBlock
(
context
.
Background
(),
block
)
wantsBlock
:=
session
(
net
,
rs
,
[]
byte
(
"wantsBlock"
))
ctx
,
_
:=
context
.
WithTimeout
(
context
.
Background
(),
time
.
Second
)
_
,
err
:=
wantsBlock
.
exchange
.
Block
(
ctx
,
block
.
Key
())
if
err
!=
nil
{
t
.
Log
(
err
)
t
.
Fatal
(
"Expected to succeed"
)
}
}
type
ipfs
struct
{
type
ipfs
struct
{
peer
*
peer
.
Peer
peer
*
peer
.
Peer
exchange
exchange
.
Interface
exchange
exchange
.
Interface
...
...
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