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
p2p
go-p2p-kad-dht
Commits
81771537
Commit
81771537
authored
Jan 11, 2018
by
Steven Allen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add test case for cleanRecord function
parent
1cb007e8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
65 additions
and
0 deletions
+65
-0
handlers_test.go
handlers_test.go
+65
-0
No files found.
handlers_test.go
0 → 100644
View file @
81771537
package
dht
import
(
"bytes"
"testing"
proto
"github.com/gogo/protobuf/proto"
recpb
"github.com/libp2p/go-libp2p-record/pb"
)
func
TestCleanRecordSigned
(
t
*
testing
.
T
)
{
actual
:=
new
(
recpb
.
Record
)
actual
.
TimeReceived
=
proto
.
String
(
"time"
)
actual
.
XXX_unrecognized
=
[]
byte
(
"extra data"
)
actual
.
Signature
=
[]
byte
(
"signature"
)
actual
.
Author
=
proto
.
String
(
"author"
)
actual
.
Value
=
[]
byte
(
"value"
)
actual
.
Key
=
proto
.
String
(
"key"
)
cleanRecord
(
actual
)
actualBytes
,
err
:=
proto
.
Marshal
(
actual
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
expected
:=
new
(
recpb
.
Record
)
expected
.
Signature
=
[]
byte
(
"signature"
)
expected
.
Author
=
proto
.
String
(
"author"
)
expected
.
Value
=
[]
byte
(
"value"
)
expected
.
Key
=
proto
.
String
(
"key"
)
expectedBytes
,
err
:=
proto
.
Marshal
(
expected
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
if
!
bytes
.
Equal
(
actualBytes
,
expectedBytes
)
{
t
.
Error
(
"failed to clean record"
)
}
}
func
TestCleanRecord
(
t
*
testing
.
T
)
{
actual
:=
new
(
recpb
.
Record
)
actual
.
TimeReceived
=
proto
.
String
(
"time"
)
actual
.
XXX_unrecognized
=
[]
byte
(
"extra data"
)
actual
.
Key
=
proto
.
String
(
"key"
)
actual
.
Value
=
[]
byte
(
"value"
)
cleanRecord
(
actual
)
actualBytes
,
err
:=
proto
.
Marshal
(
actual
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
expected
:=
new
(
recpb
.
Record
)
expected
.
Key
=
proto
.
String
(
"key"
)
expected
.
Value
=
[]
byte
(
"value"
)
expectedBytes
,
err
:=
proto
.
Marshal
(
expected
)
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
if
!
bytes
.
Equal
(
actualBytes
,
expectedBytes
)
{
t
.
Error
(
"failed to clean record"
)
}
}
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