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-dms3
Commits
da04d267
Commit
da04d267
authored
10 years ago
by
Jeromy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
clean up test setup interface
parent
b4c6c874
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
12 deletions
+12
-12
net/mock/mock_net.go
net/mock/mock_net.go
+1
-1
routing/dht/dht_test.go
routing/dht/dht_test.go
+9
-9
util/testutil/gen.go
util/testutil/gen.go
+2
-2
No files found.
net/mock/mock_net.go
View file @
da04d267
...
...
@@ -41,7 +41,7 @@ func New(ctx context.Context) Mocknet {
}
func
(
mn
*
mocknet
)
GenPeer
()
(
inet
.
Network
,
error
)
{
sk, _, err := testutil.SeededKeyPair(
512,
int64(len(mn.nets)))
sk
,
_
,
err
:=
testutil
.
SeededKeyPair
(
int64
(
len
(
mn
.
nets
)))
if
err
!=
nil
{
return
nil
,
err
}
...
...
This diff is collapsed.
Click to expand it.
routing/dht/dht_test.go
View file @
da04d267
...
...
@@ -32,9 +32,9 @@ func init() {
}
}
func setupDHT(ctx context.Context, t *testing.T, addr ma.Multiaddr
, seed int64
) *IpfsDHT {
func setupDHT(ctx context.Context, t *testing.T, addr ma.Multiaddr) *IpfsDHT {
sk, pk, err := testutil.SeededKeyPair(
512, seed
)
sk, pk, err := testutil.SeededKeyPair(
time.Now().UnixNano()
)
if err != nil {
t.Fatal(err)
}
...
...
@@ -70,7 +70,7 @@ func setupDHTS(ctx context.Context, n int, t *testing.T) ([]ma.Multiaddr, []peer
for i := 0; i < n; i++ {
addrs[i] = testutil.RandLocalTCPAddress()
dhts[i] = setupDHT(ctx, t, addrs[i]
, int64(i)
)
dhts[i] = setupDHT(ctx, t, addrs[i])
peers[i] = dhts[i].self
}
...
...
@@ -119,8 +119,8 @@ func TestPing(t *testing.T) {
addrA := testutil.RandLocalTCPAddress()
addrB := testutil.RandLocalTCPAddress()
dhtA := setupDHT(ctx, t, addrA
, 1
)
dhtB := setupDHT(ctx, t, addrB
, 2
)
dhtA := setupDHT(ctx, t, addrA)
dhtB := setupDHT(ctx, t, addrB)
peerA := dhtA.self
peerB := dhtB.self
...
...
@@ -152,8 +152,8 @@ func TestValueGetSet(t *testing.T) {
addrA := testutil.RandLocalTCPAddress()
addrB := testutil.RandLocalTCPAddress()
dhtA := setupDHT(ctx, t, addrA
, 1
)
dhtB := setupDHT(ctx, t, addrB
, 2
)
dhtA := setupDHT(ctx, t, addrA)
dhtB := setupDHT(ctx, t, addrB)
defer dhtA.Close()
defer dhtB.Close()
...
...
@@ -636,8 +636,8 @@ func TestConnectCollision(t *testing.T) {
addrA := testutil.RandLocalTCPAddress()
addrB := testutil.RandLocalTCPAddress()
dhtA := setupDHT(ctx, t, addrA
, int64((rtime*2)+1)
)
dhtB := setupDHT(ctx, t, addrB
, int64((rtime*2)+2)
)
dhtA := setupDHT(ctx, t, addrA)
dhtB := setupDHT(ctx, t, addrB)
peerA := dhtA.self
peerB := dhtB.self
...
...
This diff is collapsed.
Click to expand it.
util/testutil/gen.go
View file @
da04d267
...
...
@@ -20,8 +20,8 @@ func RandKeyPair(bits int) (ci.PrivKey, ci.PubKey, error) {
return
ci
.
GenerateKeyPairWithReader
(
ci
.
RSA
,
bits
,
u
.
NewTimeSeededRand
())
}
func
SeededKeyPair
(
bits
int
,
seed
int64
)
(
ci
.
PrivKey
,
ci
.
PubKey
,
error
)
{
return
ci
.
GenerateKeyPairWithReader
(
ci
.
RSA
,
bits
,
u
.
NewSeededRand
(
seed
))
func
SeededKeyPair
(
seed
int64
)
(
ci
.
PrivKey
,
ci
.
PubKey
,
error
)
{
return
ci
.
GenerateKeyPairWithReader
(
ci
.
RSA
,
512
,
u
.
NewSeededRand
(
seed
))
}
// RandPeerID generates random "valid" peer IDs. it does not NEED to generate
...
...
This diff is collapsed.
Click to expand it.
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