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
20b818d2
Commit
20b818d2
authored
Aug 24, 2017
by
Péter Szilágyi
Committed by
GitHub
Aug 24, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #15029 from karalabe/rlp-raw-decode
rlp: fix decoding long strings into RawValue types
parents
3c48a257
63246e25
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
11 deletions
+26
-11
decode.go
rlp/decode.go
+1
-1
decode_test.go
rlp/decode_test.go
+25
-10
No files found.
rlp/decode.go
View file @
20b818d2
...
...
@@ -693,7 +693,7 @@ func (s *Stream) Raw() ([]byte, error) {
return
nil
,
err
}
if
kind
==
String
{
puthead
(
buf
,
0x80
,
0xB
8
,
size
)
puthead
(
buf
,
0x80
,
0xB
7
,
size
)
}
else
{
puthead
(
buf
,
0xC0
,
0xF7
,
size
)
}
...
...
rlp/decode_test.go
View file @
20b818d2
...
...
@@ -256,16 +256,31 @@ func TestStreamList(t *testing.T) {
}
func
TestStreamRaw
(
t
*
testing
.
T
)
{
s
:=
NewStream
(
bytes
.
NewReader
(
unhex
(
"C58401010101"
)),
0
)
s
.
List
()
want
:=
unhex
(
"8401010101"
)
raw
,
err
:=
s
.
Raw
()
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
if
!
bytes
.
Equal
(
want
,
raw
)
{
t
.
Errorf
(
"raw mismatch: got %x, want %x"
,
raw
,
want
)
tests
:=
[]
struct
{
input
string
output
string
}{
{
"C58401010101"
,
"8401010101"
,
},
{
"F842B84001010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101"
,
"B84001010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101010101"
,
},
}
for
i
,
tt
:=
range
tests
{
s
:=
NewStream
(
bytes
.
NewReader
(
unhex
(
tt
.
input
)),
0
)
s
.
List
()
want
:=
unhex
(
tt
.
output
)
raw
,
err
:=
s
.
Raw
()
if
err
!=
nil
{
t
.
Fatal
(
err
)
}
if
!
bytes
.
Equal
(
want
,
raw
)
{
t
.
Errorf
(
"test %d: raw mismatch: got %x, want %x"
,
i
,
raw
,
want
)
}
}
}
...
...
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