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
cd6b3fd2
Commit
cd6b3fd2
authored
Mar 26, 2015
by
Taylor Gerring
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
GetDataArgs
parent
a49c8154
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
56 additions
and
20 deletions
+56
-20
api.go
rpc/api.go
+1
-4
args.go
rpc/args.go
+2
-9
args_test.go
rpc/args_test.go
+53
-7
No files found.
rpc/api.go
View file @
cd6b3fd2
...
@@ -159,10 +159,7 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err
...
@@ -159,10 +159,7 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err
if
err
:=
json
.
Unmarshal
(
req
.
Params
,
&
args
);
err
!=
nil
{
if
err
:=
json
.
Unmarshal
(
req
.
Params
,
&
args
);
err
!=
nil
{
return
err
return
err
}
}
if
err
:=
args
.
requirements
();
err
!=
nil
{
*
reply
=
api
.
xethAtStateNum
(
args
.
BlockNumber
)
.
CodeAt
(
args
.
Address
.
Hex
())
return
err
}
*
reply
=
api
.
xethAtStateNum
(
args
.
BlockNumber
)
.
CodeAt
(
args
.
Address
)
case
"eth_sendTransaction"
,
"eth_transact"
:
case
"eth_sendTransaction"
,
"eth_transact"
:
args
:=
new
(
NewTxArgs
)
args
:=
new
(
NewTxArgs
)
if
err
:=
json
.
Unmarshal
(
req
.
Params
,
&
args
);
err
!=
nil
{
if
err
:=
json
.
Unmarshal
(
req
.
Params
,
&
args
);
err
!=
nil
{
...
...
rpc/args.go
View file @
cd6b3fd2
...
@@ -281,7 +281,7 @@ func (args *GetBalanceArgs) UnmarshalJSON(b []byte) (err error) {
...
@@ -281,7 +281,7 @@ func (args *GetBalanceArgs) UnmarshalJSON(b []byte) (err error) {
}
}
type
GetDataArgs
struct
{
type
GetDataArgs
struct
{
Address
string
Address
common
.
Address
BlockNumber
int64
BlockNumber
int64
}
}
...
@@ -299,7 +299,7 @@ func (args *GetDataArgs) UnmarshalJSON(b []byte) (err error) {
...
@@ -299,7 +299,7 @@ func (args *GetDataArgs) UnmarshalJSON(b []byte) (err error) {
if
!
ok
{
if
!
ok
{
return
NewInvalidTypeError
(
"address"
,
"not a string"
)
return
NewInvalidTypeError
(
"address"
,
"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
{
...
@@ -310,13 +310,6 @@ func (args *GetDataArgs) UnmarshalJSON(b []byte) (err error) {
...
@@ -310,13 +310,6 @@ func (args *GetDataArgs) UnmarshalJSON(b []byte) (err error) {
return
nil
return
nil
}
}
func
(
args
*
GetDataArgs
)
requirements
()
error
{
if
len
(
args
.
Address
)
==
0
{
return
NewValidationError
(
"Address"
,
"cannot be blank"
)
}
return
nil
}
type
BlockNumIndexArgs
struct
{
type
BlockNumIndexArgs
struct
{
BlockNumber
int64
BlockNumber
int64
Index
int64
Index
int64
...
...
rpc/args_test.go
View file @
cd6b3fd2
...
@@ -682,7 +682,7 @@ func TestGetTxCountBlockheightInvalid(t *testing.T) {
...
@@ -682,7 +682,7 @@ func TestGetTxCountBlockheightInvalid(t *testing.T) {
func
TestGetDataArgs
(
t
*
testing
.
T
)
{
func
TestGetDataArgs
(
t
*
testing
.
T
)
{
input
:=
`["0xd5677cf67b5aa051bb40496e68ad359eb97cfbf8", "latest"]`
input
:=
`["0xd5677cf67b5aa051bb40496e68ad359eb97cfbf8", "latest"]`
expected
:=
new
(
GetDataArgs
)
expected
:=
new
(
GetDataArgs
)
expected
.
Address
=
"0xd5677cf67b5aa051bb40496e68ad359eb97cfbf8"
expected
.
Address
=
common
.
HexToAddress
(
"0xd5677cf67b5aa051bb40496e68ad359eb97cfbf8"
)
expected
.
BlockNumber
=
-
1
expected
.
BlockNumber
=
-
1
args
:=
new
(
GetDataArgs
)
args
:=
new
(
GetDataArgs
)
...
@@ -690,10 +690,6 @@ func TestGetDataArgs(t *testing.T) {
...
@@ -690,10 +690,6 @@ func TestGetDataArgs(t *testing.T) {
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
)
}
}
...
@@ -703,13 +699,63 @@ func TestGetDataArgs(t *testing.T) {
...
@@ -703,13 +699,63 @@ func TestGetDataArgs(t *testing.T) {
}
}
}
}
func
TestGetData
EmptyArgs
(
t
*
testing
.
T
)
{
func
TestGetData
ArgsEmpty
(
t
*
testing
.
T
)
{
input
:=
`[]`
input
:=
`[]`
args
:=
new
(
GetDataArgs
)
args
:=
new
(
GetDataArgs
)
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
TestGetDataArgsInvalid
(
t
*
testing
.
T
)
{
input
:=
`{}`
args
:=
new
(
GetDataArgs
)
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
TestGetDataArgsAddressNotString
(
t
*
testing
.
T
)
{
input
:=
`[12, "latest"]`
args
:=
new
(
GetDataArgs
)
err
:=
json
.
Unmarshal
([]
byte
(
input
),
&
args
)
switch
err
.
(
type
)
{
case
nil
:
t
.
Error
(
"Expected error but didn't get one"
)
case
*
InvalidTypeError
:
break
default
:
t
.
Errorf
(
"Expected *rpc.InvalidTypeError but got %T with message `%s`"
,
err
,
err
.
Error
())
}
}
func
TestGetDataArgsBlocknumberNotString
(
t
*
testing
.
T
)
{
input
:=
`["0xd5677cf67b5aa051bb40496e68ad359eb97cfbf8", false]`
args
:=
new
(
GetDataArgs
)
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
*
InvalidTypeError
:
break
default
:
t
.
Errorf
(
"Expected *rpc.InvalidTypeError 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