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
35ad9feb
Commit
35ad9feb
authored
Apr 22, 2015
by
Taylor Gerring
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update eth_getBlockByNumber to accept words
parent
5f6c8832
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
6 deletions
+21
-6
args.go
rpc/args.go
+2
-6
args_test.go
rpc/args_test.go
+19
-0
No files found.
rpc/args.go
View file @
35ad9feb
...
...
@@ -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
)
...
...
rpc/args_test.go
View file @
35ad9feb
...
...
@@ -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
:=
`[]`
...
...
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