Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mybee
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
vicotor
mybee
Commits
95d497f3
Unverified
Commit
95d497f3
authored
Apr 07, 2020
by
Petar Radovic
Committed by
GitHub
Apr 07, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Hive tests fix - expect values eventually (#71)
* hive tests fix * tests name in hive tests
parent
6e9510b1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
90 additions
and
70 deletions
+90
-70
go.sum
go.sum
+7
-0
hive_test.go
pkg/hive/hive_test.go
+83
-70
No files found.
go.sum
View file @
95d497f3
...
@@ -110,6 +110,7 @@ github.com/hashicorp/golang-lru v0.5.1 h1:0hERBMJE1eitiLkihrMvRVBYAkpHzc/J3QdDN+
...
@@ -110,6 +110,7 @@ github.com/hashicorp/golang-lru v0.5.1 h1:0hERBMJE1eitiLkihrMvRVBYAkpHzc/J3QdDN+
github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI=
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
github.com/huin/goupnp v1.0.0 h1:wg75sLpL6DZqwHQN6E1Cfk6mtfzS45z8OV+ic+DtHRo=
github.com/huin/goupnp v1.0.0 h1:wg75sLpL6DZqwHQN6E1Cfk6mtfzS45z8OV+ic+DtHRo=
github.com/huin/goupnp v1.0.0/go.mod h1:n9v9KO1tAxYH82qOn+UTIFQDmx5n1Zxd/ClZDMX7Bnc=
github.com/huin/goupnp v1.0.0/go.mod h1:n9v9KO1tAxYH82qOn+UTIFQDmx5n1Zxd/ClZDMX7Bnc=
...
@@ -232,6 +233,7 @@ github.com/libp2p/go-libp2p-testing v0.0.2/go.mod h1:gvchhf3FQOtBdr+eFUABet5a4MB
...
@@ -232,6 +233,7 @@ github.com/libp2p/go-libp2p-testing v0.0.2/go.mod h1:gvchhf3FQOtBdr+eFUABet5a4MB
github.com/libp2p/go-libp2p-testing v0.0.3/go.mod h1:gvchhf3FQOtBdr+eFUABet5a4MBLK8jM3V4Zghvmi+E=
github.com/libp2p/go-libp2p-testing v0.0.3/go.mod h1:gvchhf3FQOtBdr+eFUABet5a4MBLK8jM3V4Zghvmi+E=
github.com/libp2p/go-libp2p-testing v0.0.4/go.mod h1:gvchhf3FQOtBdr+eFUABet5a4MBLK8jM3V4Zghvmi+E=
github.com/libp2p/go-libp2p-testing v0.0.4/go.mod h1:gvchhf3FQOtBdr+eFUABet5a4MBLK8jM3V4Zghvmi+E=
github.com/libp2p/go-libp2p-testing v0.1.0/go.mod h1:xaZWMJrPUM5GlDBxCeGUi7kI4eqnjVyavGroI2nxEM0=
github.com/libp2p/go-libp2p-testing v0.1.0/go.mod h1:xaZWMJrPUM5GlDBxCeGUi7kI4eqnjVyavGroI2nxEM0=
github.com/libp2p/go-libp2p-testing v0.1.1 h1:U03z3HnGI7Ni8Xx6ONVZvUFOAzWYmolWf5W5jAOPNmU=
github.com/libp2p/go-libp2p-testing v0.1.1/go.mod h1:xaZWMJrPUM5GlDBxCeGUi7kI4eqnjVyavGroI2nxEM0=
github.com/libp2p/go-libp2p-testing v0.1.1/go.mod h1:xaZWMJrPUM5GlDBxCeGUi7kI4eqnjVyavGroI2nxEM0=
github.com/libp2p/go-libp2p-tls v0.1.1 h1:tjW7njTM8JX8FbEvqr8/VSKBdZYZ7CtGtv3i6NiFf10=
github.com/libp2p/go-libp2p-tls v0.1.1 h1:tjW7njTM8JX8FbEvqr8/VSKBdZYZ7CtGtv3i6NiFf10=
github.com/libp2p/go-libp2p-tls v0.1.1/go.mod h1:wZfuewxOndz5RTnCAxFliGjvYSDA40sKitV4c50uI1M=
github.com/libp2p/go-libp2p-tls v0.1.1/go.mod h1:wZfuewxOndz5RTnCAxFliGjvYSDA40sKitV4c50uI1M=
...
@@ -351,9 +353,11 @@ github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn
...
@@ -351,9 +353,11 @@ github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v1.8.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v1.8.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v1.11.0 h1:JAKSXpt1YjtLA7YpPiqO9ss6sNXEsPfSGdwN0UHqzrw=
github.com/onsi/ginkgo v1.11.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/ginkgo v1.11.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
github.com/onsi/gomega v1.5.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
github.com/onsi/gomega v1.5.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY=
github.com/onsi/gomega v1.8.1 h1:C5Dqfs/LeauYDX0jJXIe2SWmwCbGzx9yF8C8xy3Lh34=
github.com/onsi/gomega v1.8.1/go.mod h1:Ho0h+IUsWyvy1OpqCwxlQ/21gkhVunqlU8fDGcoTdcA=
github.com/onsi/gomega v1.8.1/go.mod h1:Ho0h+IUsWyvy1OpqCwxlQ/21gkhVunqlU8fDGcoTdcA=
github.com/opentracing/opentracing-go v1.0.2 h1:3jA2P6O1F9UOrWVpwrIo17pu01KWvNWg4X946/Y5Zwg=
github.com/opentracing/opentracing-go v1.0.2 h1:3jA2P6O1F9UOrWVpwrIo17pu01KWvNWg4X946/Y5Zwg=
github.com/opentracing/opentracing-go v1.0.2/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o=
github.com/opentracing/opentracing-go v1.0.2/go.mod h1:UkNAQd3GIcIGf0SeVgPpRdFStlNbqXla1AfSYxPUl2o=
...
@@ -540,6 +544,7 @@ golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3
...
@@ -540,6 +544,7 @@ golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3
golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
...
@@ -559,6 +564,7 @@ gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc/go.mod
...
@@ -559,6 +564,7 @@ gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc/go.mod
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4=
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
gopkg.in/ini.v1 v1.51.0 h1:AQvPpx3LzTDM0AjnIRlVFwFFGC+npRopjZxLJj6gdno=
gopkg.in/ini.v1 v1.51.0 h1:AQvPpx3LzTDM0AjnIRlVFwFFGC+npRopjZxLJj6gdno=
gopkg.in/ini.v1 v1.51.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
gopkg.in/ini.v1 v1.51.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
...
@@ -567,6 +573,7 @@ gopkg.in/mail.v2 v2.3.1/go.mod h1:htwXN1Qh09vZJ1NVKxQqHPBaCBbzKhp5GzuJEA4VJWw=
...
@@ -567,6 +573,7 @@ gopkg.in/mail.v2 v2.3.1/go.mod h1:htwXN1Qh09vZJ1NVKxQqHPBaCBbzKhp5GzuJEA4VJWw=
gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo=
gopkg.in/resty.v1 v1.12.0/go.mod h1:mDo4pnntr5jdWRML875a/NmxYqAlA73dVijT2AXvQQo=
gopkg.in/src-d/go-cli.v0 v0.0.0-20181105080154-d492247bbc0d/go.mod h1:z+K8VcOYVYcSwSjGebuDL6176A1XskgbtNl64NSg+n8=
gopkg.in/src-d/go-cli.v0 v0.0.0-20181105080154-d492247bbc0d/go.mod h1:z+K8VcOYVYcSwSjGebuDL6176A1XskgbtNl64NSg+n8=
gopkg.in/src-d/go-log.v1 v1.0.1/go.mod h1:GN34hKP0g305ysm2/hctJ0Y8nWP3zxXXJ8GFabTyABE=
gopkg.in/src-d/go-log.v1 v1.0.1/go.mod h1:GN34hKP0g305ysm2/hctJ0Y8nWP3zxXXJ8GFabTyABE=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74=
gopkg.in/yaml.v2 v2.0.0-20170812160011-eb3733d160e7/go.mod h1:JAlM8MvJe8wmxCU4Bli9HhUf9+ttbYbLASfIpnQbh74=
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
...
...
pkg/hive/hive_test.go
View file @
95d497f3
...
@@ -103,97 +103,110 @@ func TestBroadcastPeers(t *testing.T) {
...
@@ -103,97 +103,110 @@ func TestBroadcastPeers(t *testing.T) {
},
},
}
}
for
_
,
tc
:=
range
testCases
{
for
name
,
tc
:=
range
testCases
{
addressbookclean
:=
inmem
.
New
()
t
.
Run
(
name
,
func
(
t
*
testing
.
T
)
{
exporter
,
ok
:=
addressbookclean
.
(
AddressExporter
)
addressbookclean
:=
inmem
.
New
()
if
!
ok
{
exporter
,
ok
:=
addressbookclean
.
(
AddressExporter
)
t
.
Fatal
(
"could not type assert AddressExporter"
)
if
!
ok
{
}
t
.
Fatal
(
"could not type assert AddressExporter"
)
}
// create a hive server that handles the incoming stream
server
:=
hive
.
New
(
hive
.
Options
{
Logger
:
logger
,
AddressBook
:
addressbookclean
,
})
// setup the stream recorder to record stream data
recorder
:=
streamtest
.
New
(
streamtest
.
WithProtocols
(
server
.
Protocol
()),
)
// create a hive client that will do broadcast
client
:=
hive
.
New
(
hive
.
Options
{
Streamer
:
recorder
,
Logger
:
logger
,
AddressBook
:
addressbook
,
})
if
err
:=
client
.
BroadcastPeers
(
context
.
Background
(),
tc
.
addresee
,
tc
.
peers
...
);
err
!=
nil
{
t
.
Fatal
(
err
)
}
// get a record for this stream
// create a hive server that handles the incoming stream
records
,
err
:=
recorder
.
Records
(
tc
.
addresee
,
"hive"
,
"1.0.0"
,
"peers"
)
server
:=
hive
.
New
(
hive
.
Options
{
if
err
!=
nil
{
Logger
:
logger
,
t
.
Fatal
(
err
)
AddressBook
:
addressbookclean
,
}
})
if
l
:=
len
(
records
);
l
!=
len
(
tc
.
wantMsgs
)
{
t
.
Fatalf
(
"got %v records, want %v"
,
l
,
len
(
tc
.
wantMsgs
))
// setup the stream recorder to record stream data
}
recorder
:=
streamtest
.
New
(
streamtest
.
WithProtocols
(
server
.
Protocol
()),
)
// create a hive client that will do broadcast
client
:=
hive
.
New
(
hive
.
Options
{
Streamer
:
recorder
,
Logger
:
logger
,
AddressBook
:
addressbook
,
})
if
err
:=
client
.
BroadcastPeers
(
context
.
Background
(),
tc
.
addresee
,
tc
.
peers
...
);
err
!=
nil
{
t
.
Fatal
(
err
)
}
// there is a one record per batch (wantMsg)
// get a record for this stream
for
i
,
record
:=
range
records
{
records
,
err
:=
recorder
.
Records
(
tc
.
addresee
,
"hive"
,
"1.0.0"
,
"peers"
)
messages
,
err
:=
readAndAssertPeersMsgs
(
record
.
In
(),
1
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatal
(
err
)
t
.
Fatal
(
err
)
}
}
if
l
:=
len
(
records
);
l
!=
len
(
tc
.
wantMsgs
)
{
t
.
Fatalf
(
"got %v records, want %v"
,
l
,
len
(
tc
.
wantMsgs
))
}
if
fmt
.
Sprint
(
messages
[
0
])
!=
fmt
.
Sprint
(
tc
.
wantMsgs
[
i
])
{
// there is a one record per batch (wantMsg)
t
.
Errorf
(
"Messages got %v, want %v"
,
messages
,
tc
.
wantMsgs
)
for
i
,
record
:=
range
records
{
messages
,
err
:=
readAndAssertPeersMsgs
(
record
.
In
(),
1
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
if
fmt
.
Sprint
(
messages
[
0
])
!=
fmt
.
Sprint
(
tc
.
wantMsgs
[
i
])
{
t
.
Errorf
(
"Messages got %v, want %v"
,
messages
,
tc
.
wantMsgs
)
}
}
}
expectOverlaysEventually
(
t
,
exporter
,
tc
.
wantOverlays
)
expectMultiaddresessEventually
(
t
,
exporter
,
tc
.
wantMultiAddresses
)
})
}
}
func
expectOverlaysEventually
(
t
*
testing
.
T
,
exporter
AddressExporter
,
wantOverlays
[]
swarm
.
Address
)
{
for
i
:=
0
;
i
<
100
;
i
++
{
var
stringOverlays
[]
string
var
stringWantOverlays
[]
string
for
_
,
k
:=
range
exporter
.
Overlays
()
{
stringOverlays
=
append
(
stringOverlays
,
k
.
String
())
}
}
if
!
compareOverlays
(
exporter
.
Overlays
(),
tc
.
wantOverlays
)
{
for
_
,
k
:=
range
wantOverlays
{
t
.
Errorf
(
"Overlays got %v, want %v"
,
exporter
.
Overlays
(),
tc
.
wantOverlays
)
stringWantOverlays
=
append
(
stringWantOverlays
,
k
.
String
()
)
}
}
if
!
compareMultiaddrses
(
exporter
.
Multiaddresses
(),
tc
.
wantMultiAddresses
)
{
sort
.
Strings
(
stringOverlays
)
t
.
Errorf
(
"Multiaddresses got %v, want %v"
,
exporter
.
Multiaddresses
(),
tc
.
wantMultiAddresses
)
sort
.
Strings
(
stringWantOverlays
)
if
reflect
.
DeepEqual
(
stringOverlays
,
stringWantOverlays
)
{
return
}
}
time
.
Sleep
(
50
*
time
.
Millisecond
)
}
}
t
.
Errorf
(
"Overlays got %v, want %v"
,
exporter
.
Overlays
(),
wantOverlays
)
}
}
func
compareOverlays
(
keys
[]
swarm
.
Address
,
wantKeys
[]
swarm
.
Address
)
bool
{
func
expectMultiaddresessEventually
(
t
*
testing
.
T
,
exporter
AddressExporter
,
wantMultiaddresses
[]
ma
.
Multiaddr
)
{
var
stringKeys
[]
string
for
i
:=
0
;
i
<
100
;
i
++
{
for
_
,
k
:=
range
keys
{
var
stringMultiaddresses
[]
string
stringKeys
=
append
(
stringKeys
,
k
.
String
())
for
_
,
v
:=
range
exporter
.
Multiaddresses
()
{
}
stringMultiaddresses
=
append
(
stringMultiaddresses
,
v
.
String
())
}
var
stringWantKeys
[]
string
for
_
,
k
:=
range
wantKeys
{
stringWantKeys
=
append
(
stringWantKeys
,
k
.
String
())
}
sort
.
Strings
(
stringKeys
)
var
stringWantMultiAddresses
[]
string
sort
.
Strings
(
stringWantKeys
)
for
_
,
v
:=
range
wantMultiaddresses
{
return
reflect
.
DeepEqual
(
stringKeys
,
stringWantKeys
)
stringWantMultiAddresses
=
append
(
stringWantMultiAddresses
,
v
.
String
()
)
}
}
func
compareMultiaddrses
(
values
[]
ma
.
Multiaddr
,
wantValues
[]
ma
.
Multiaddr
)
bool
{
sort
.
Strings
(
stringMultiaddresses
)
var
stringVal
[]
string
sort
.
Strings
(
stringWantMultiAddresses
)
for
_
,
v
:=
range
values
{
if
reflect
.
DeepEqual
(
stringMultiaddresses
,
stringWantMultiAddresses
)
{
stringVal
=
append
(
stringVal
,
v
.
String
())
return
}
}
var
stringWantVal
[]
string
time
.
Sleep
(
50
*
time
.
Millisecond
)
for
_
,
v
:=
range
wantValues
{
stringWantVal
=
append
(
stringWantVal
,
v
.
String
())
}
}
sort
.
Strings
(
stringVal
)
t
.
Errorf
(
"Multiaddresses got %v, want %v"
,
exporter
.
Multiaddresses
(),
wantMultiaddresses
)
sort
.
Strings
(
stringWantVal
)
return
reflect
.
DeepEqual
(
stringVal
,
stringWantVal
)
}
}
func
readAndAssertPeersMsgs
(
in
[]
byte
,
expectedLen
int
)
([]
pb
.
Peers
,
error
)
{
func
readAndAssertPeersMsgs
(
in
[]
byte
,
expectedLen
int
)
([]
pb
.
Peers
,
error
)
{
...
...
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