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
fda4d02f
Commit
fda4d02f
authored
Mar 10, 2015
by
Taylor Gerring
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Left-pad odd length hex inputs and tests
parent
35841e51
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
0 deletions
+28
-0
util.go
rpc/util.go
+3
-0
util_test.go
rpc/util_test.go
+25
-0
No files found.
rpc/util.go
View file @
fda4d02f
...
...
@@ -132,6 +132,9 @@ func fromHex(s string) []byte {
if
s
[
0
:
2
]
==
"0x"
{
s
=
s
[
2
:
]
}
if
len
(
s
)
%
2
==
1
{
s
=
"0"
+
s
}
return
ethutil
.
Hex2Bytes
(
s
)
}
return
nil
...
...
rpc/util_test.go
0 → 100644
View file @
fda4d02f
package
rpc
import
(
"bytes"
"testing"
)
//fromHex
func
TestFromHex
(
t
*
testing
.
T
)
{
input
:=
"0x01"
expected
:=
[]
byte
{
1
}
result
:=
fromHex
(
input
)
if
bytes
.
Compare
(
expected
,
result
)
!=
0
{
t
.
Errorf
(
"Expected % x got % x"
,
expected
,
result
)
}
}
func
TestFromHexOddLength
(
t
*
testing
.
T
)
{
input
:=
"0x1"
expected
:=
[]
byte
{
1
}
result
:=
fromHex
(
input
)
if
bytes
.
Compare
(
expected
,
result
)
!=
0
{
t
.
Errorf
(
"Expected % x got % x"
,
expected
,
result
)
}
}
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