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
4d8c4439
Commit
4d8c4439
authored
Dec 15, 2017
by
Steven Allen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
improve basic bitswap test
License: MIT Signed-off-by:
Steven Allen
<
steven@stebalien.com
>
parent
9db5471e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
9 deletions
+16
-9
exchange/bitswap/bitswap_test.go
exchange/bitswap/bitswap_test.go
+16
-9
No files found.
exchange/bitswap/bitswap_test.go
View file @
4d8c4439
...
...
@@ -292,23 +292,22 @@ func TestEmptyKey(t *testing.T) {
}
}
func
assertStat
(
st
*
Stat
,
sblks
,
rblks
,
sdata
,
rdata
uint64
)
error
{
func assertStat(
t *testing.T,
st *Stat, sblks, rblks, sdata, rdata uint64) {
if sblks != st.BlocksSent {
return
fm
t
.
Errorf
(
"mismatch in blocks sent: %d vs %d"
,
sblks
,
st
.
BlocksSent
)
t.Errorf("mismatch in blocks sent: %d vs %d", sblks, st.BlocksSent)
}
if rblks != st.BlocksReceived {
return
fm
t
.
Errorf
(
"mismatch in blocks recvd: %d vs %d"
,
rblks
,
st
.
BlocksReceived
)
t.Errorf("mismatch in blocks recvd: %d vs %d", rblks, st.BlocksReceived)
}
if sdata != st.DataSent {
return
fm
t
.
Errorf
(
"mismatch in data sent: %d vs %d"
,
sdata
,
st
.
DataSent
)
t.Errorf("mismatch in data sent: %d vs %d", sdata, st.DataSent)
}
if rdata != st.DataReceived {
return
fm
t
.
Errorf
(
"mismatch in data recvd: %d vs %d"
,
rdata
,
st
.
DataReceived
)
t.Errorf("mismatch in data recvd: %d vs %d", rdata, st.DataReceived)
}
return
nil
}
func TestBasicBitswap(t *testing.T) {
...
...
@@ -355,12 +354,20 @@ func TestBasicBitswap(t *testing.T) {
t.Fatal(err)
}
if
err
:=
assertStat
(
st0
,
1
,
0
,
1
,
0
);
err
!=
nil
{
st2, err := instances[2].Exchange.Stat()
if err != nil {
t.Fatal(err)
}
if
err
:=
assertStat
(
st1
,
0
,
1
,
0
,
1
);
err
!=
nil
{
t
.
Fatal
(
err
)
t.Log("stat node 0")
assertStat(t, st0, 1, 0, uint64(len(blk.RawData())), 0)
t.Log("stat node 1")
assertStat(t, st1, 0, 1, 0, uint64(len(blk.RawData())))
t.Log("stat node 2")
assertStat(t, st2, 0, 0, 0, 0)
if !bytes.Equal(blk.RawData(), blocks[0].RawData()) {
t.Errorf("blocks aren't equal: expected %v, actual %v", blocks[0].RawData(), blk.RawData())
}
t.Log(blk)
...
...
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