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
359a9773
Commit
359a9773
authored
Apr 23, 2015
by
Jeffrey Wilcke
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #783 from tgerring/issue777
Issue 777
parents
69788cb9
20bae2b8
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
61 additions
and
11 deletions
+61
-11
args.go
rpc/args.go
+6
-10
args_test.go
rpc/args_test.go
+55
-1
No files found.
rpc/args.go
View file @
359a9773
...
...
@@ -145,12 +145,8 @@ func (args *GetBlockByNumberArgs) UnmarshalJSON(b []byte) (err error) {
return
NewInsufficientParamsError
(
len
(
obj
),
2
)
}
if
v
,
ok
:=
obj
[
0
]
.
(
float64
);
ok
{
args
.
BlockNumber
=
int64
(
v
)
}
else
if
v
,
ok
:=
obj
[
0
]
.
(
string
);
ok
{
args
.
BlockNumber
=
common
.
Big
(
v
)
.
Int64
()
}
else
{
return
NewInvalidTypeError
(
"blockNumber"
,
"not a number or string"
)
if
err
:=
blockHeight
(
obj
[
0
],
&
args
.
BlockNumber
);
err
!=
nil
{
return
err
}
args
.
IncludeTxs
=
obj
[
1
]
.
(
bool
)
...
...
@@ -539,11 +535,11 @@ func (args *BlockNumIndexArgs) UnmarshalJSON(b []byte) (err error) {
return
err
}
arg1
,
ok
:=
obj
[
1
]
.
(
string
)
if
!
ok
{
return
NewInvalidTypeError
(
"index"
,
"not a string"
)
var
arg1
*
big
.
Int
if
arg1
,
err
=
numString
(
obj
[
1
]);
err
!=
nil
{
return
err
}
args
.
Index
=
common
.
Big
(
arg1
)
.
Int64
()
args
.
Index
=
arg1
.
Int64
()
return
nil
}
...
...
rpc/args_test.go
View file @
359a9773
...
...
@@ -355,6 +355,25 @@ func TestGetBlockByNumberArgsBlockHex(t *testing.T) {
t
.
Errorf
(
"IncludeTxs should be %v but is %v"
,
expected
.
IncludeTxs
,
args
.
IncludeTxs
)
}
}
func
TestGetBlockByNumberArgsWords
(
t
*
testing
.
T
)
{
input
:=
`["earliest", true]`
expected
:=
new
(
GetBlockByNumberArgs
)
expected
.
BlockNumber
=
0
expected
.
IncludeTxs
=
true
args
:=
new
(
GetBlockByNumberArgs
)
if
err
:=
json
.
Unmarshal
([]
byte
(
input
),
&
args
);
err
!=
nil
{
t
.
Error
(
err
)
}
if
args
.
BlockNumber
!=
expected
.
BlockNumber
{
t
.
Errorf
(
"BlockNumber should be %v but is %v"
,
expected
.
BlockNumber
,
args
.
BlockNumber
)
}
if
args
.
IncludeTxs
!=
expected
.
IncludeTxs
{
t
.
Errorf
(
"IncludeTxs should be %v but is %v"
,
expected
.
IncludeTxs
,
args
.
IncludeTxs
)
}
}
func
TestGetBlockByNumberEmpty
(
t
*
testing
.
T
)
{
input
:=
`[]`
...
...
@@ -2165,6 +2184,21 @@ func TestBlockNumArgs(t *testing.T) {
}
}
func
TestBlockNumArgsWord
(
t
*
testing
.
T
)
{
input
:=
`["pending"]`
expected
:=
new
(
BlockNumIndexArgs
)
expected
.
BlockNumber
=
-
2
args
:=
new
(
BlockNumArg
)
if
err
:=
json
.
Unmarshal
([]
byte
(
input
),
&
args
);
err
!=
nil
{
t
.
Error
(
err
)
}
if
expected
.
BlockNumber
!=
args
.
BlockNumber
{
t
.
Errorf
(
"BlockNumber shoud be %#v but is %#v"
,
expected
.
BlockNumber
,
args
.
BlockNumber
)
}
}
func
TestBlockNumArgsInvalid
(
t
*
testing
.
T
)
{
input
:=
`{}`
...
...
@@ -2214,6 +2248,26 @@ func TestBlockNumIndexArgs(t *testing.T) {
}
}
func
TestBlockNumIndexArgsWord
(
t
*
testing
.
T
)
{
input
:=
`["latest", 67]`
expected
:=
new
(
BlockNumIndexArgs
)
expected
.
BlockNumber
=
-
1
expected
.
Index
=
67
args
:=
new
(
BlockNumIndexArgs
)
if
err
:=
json
.
Unmarshal
([]
byte
(
input
),
&
args
);
err
!=
nil
{
t
.
Error
(
err
)
}
if
expected
.
BlockNumber
!=
args
.
BlockNumber
{
t
.
Errorf
(
"BlockNumber shoud be %#v but is %#v"
,
expected
.
BlockNumber
,
args
.
BlockNumber
)
}
if
expected
.
Index
!=
args
.
Index
{
t
.
Errorf
(
"Index shoud be %#v but is %#v"
,
expected
.
Index
,
args
.
Index
)
}
}
func
TestBlockNumIndexArgsEmpty
(
t
*
testing
.
T
)
{
input
:=
`[]`
...
...
@@ -2245,7 +2299,7 @@ func TestBlockNumIndexArgsBlocknumInvalid(t *testing.T) {
}
func
TestBlockNumIndexArgsIndexInvalid
(
t
*
testing
.
T
)
{
input
:=
`["0x29a",
1
]`
input
:=
`["0x29a",
true
]`
args
:=
new
(
BlockNumIndexArgs
)
str
:=
ExpectInvalidTypeError
(
json
.
Unmarshal
([]
byte
(
input
),
&
args
))
...
...
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