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
6ab9f0a1
Commit
6ab9f0a1
authored
Apr 04, 2018
by
Ricardo Domingos
Committed by
Felix Lange
Apr 04, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
accounts/abi: improve test coverage (#16044)
parent
7aad81f8
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
82 additions
and
62 deletions
+82
-62
numbers.go
accounts/abi/numbers.go
+18
-18
reflect.go
accounts/abi/reflect.go
+10
-10
type.go
accounts/abi/type.go
+1
-1
type_test.go
accounts/abi/type_test.go
+36
-33
unpack_test.go
accounts/abi/unpack_test.go
+17
-0
No files found.
accounts/abi/numbers.go
View file @
6ab9f0a1
...
...
@@ -25,23 +25,23 @@ import (
)
var
(
big
_t
=
reflect
.
TypeOf
(
&
big
.
Int
{})
derefbig
_t
=
reflect
.
TypeOf
(
big
.
Int
{})
uint8
_t
=
reflect
.
TypeOf
(
uint8
(
0
))
uint16
_t
=
reflect
.
TypeOf
(
uint16
(
0
))
uint32
_t
=
reflect
.
TypeOf
(
uint32
(
0
))
uint64
_t
=
reflect
.
TypeOf
(
uint64
(
0
))
int
_t
=
reflect
.
TypeOf
(
int
(
0
))
int8
_t
=
reflect
.
TypeOf
(
int8
(
0
))
int16
_t
=
reflect
.
TypeOf
(
int16
(
0
))
int32
_t
=
reflect
.
TypeOf
(
int32
(
0
))
int64
_t
=
reflect
.
TypeOf
(
int64
(
0
))
address
_t
=
reflect
.
TypeOf
(
common
.
Address
{})
int
_ts
=
reflect
.
TypeOf
([]
int
(
nil
))
int8
_ts
=
reflect
.
TypeOf
([]
int8
(
nil
))
int16
_ts
=
reflect
.
TypeOf
([]
int16
(
nil
))
int32
_ts
=
reflect
.
TypeOf
([]
int32
(
nil
))
int64
_ts
=
reflect
.
TypeOf
([]
int64
(
nil
))
big
T
=
reflect
.
TypeOf
(
&
big
.
Int
{})
derefbig
T
=
reflect
.
TypeOf
(
big
.
Int
{})
uint8
T
=
reflect
.
TypeOf
(
uint8
(
0
))
uint16
T
=
reflect
.
TypeOf
(
uint16
(
0
))
uint32
T
=
reflect
.
TypeOf
(
uint32
(
0
))
uint64
T
=
reflect
.
TypeOf
(
uint64
(
0
))
int
T
=
reflect
.
TypeOf
(
int
(
0
))
int8
T
=
reflect
.
TypeOf
(
int8
(
0
))
int16
T
=
reflect
.
TypeOf
(
int16
(
0
))
int32
T
=
reflect
.
TypeOf
(
int32
(
0
))
int64
T
=
reflect
.
TypeOf
(
int64
(
0
))
address
T
=
reflect
.
TypeOf
(
common
.
Address
{})
int
TS
=
reflect
.
TypeOf
([]
int
(
nil
))
int8
TS
=
reflect
.
TypeOf
([]
int8
(
nil
))
int16
TS
=
reflect
.
TypeOf
([]
int16
(
nil
))
int32
TS
=
reflect
.
TypeOf
([]
int32
(
nil
))
int64
TS
=
reflect
.
TypeOf
([]
int64
(
nil
))
)
// U256 converts a big Int into a 256bit EVM number.
...
...
@@ -52,7 +52,7 @@ func U256(n *big.Int) []byte {
// checks whether the given reflect value is signed. This also works for slices with a number type
func
isSigned
(
v
reflect
.
Value
)
bool
{
switch
v
.
Type
()
{
case
int
_ts
,
int8_ts
,
int16_ts
,
int32_ts
,
int64_ts
,
int_t
,
int8_t
,
int16_t
,
int32_t
,
int64_t
:
case
int
TS
,
int8TS
,
int16TS
,
int32TS
,
int64TS
,
intT
,
int8T
,
int16T
,
int32T
,
int64T
:
return
true
}
return
false
...
...
accounts/abi/reflect.go
View file @
6ab9f0a1
...
...
@@ -24,7 +24,7 @@ import (
// indirect recursively dereferences the value until it either gets the value
// or finds a big.Int
func
indirect
(
v
reflect
.
Value
)
reflect
.
Value
{
if
v
.
Kind
()
==
reflect
.
Ptr
&&
v
.
Elem
()
.
Type
()
!=
derefbig
_t
{
if
v
.
Kind
()
==
reflect
.
Ptr
&&
v
.
Elem
()
.
Type
()
!=
derefbig
T
{
return
indirect
(
v
.
Elem
())
}
return
v
...
...
@@ -36,26 +36,26 @@ func reflectIntKindAndType(unsigned bool, size int) (reflect.Kind, reflect.Type)
switch
size
{
case
8
:
if
unsigned
{
return
reflect
.
Uint8
,
uint8
_t
return
reflect
.
Uint8
,
uint8
T
}
return
reflect
.
Int8
,
int8
_t
return
reflect
.
Int8
,
int8
T
case
16
:
if
unsigned
{
return
reflect
.
Uint16
,
uint16
_t
return
reflect
.
Uint16
,
uint16
T
}
return
reflect
.
Int16
,
int16
_t
return
reflect
.
Int16
,
int16
T
case
32
:
if
unsigned
{
return
reflect
.
Uint32
,
uint32
_t
return
reflect
.
Uint32
,
uint32
T
}
return
reflect
.
Int32
,
int32
_t
return
reflect
.
Int32
,
int32
T
case
64
:
if
unsigned
{
return
reflect
.
Uint64
,
uint64
_t
return
reflect
.
Uint64
,
uint64
T
}
return
reflect
.
Int64
,
int64
_t
return
reflect
.
Int64
,
int64
T
}
return
reflect
.
Ptr
,
big
_t
return
reflect
.
Ptr
,
big
T
}
// mustArrayToBytesSlice creates a new byte slice with the exact same size as value
...
...
accounts/abi/type.go
View file @
6ab9f0a1
...
...
@@ -135,7 +135,7 @@ func NewType(t string) (typ Type, err error) {
typ
.
Type
=
reflect
.
TypeOf
(
bool
(
false
))
case
"address"
:
typ
.
Kind
=
reflect
.
Array
typ
.
Type
=
address
_t
typ
.
Type
=
address
T
typ
.
Size
=
20
typ
.
T
=
AddressTy
case
"string"
:
...
...
accounts/abi/type_test.go
View file @
6ab9f0a1
This diff is collapsed.
Click to expand it.
accounts/abi/unpack_test.go
View file @
6ab9f0a1
...
...
@@ -56,6 +56,23 @@ var unpackTests = []unpackTest{
enc
:
"0000000000000000000000000000000000000000000000000000000000000001"
,
want
:
true
,
},
{
def
:
`[{ "type": "bool" }]`
,
enc
:
"0000000000000000000000000000000000000000000000000000000000000000"
,
want
:
false
,
},
{
def
:
`[{ "type": "bool" }]`
,
enc
:
"0000000000000000000000000000000000000000000000000001000000000001"
,
want
:
false
,
err
:
"abi: improperly encoded boolean value"
,
},
{
def
:
`[{ "type": "bool" }]`
,
enc
:
"0000000000000000000000000000000000000000000000000000000000000003"
,
want
:
false
,
err
:
"abi: improperly encoded boolean value"
,
},
{
def
:
`[{"type": "uint32"}]`
,
enc
:
"0000000000000000000000000000000000000000000000000000000000000001"
,
...
...
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