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
09a1db4c
Commit
09a1db4c
authored
Jan 05, 2015
by
Juan Batiz-Benet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
p2p/test: bogus key pair for faster tests
parent
c83c43a2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
11 deletions
+13
-11
bitswap_test.go
bitswap_test.go
+9
-9
testutils.go
testutils.go
+4
-2
No files found.
bitswap_test.go
View file @
09a1db4c
...
...
@@ -11,10 +11,10 @@ import (
blocks
"github.com/jbenet/go-ipfs/blocks"
blocksutil
"github.com/jbenet/go-ipfs/blocks/blocksutil"
tn
"github.com/jbenet/go-ipfs/exchange/bitswap/testnet"
p2ptestutil
"github.com/jbenet/go-ipfs/p2p/test/util"
mockrouting
"github.com/jbenet/go-ipfs/routing/mock"
u
"github.com/jbenet/go-ipfs/util"
delay
"github.com/jbenet/go-ipfs/util/delay"
"github.com/jbenet/go-ipfs/util/testutil"
)
// FIXME the tests are really sensitive to the network delay. fix them to work
...
...
@@ -25,7 +25,7 @@ func TestClose(t *testing.T) {
// TODO
t
.
Skip
(
"TODO Bitswap's Close implementation is a WIP"
)
vnet
:=
tn
.
VirtualNetwork
(
mockrouting
.
NewServer
(),
delay
.
Fixed
(
kNetworkDelay
))
sesgen
:=
NewSessionGenerator
(
vnet
)
sesgen
:=
New
Test
SessionGenerator
(
vnet
)
defer
sesgen
.
Close
()
bgen
:=
blocksutil
.
NewBlockGenerator
()
...
...
@@ -39,7 +39,7 @@ func TestClose(t *testing.T) {
func
TestGetBlockTimeout
(
t
*
testing
.
T
)
{
net
:=
tn
.
VirtualNetwork
(
mockrouting
.
NewServer
(),
delay
.
Fixed
(
kNetworkDelay
))
g
:=
NewSessionGenerator
(
net
)
g
:=
New
Test
SessionGenerator
(
net
)
defer
g
.
Close
()
self
:=
g
.
Next
()
...
...
@@ -57,11 +57,11 @@ func TestProviderForKeyButNetworkCannotFind(t *testing.T) { // TODO revisit this
rs
:=
mockrouting
.
NewServer
()
net
:=
tn
.
VirtualNetwork
(
rs
,
delay
.
Fixed
(
kNetworkDelay
))
g
:=
NewSessionGenerator
(
net
)
g
:=
New
Test
SessionGenerator
(
net
)
defer
g
.
Close
()
block
:=
blocks
.
NewBlock
([]
byte
(
"block"
))
pinfo
:=
testutil
.
RandIdentityOrFatal
(
t
)
pinfo
:=
p2p
testutil
.
Rand
TestBogus
IdentityOrFatal
(
t
)
rs
.
Client
(
pinfo
)
.
Provide
(
context
.
Background
(),
block
.
Key
())
// but not on network
solo
:=
g
.
Next
()
...
...
@@ -81,7 +81,7 @@ func TestGetBlockFromPeerAfterPeerAnnounces(t *testing.T) {
net
:=
tn
.
VirtualNetwork
(
mockrouting
.
NewServer
(),
delay
.
Fixed
(
kNetworkDelay
))
block
:=
blocks
.
NewBlock
([]
byte
(
"block"
))
g
:=
NewSessionGenerator
(
net
)
g
:=
New
Test
SessionGenerator
(
net
)
defer
g
.
Close
()
hasBlock
:=
g
.
Next
()
...
...
@@ -134,7 +134,7 @@ func PerformDistributionTest(t *testing.T, numInstances, numBlocks int) {
t
.
SkipNow
()
}
net
:=
tn
.
VirtualNetwork
(
mockrouting
.
NewServer
(),
delay
.
Fixed
(
kNetworkDelay
))
sg
:=
NewSessionGenerator
(
net
)
sg
:=
New
Test
SessionGenerator
(
net
)
defer
sg
.
Close
()
bg
:=
blocksutil
.
NewBlockGenerator
()
...
...
@@ -198,7 +198,7 @@ func TestSendToWantingPeer(t *testing.T) {
}
net
:=
tn
.
VirtualNetwork
(
mockrouting
.
NewServer
(),
delay
.
Fixed
(
kNetworkDelay
))
sg
:=
NewSessionGenerator
(
net
)
sg
:=
New
Test
SessionGenerator
(
net
)
defer
sg
.
Close
()
bg
:=
blocksutil
.
NewBlockGenerator
()
...
...
@@ -243,7 +243,7 @@ func TestSendToWantingPeer(t *testing.T) {
func
TestBasicBitswap
(
t
*
testing
.
T
)
{
net
:=
tn
.
VirtualNetwork
(
mockrouting
.
NewServer
(),
delay
.
Fixed
(
kNetworkDelay
))
sg
:=
NewSessionGenerator
(
net
)
sg
:=
New
Test
SessionGenerator
(
net
)
bg
:=
blocksutil
.
NewBlockGenerator
()
t
.
Log
(
"Test a few nodes trying to get one file with a lot of blocks"
)
...
...
testutils.go
View file @
09a1db4c
...
...
@@ -10,12 +10,14 @@ import (
exchange
"github.com/jbenet/go-ipfs/exchange"
tn
"github.com/jbenet/go-ipfs/exchange/bitswap/testnet"
peer
"github.com/jbenet/go-ipfs/p2p/peer"
p2ptestutil
"github.com/jbenet/go-ipfs/p2p/test/util"
datastore2
"github.com/jbenet/go-ipfs/util/datastore2"
delay
"github.com/jbenet/go-ipfs/util/delay"
testutil
"github.com/jbenet/go-ipfs/util/testutil"
)
func
NewSessionGenerator
(
// WARNING: this uses RandTestBogusIdentity DO NOT USE for NON TESTS!
func
NewTestSessionGenerator
(
net
tn
.
Network
)
SessionGenerator
{
ctx
,
cancel
:=
context
.
WithCancel
(
context
.
TODO
())
return
SessionGenerator
{
...
...
@@ -41,7 +43,7 @@ func (g *SessionGenerator) Close() error {
func
(
g
*
SessionGenerator
)
Next
()
Instance
{
g
.
seq
++
p
,
err
:=
testutil
.
RandIdentity
()
p
,
err
:=
p2p
testutil
.
Rand
TestBogus
Identity
()
if
err
!=
nil
{
panic
(
"FIXME"
)
// TODO change signature
}
...
...
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