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
4523a00b
Commit
4523a00b
authored
Mar 26, 2015
by
Taylor Gerring
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
GetTxCountArgs
parent
9c4504dc
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
57 additions
and
23 deletions
+57
-23
api.go
rpc/api.go
+1
-6
args.go
rpc/args.go
+2
-9
args_test.go
rpc/args_test.go
+54
-8
No files found.
rpc/api.go
View file @
4523a00b
...
@@ -123,12 +123,7 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err
...
@@ -123,12 +123,7 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err
return
err
return
err
}
}
err
:=
args
.
requirements
()
*
reply
=
api
.
xethAtStateNum
(
args
.
BlockNumber
)
.
TxCountAt
(
args
.
Address
.
Hex
())
if
err
!=
nil
{
return
err
}
*
reply
=
api
.
xethAtStateNum
(
args
.
BlockNumber
)
.
TxCountAt
(
args
.
Address
)
case
"eth_getBlockTransactionCountByHash"
:
case
"eth_getBlockTransactionCountByHash"
:
args
:=
new
(
GetBlockByHashArgs
)
args
:=
new
(
GetBlockByHashArgs
)
if
err
:=
json
.
Unmarshal
(
req
.
Params
,
&
args
);
err
!=
nil
{
if
err
:=
json
.
Unmarshal
(
req
.
Params
,
&
args
);
err
!=
nil
{
...
...
rpc/args.go
View file @
4523a00b
...
@@ -221,7 +221,7 @@ func (args *GetStorageAtArgs) UnmarshalJSON(b []byte) (err error) {
...
@@ -221,7 +221,7 @@ func (args *GetStorageAtArgs) UnmarshalJSON(b []byte) (err error) {
}
}
type
GetTxCountArgs
struct
{
type
GetTxCountArgs
struct
{
Address
string
Address
common
.
Address
BlockNumber
int64
BlockNumber
int64
}
}
...
@@ -239,7 +239,7 @@ func (args *GetTxCountArgs) UnmarshalJSON(b []byte) (err error) {
...
@@ -239,7 +239,7 @@ func (args *GetTxCountArgs) UnmarshalJSON(b []byte) (err error) {
if
!
ok
{
if
!
ok
{
return
NewDecodeParamError
(
"Address is not a string"
)
return
NewDecodeParamError
(
"Address is not a string"
)
}
}
args
.
Address
=
addstr
args
.
Address
=
common
.
HexToAddress
(
addstr
)
if
len
(
obj
)
>
1
{
if
len
(
obj
)
>
1
{
if
err
:=
blockHeight
(
obj
[
1
],
&
args
.
BlockNumber
);
err
!=
nil
{
if
err
:=
blockHeight
(
obj
[
1
],
&
args
.
BlockNumber
);
err
!=
nil
{
...
@@ -250,13 +250,6 @@ func (args *GetTxCountArgs) UnmarshalJSON(b []byte) (err error) {
...
@@ -250,13 +250,6 @@ func (args *GetTxCountArgs) UnmarshalJSON(b []byte) (err error) {
return
nil
return
nil
}
}
func
(
args
*
GetTxCountArgs
)
requirements
()
error
{
if
len
(
args
.
Address
)
==
0
{
return
NewValidationError
(
"Address"
,
"cannot be blank"
)
}
return
nil
}
type
GetBalanceArgs
struct
{
type
GetBalanceArgs
struct
{
Address
string
Address
string
BlockNumber
int64
BlockNumber
int64
...
...
rpc/args_test.go
View file @
4523a00b
...
@@ -559,20 +559,16 @@ func TestGetStorageAtArgsValueNotString(t *testing.T) {
...
@@ -559,20 +559,16 @@ func TestGetStorageAtArgsValueNotString(t *testing.T) {
}
}
func
TestGetTxCountArgs
(
t
*
testing
.
T
)
{
func
TestGetTxCountArgs
(
t
*
testing
.
T
)
{
input
:=
`["0x407d73d8a49eeb85d32cf465507dd71d507100c1", "
latest
"]`
input
:=
`["0x407d73d8a49eeb85d32cf465507dd71d507100c1", "
pending
"]`
expected
:=
new
(
GetTxCountArgs
)
expected
:=
new
(
GetTxCountArgs
)
expected
.
Address
=
"0x407d73d8a49eeb85d32cf465507dd71d507100c1"
expected
.
Address
=
common
.
HexToAddress
(
"0x407d73d8a49eeb85d32cf465507dd71d507100c1"
)
expected
.
BlockNumber
=
-
1
expected
.
BlockNumber
=
-
2
args
:=
new
(
GetTxCountArgs
)
args
:=
new
(
GetTxCountArgs
)
if
err
:=
json
.
Unmarshal
([]
byte
(
input
),
&
args
);
err
!=
nil
{
if
err
:=
json
.
Unmarshal
([]
byte
(
input
),
&
args
);
err
!=
nil
{
t
.
Error
(
err
)
t
.
Error
(
err
)
}
}
if
err
:=
args
.
requirements
();
err
!=
nil
{
t
.
Error
(
err
)
}
if
expected
.
Address
!=
args
.
Address
{
if
expected
.
Address
!=
args
.
Address
{
t
.
Errorf
(
"Address shoud be %#v but is %#v"
,
expected
.
Address
,
args
.
Address
)
t
.
Errorf
(
"Address shoud be %#v but is %#v"
,
expected
.
Address
,
args
.
Address
)
}
}
...
@@ -587,8 +583,58 @@ func TestGetTxCountEmptyArgs(t *testing.T) {
...
@@ -587,8 +583,58 @@ func TestGetTxCountEmptyArgs(t *testing.T) {
args
:=
new
(
GetTxCountArgs
)
args
:=
new
(
GetTxCountArgs
)
err
:=
json
.
Unmarshal
([]
byte
(
input
),
&
args
)
err
:=
json
.
Unmarshal
([]
byte
(
input
),
&
args
)
if
err
==
nil
{
switch
err
.
(
type
)
{
case
nil
:
t
.
Error
(
"Expected error but didn't get one"
)
case
*
InsufficientParamsError
:
break
default
:
t
.
Errorf
(
"Expected *rpc.InsufficientParamsError but got %T with message `%s`"
,
err
,
err
.
Error
())
}
}
func
TestGetTxCountEmptyArgsInvalid
(
t
*
testing
.
T
)
{
input
:=
`false`
args
:=
new
(
GetTxCountArgs
)
err
:=
json
.
Unmarshal
([]
byte
(
input
),
&
args
)
switch
err
.
(
type
)
{
case
nil
:
t
.
Error
(
"Expected error but didn't get one"
)
t
.
Error
(
"Expected error but didn't get one"
)
case
*
DecodeParamError
:
break
default
:
t
.
Errorf
(
"Expected *rpc.DecodeParamError but got %T with message `%s`"
,
err
,
err
.
Error
())
}
}
func
TestGetTxCountAddressNotString
(
t
*
testing
.
T
)
{
input
:=
`[false, "pending"]`
args
:=
new
(
GetTxCountArgs
)
err
:=
json
.
Unmarshal
([]
byte
(
input
),
&
args
)
switch
err
.
(
type
)
{
case
nil
:
t
.
Error
(
"Expected error but didn't get one"
)
case
*
DecodeParamError
:
break
default
:
t
.
Errorf
(
"Expected *rpc.DecodeParamError but got %T with message `%s`"
,
err
,
err
.
Error
())
}
}
func
TestGetTxCountBlockheightInvalid
(
t
*
testing
.
T
)
{
input
:=
`["0x407d73d8a49eeb85d32cf465507dd71d507100c1", {}]`
args
:=
new
(
GetTxCountArgs
)
err
:=
json
.
Unmarshal
([]
byte
(
input
),
&
args
)
switch
err
.
(
type
)
{
case
nil
:
t
.
Error
(
"Expected error but didn't get one"
)
case
*
DecodeParamError
:
break
default
:
t
.
Errorf
(
"Expected *rpc.DecodeParamError but got %T with message `%s`"
,
err
,
err
.
Error
())
}
}
}
}
...
...
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