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
88e67c55
Commit
88e67c55
authored
Dec 31, 2017
by
croath
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
accounts/abi: add a test case for unpacking mobile interfaces
parent
e7cd627d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
0 deletions
+36
-0
unpack_test.go
accounts/abi/unpack_test.go
+36
-0
No files found.
accounts/abi/unpack_test.go
View file @
88e67c55
...
...
@@ -287,6 +287,42 @@ func TestUnpack(t *testing.T) {
}
}
var
unpackMobileTests
=
[]
unpackTest
{
{
def
:
`[{"type": "uint256"}]`
,
enc
:
"0000000000000000000000000000000000000000000000000000000000000001"
,
want
:
big
.
NewInt
(
1
),
},
}
func
TestUnpackMobileOnly
(
t
*
testing
.
T
)
{
for
i
,
test
:=
range
unpackMobileTests
{
t
.
Run
(
strconv
.
Itoa
(
i
),
func
(
t
*
testing
.
T
)
{
def
:=
fmt
.
Sprintf
(
`[{ "name" : "method", "outputs": %s}]`
,
test
.
def
)
abi
,
err
:=
JSON
(
strings
.
NewReader
(
def
))
if
err
!=
nil
{
t
.
Fatalf
(
"invalid ABI definition %s: %v"
,
def
,
err
)
}
encb
,
err
:=
hex
.
DecodeString
(
test
.
enc
)
if
err
!=
nil
{
t
.
Fatalf
(
"invalid hex: %s"
+
test
.
enc
)
}
outptr
:=
reflect
.
New
(
reflect
.
TypeOf
(
test
.
want
))
results
:=
make
([]
interface
{},
1
)
copy
(
results
,
[]
interface
{}{
outptr
.
Interface
()})
err
=
abi
.
Unpack
(
&
results
,
"method"
,
encb
)
if
err
:=
test
.
checkError
(
err
);
err
!=
nil
{
t
.
Errorf
(
"test %d (%v) failed: %v"
,
i
,
test
.
def
,
err
)
return
}
out
:=
outptr
.
Elem
()
.
Interface
()
if
!
reflect
.
DeepEqual
(
test
.
want
,
out
)
{
t
.
Errorf
(
"test %d (%v) failed: expected %v, got %v"
,
i
,
test
.
def
,
test
.
want
,
out
)
}
})
}
}
type
methodMultiOutput
struct
{
Int
*
big
.
Int
String
string
...
...
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