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
c3d52504
Commit
c3d52504
authored
Apr 20, 2016
by
Jeffrey Wilcke
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
accounts/abi: added unpacking "anything" in to interface{}
parent
e0dc45fc
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
0 deletions
+11
-0
abi.go
accounts/abi/abi.go
+2
-0
abi_test.go
accounts/abi/abi_test.go
+9
-0
No files found.
accounts/abi/abi.go
View file @
c3d52504
...
@@ -316,6 +316,8 @@ func set(dst, src reflect.Value, output Argument) error {
...
@@ -316,6 +316,8 @@ func set(dst, src reflect.Value, output Argument) error {
return
fmt
.
Errorf
(
"abi: cannot unmarshal src (len=%d) in to dst (len=%d)"
,
output
.
Type
.
SliceSize
,
dst
.
Len
())
return
fmt
.
Errorf
(
"abi: cannot unmarshal src (len=%d) in to dst (len=%d)"
,
output
.
Type
.
SliceSize
,
dst
.
Len
())
}
}
reflect
.
Copy
(
dst
,
src
)
reflect
.
Copy
(
dst
,
src
)
case
dstType
.
Kind
()
==
reflect
.
Interface
:
dst
.
Set
(
src
)
default
:
default
:
return
fmt
.
Errorf
(
"abi: cannot unmarshal %v in to %v"
,
src
.
Type
(),
dst
.
Type
())
return
fmt
.
Errorf
(
"abi: cannot unmarshal %v in to %v"
,
src
.
Type
(),
dst
.
Type
())
}
}
...
...
accounts/abi/abi_test.go
View file @
c3d52504
...
@@ -161,6 +161,13 @@ func TestSimpleMethodUnpack(t *testing.T) {
...
@@ -161,6 +161,13 @@ func TestSimpleMethodUnpack(t *testing.T) {
"hash"
,
"hash"
,
nil
,
nil
,
},
},
{
`[ { "type": "bytes32" } ]`
,
pad
([]
byte
{
1
},
32
,
false
),
pad
([]
byte
{
1
},
32
,
false
),
"interface"
,
nil
,
},
}
{
}
{
abiDefinition
:=
fmt
.
Sprintf
(
`[{ "name" : "method", "outputs": %s}]`
,
test
.
def
)
abiDefinition
:=
fmt
.
Sprintf
(
`[{ "name" : "method", "outputs": %s}]`
,
test
.
def
)
abi
,
err
:=
JSON
(
strings
.
NewReader
(
abiDefinition
))
abi
,
err
:=
JSON
(
strings
.
NewReader
(
abiDefinition
))
...
@@ -203,6 +210,8 @@ func TestSimpleMethodUnpack(t *testing.T) {
...
@@ -203,6 +210,8 @@ func TestSimpleMethodUnpack(t *testing.T) {
var
v
common
.
Hash
var
v
common
.
Hash
err
=
abi
.
Unpack
(
&
v
,
"method"
,
test
.
marshalledOutput
)
err
=
abi
.
Unpack
(
&
v
,
"method"
,
test
.
marshalledOutput
)
outvar
=
v
outvar
=
v
case
"interface"
:
err
=
abi
.
Unpack
(
&
outvar
,
"method"
,
test
.
marshalledOutput
)
default
:
default
:
t
.
Errorf
(
"unsupported type '%v' please add it to the switch statement in this test"
,
test
.
outVar
)
t
.
Errorf
(
"unsupported type '%v' please add it to the switch statement in this test"
,
test
.
outVar
)
continue
continue
...
...
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