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
ad8d519e
Commit
ad8d519e
authored
Jul 16, 2017
by
Jim McDonald
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
common: tests for EIP55-compliant Address.Hex()
parent
9e80d9be
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
0 deletions
+31
-0
types_test.go
common/types_test.go
+31
-0
No files found.
common/types_test.go
View file @
ad8d519e
...
...
@@ -94,3 +94,34 @@ func TestAddressUnmarshalJSON(t *testing.T) {
}
}
}
func
TestAddressHexChecksum
(
t
*
testing
.
T
)
{
var
tests
=
[]
struct
{
Input
string
Output
string
}{
// Test cases from https://github.com/ethereum/EIPs/blob/master/EIPS/eip-55.md#specification
{
"0x5aaeb6053f3e94c9b9a09f33669435e7ef1beaed"
,
"0x5aAeb6053F3E94C9b9A09f33669435E7Ef1BeAed"
},
{
"0xfb6916095ca1df60bb79ce92ce3ea74c37c5d359"
,
"0xfB6916095ca1df60bB79Ce92cE3Ea74c37c5d359"
},
{
"0xdbf03b407c01e7cd3cbea99509d93f8dddc8c6fb"
,
"0xdbF03B407c01E7cD3CBea99509d93f8DDDC8C6FB"
},
{
"0xd1220a0cf47c7b9be7a2e6ba89f429762e7b9adb"
,
"0xD1220A0cf47c7B9Be7A2E6BA89F429762e7b9aDb"
},
// Ensure that non-standard length input values are handled correctly
{
"0xa"
,
"0x000000000000000000000000000000000000000A"
},
{
"0x0a"
,
"0x000000000000000000000000000000000000000A"
},
{
"0x00a"
,
"0x000000000000000000000000000000000000000A"
},
{
"0x000000000000000000000000000000000000000a"
,
"0x000000000000000000000000000000000000000A"
},
}
for
i
,
test
:=
range
tests
{
output
:=
HexToAddress
(
test
.
Input
)
.
Hex
()
if
output
!=
test
.
Output
{
t
.
Errorf
(
"test #%d: failed to match when it should (%s != %s)"
,
i
,
output
,
test
.
Output
)
}
}
}
func
BenchmarkAddressHex
(
b
*
testing
.
B
)
{
testAddr
:=
HexToAddress
(
"0x5aaeb6053f3e94c9b9a09f33669435e7ef1beaed"
)
for
n
:=
0
;
n
<
b
.
N
;
n
++
{
testAddr
.
Hex
()
}
}
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