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
02cf54de
Unverified
Commit
02cf54de
authored
Apr 14, 2020
by
Will Scott
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rebase on dual DHT
parent
635a5c79
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
21 deletions
+37
-21
test/integration/wan_lan_dht_test.go
test/integration/wan_lan_dht_test.go
+37
-21
No files found.
test/integration/wan_lan_dht_test.go
View file @
02cf54de
...
...
@@ -102,6 +102,7 @@ func RunDHTConnectivity(conf testutil.LatencyConfig, numPeers int) error {
wanAddr
:=
makeAddr
(
uint32
(
i
),
true
)
wanPeer
.
Peerstore
.
AddAddr
(
wanPeer
.
Identity
,
wanAddr
,
peerstore
.
PermanentAddrTTL
)
for
_
,
p
:=
range
wanPeers
{
mn
.
LinkPeers
(
p
.
Identity
,
wanPeer
.
Identity
)
mn
.
ConnectPeers
(
p
.
Identity
,
wanPeer
.
Identity
)
}
wanPeers
=
append
(
wanPeers
,
wanPeer
)
...
...
@@ -117,18 +118,30 @@ func RunDHTConnectivity(conf testutil.LatencyConfig, numPeers int) error {
lanAddr
:=
makeAddr
(
uint32
(
i
),
false
)
lanPeer
.
Peerstore
.
AddAddr
(
lanPeer
.
Identity
,
lanAddr
,
peerstore
.
PermanentAddrTTL
)
for
_
,
p
:=
range
lanPeers
{
mn
.
LinkPeers
(
p
.
Identity
,
lanPeer
.
Identity
)
mn
.
ConnectPeers
(
p
.
Identity
,
lanPeer
.
Identity
)
}
lanPeers
=
append
(
lanPeers
,
lanPeer
)
}
// Add interfaces / addresses to test peer.
wanAddr
:=
makeAddr
(
0
,
true
)
testPeer
.
Peerstore
.
AddAddr
(
testPeer
.
Identity
,
wanAddr
,
peerstore
.
PermanentAddrTTL
)
lanAddr
:=
makeAddr
(
0
,
false
)
testPeer
.
Peerstore
.
AddAddr
(
testPeer
.
Identity
,
lanAddr
,
peerstore
.
PermanentAddrTTL
)
// The test peer is connected to one lan peer.
for
_
,
p
:=
range
lanPeers
{
if
_
,
err
:=
mn
.
LinkPeers
(
testPeer
.
Identity
,
p
.
Identity
);
err
!=
nil
{
return
err
}
}
_
,
err
=
mn
.
ConnectPeers
(
testPeer
.
Identity
,
lanPeers
[
0
]
.
Identity
)
if
err
!=
nil
{
return
err
}
err
,
done
:=
<-
testPeer
.
DHT
.
RefreshRoutingTable
()
err
,
done
:=
<-
testPeer
.
DHT
.
LAN
.
RefreshRoutingTable
()
if
err
!=
nil
||
!
done
{
if
!
done
{
err
=
fmt
.
Errorf
(
"expected refresh routing table to close"
)
...
...
@@ -149,25 +162,28 @@ func RunDHTConnectivity(conf testutil.LatencyConfig, numPeers int) error {
if
err
:=
lanPeers
[
i
]
.
DHT
.
Provide
(
provideCtx
,
provideCid
,
true
);
err
!=
nil
{
return
err
}
provs
,
err
:=
testPeer
.
DHT
.
FindProviders
(
provideCtx
,
provideCid
)
if
err
!=
nil
{
return
err
provChan
:=
testPeer
.
DHT
.
FindProvidersAsync
(
provideCtx
,
provideCid
,
0
)
prov
,
ok
:=
<-
provChan
if
!
ok
||
prov
.
ID
==
""
{
return
fmt
.
Errorf
(
"Expected provider. stream closed early"
)
}
if
len
(
provs
)
!=
1
{
return
fmt
.
Errorf
(
"Expected one provider, got %d"
,
len
(
provs
))
}
if
provs
[
0
]
.
ID
!=
lanPeers
[
i
]
.
Identity
{
if
prov
.
ID
!=
lanPeers
[
i
]
.
Identity
{
return
fmt
.
Errorf
(
"Unexpected lan peer provided record"
)
}
// Now, bootstrap from a wan peer.
for
_
,
p
:=
range
wanPeers
{
if
_
,
err
:=
mn
.
LinkPeers
(
testPeer
.
Identity
,
p
.
Identity
);
err
!=
nil
{
return
err
}
}
bis
:=
wanPeers
[
0
]
.
Peerstore
.
PeerInfo
(
wanPeers
[
0
]
.
PeerHost
.
ID
())
bcfg
:=
bootstrap
.
BootstrapConfigWithPeers
([]
peer
.
AddrInfo
{
bis
})
if
err
:=
testPeer
.
Bootstrap
(
bcfg
);
err
!=
nil
{
return
err
}
err
,
done
=
<-
testPeer
.
DHT
.
RefreshRoutingTable
()
err
,
done
=
<-
testPeer
.
DHT
.
WAN
.
RefreshRoutingTable
()
if
err
!=
nil
||
!
done
{
if
!
done
{
err
=
fmt
.
Errorf
(
"expected refresh routing table to close"
)
...
...
@@ -188,14 +204,12 @@ func RunDHTConnectivity(conf testutil.LatencyConfig, numPeers int) error {
if
err
:=
wanPeers
[
i
]
.
DHT
.
Provide
(
wanProvideCtx
,
wanCid
,
true
);
err
!=
nil
{
return
err
}
provs
,
err
=
testPeer
.
DHT
.
FindProviders
(
wanProvideCtx
,
wanCid
)
if
err
!=
nil
{
return
err
provChan
=
testPeer
.
DHT
.
FindProvidersAsync
(
wanProvideCtx
,
wanCid
,
0
)
prov
,
ok
=
<-
provChan
if
!
ok
||
prov
.
ID
==
""
{
return
fmt
.
Errorf
(
"Expected one provider, closed early"
)
}
if
len
(
provs
)
!=
1
{
return
fmt
.
Errorf
(
"Expected one provider, got %d"
,
len
(
provs
))
}
if
provs
[
0
]
.
ID
!=
wanPeers
[
i
]
.
Identity
{
if
prov
.
ID
!=
wanPeers
[
i
]
.
Identity
{
return
fmt
.
Errorf
(
"Unexpected lan peer provided record"
)
}
...
...
@@ -211,12 +225,14 @@ func RunDHTConnectivity(conf testutil.LatencyConfig, numPeers int) error {
if
err
:=
wanPeers
[
i
]
.
DHT
.
Provide
(
provideCtx
,
provideCid
,
true
);
err
!=
nil
{
return
err
}
provs
,
err
=
testPeer
.
DHT
.
FindProviders
(
provideCtx
,
provideCid
)
if
err
!=
nil
{
return
err
provChan
=
testPeer
.
DHT
.
FindProvidersAsync
(
provideCtx
,
provideCid
,
0
)
prov
,
ok
=
<-
provChan
if
!
ok
{
return
fmt
.
Errorf
(
"Expected two providers, got 0"
)
}
if
len
(
provs
)
!=
2
{
return
fmt
.
Errorf
(
"Expected two providers, got %d"
,
len
(
provs
))
prov
,
ok
=
<-
provChan
if
!
ok
{
return
fmt
.
Errorf
(
"Expected two providers, got 1"
)
}
return
nil
...
...
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