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
b33a5294
Unverified
Commit
b33a5294
authored
Nov 29, 2017
by
Péter Szilágyi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
common: fix hex utils to handle 1 byte address conversions
parent
be12392f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
7 deletions
+15
-7
bytes.go
common/bytes.go
+4
-5
bytes_test.go
common/bytes_test.go
+11
-2
No files found.
common/bytes.go
View file @
b33a5294
...
...
@@ -35,12 +35,11 @@ func FromHex(s string) []byte {
if
s
[
0
:
2
]
==
"0x"
||
s
[
0
:
2
]
==
"0X"
{
s
=
s
[
2
:
]
}
if
len
(
s
)
%
2
==
1
{
s
=
"0"
+
s
}
return
Hex2Bytes
(
s
)
}
return
nil
if
len
(
s
)
%
2
==
1
{
s
=
"0"
+
s
}
return
Hex2Bytes
(
s
)
}
// Copy bytes
...
...
common/bytes_test.go
View file @
b33a5294
...
...
@@ -74,7 +74,7 @@ func TestFromHex(t *testing.T) {
expected
:=
[]
byte
{
1
}
result
:=
FromHex
(
input
)
if
!
bytes
.
Equal
(
expected
,
result
)
{
t
.
Errorf
(
"Expected %
x got %
x"
,
expected
,
result
)
t
.
Errorf
(
"Expected %
x got %
x"
,
expected
,
result
)
}
}
...
...
@@ -83,6 +83,15 @@ func TestFromHexOddLength(t *testing.T) {
expected
:=
[]
byte
{
1
}
result
:=
FromHex
(
input
)
if
!
bytes
.
Equal
(
expected
,
result
)
{
t
.
Errorf
(
"Expected % x got % x"
,
expected
,
result
)
t
.
Errorf
(
"Expected %x got %x"
,
expected
,
result
)
}
}
func
TestNoPrefixShortHexOddLength
(
t
*
testing
.
T
)
{
input
:=
"1"
expected
:=
[]
byte
{
1
}
result
:=
FromHex
(
input
)
if
!
bytes
.
Equal
(
expected
,
result
)
{
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