Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
张蕾
Geth-Modification
Commits
0747aa3a
Commit
0747aa3a
authored
Dec 29, 2013
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removed logs from tests and updated rlp encoding to include byte slices
parent
74bc4511
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
8 deletions
+6
-8
rlp.go
rlp.go
+1
-1
rlp_test.go
rlp_test.go
+5
-7
No files found.
rlp.go
View file @
0747aa3a
...
@@ -132,7 +132,7 @@ func Encode(object interface{}) []byte {
...
@@ -132,7 +132,7 @@ func Encode(object interface{}) []byte {
case
[]
byte
:
case
[]
byte
:
// Cast the byte slice to a string
// Cast the byte slice to a string
//
buff.Write(Encode(string(t)))
buff
.
Write
(
Encode
(
string
(
t
)))
case
[]
interface
{},
[]
string
:
case
[]
interface
{},
[]
string
:
// Inline function for writing the slice header
// Inline function for writing the slice header
...
...
rlp_test.go
View file @
0747aa3a
...
@@ -7,13 +7,14 @@ import (
...
@@ -7,13 +7,14 @@ import (
func
TestEncode
(
t
*
testing
.
T
)
{
func
TestEncode
(
t
*
testing
.
T
)
{
strRes
:=
"Cdog"
strRes
:=
"Cdog"
bytes
:=
Encode
(
"dog"
)
bytes
:=
Encode
(
"dog"
)
str
:=
string
(
bytes
)
str
:=
string
(
bytes
)
if
str
!=
strRes
{
if
str
!=
strRes
{
t
.
Error
(
fmt
.
Sprintf
(
"Expected %q, got %q"
,
strRes
,
str
))
t
.
Error
(
fmt
.
Sprintf
(
"Expected %q, got %q"
,
strRes
,
str
))
}
}
dec
,
_
:=
Decode
(
bytes
,
0
)
//dec,_ := Decode(bytes, 0)
fmt
.
Printf
(
"raw: %v encoded: %q == %v
\n
"
,
dec
,
str
,
"dog"
)
sliceRes
:=
"
\x83
CdogCgodCcat"
sliceRes
:=
"
\x83
CdogCgodCcat"
strs
:=
[]
string
{
"dog"
,
"god"
,
"cat"
}
strs
:=
[]
string
{
"dog"
,
"god"
,
"cat"
}
...
@@ -23,8 +24,7 @@ func TestEncode(t *testing.T) {
...
@@ -23,8 +24,7 @@ func TestEncode(t *testing.T) {
t
.
Error
(
fmt
.
Sprintf
(
"Expected %q, got %q"
,
sliceRes
,
slice
))
t
.
Error
(
fmt
.
Sprintf
(
"Expected %q, got %q"
,
sliceRes
,
slice
))
}
}
dec
,
_
=
Decode
(
bytes
,
0
)
//dec,_ = Decode(bytes, 0)
fmt
.
Printf
(
"raw: %v encoded: %q == %v
\n
"
,
dec
,
slice
,
strs
)
}
}
func
TestMultiEncode
(
t
*
testing
.
T
)
{
func
TestMultiEncode
(
t
*
testing
.
T
)
{
...
@@ -42,10 +42,8 @@ func TestMultiEncode(t *testing.T) {
...
@@ -42,10 +42,8 @@ func TestMultiEncode(t *testing.T) {
}
}
bytes
:=
Encode
(
inter
)
bytes
:=
Encode
(
inter
)
fmt
.
Printf
(
"%q
\n
"
,
bytes
)
dec
,
_
:=
Decode
(
bytes
,
0
)
Decode
(
bytes
,
0
)
fmt
.
Println
(
dec
)
}
}
func
BenchmarkEncodeDecode
(
b
*
testing
.
B
)
{
func
BenchmarkEncodeDecode
(
b
*
testing
.
B
)
{
...
...
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