good morning!!!!
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
bor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
open
bor
Commits
ad8d519e
Commit
ad8d519e
authored
Jul 16, 2017
by
Jim McDonald
Browse files
Options
Downloads
Patches
Plain Diff
common: tests for EIP55-compliant Address.Hex()
parent
9e80d9be
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
common/types_test.go
+31
-0
31 additions, 0 deletions
common/types_test.go
with
31 additions
and
0 deletions
common/types_test.go
+
31
−
0
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
()
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment