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
3472823b
Commit
3472823b
authored
Mar 26, 2015
by
Taylor Gerring
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
HashIndexArgs
parent
cb103c08
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
66 additions
and
6 deletions
+66
-6
api.go
rpc/api.go
+3
-3
args.go
rpc/args.go
+2
-2
args_test.go
rpc/args_test.go
+61
-1
No files found.
rpc/api.go
View file @
3472823b
...
@@ -212,7 +212,7 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err
...
@@ -212,7 +212,7 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err
args
:=
new
(
HashIndexArgs
)
args
:=
new
(
HashIndexArgs
)
if
err
:=
json
.
Unmarshal
(
req
.
Params
,
&
args
);
err
!=
nil
{
if
err
:=
json
.
Unmarshal
(
req
.
Params
,
&
args
);
err
!=
nil
{
}
}
tx
:=
api
.
xeth
()
.
EthTransactionByHash
(
args
.
Hash
)
tx
:=
api
.
xeth
()
.
EthTransactionByHash
(
args
.
Hash
.
Hex
()
)
if
tx
!=
nil
{
if
tx
!=
nil
{
*
reply
=
NewTransactionRes
(
tx
)
*
reply
=
NewTransactionRes
(
tx
)
}
}
...
@@ -222,7 +222,7 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err
...
@@ -222,7 +222,7 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err
return
err
return
err
}
}
block
:=
api
.
xeth
()
.
EthBlockByH
exstring
(
args
.
Hash
)
block
:=
api
.
xeth
()
.
EthBlockByH
ash
(
args
.
Hash
)
br
:=
NewBlockRes
(
block
)
br
:=
NewBlockRes
(
block
)
br
.
fullTx
=
true
br
.
fullTx
=
true
...
@@ -250,7 +250,7 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err
...
@@ -250,7 +250,7 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err
return
err
return
err
}
}
br
:=
NewBlockRes
(
api
.
xeth
()
.
EthBlockByH
exstring
(
args
.
Hash
))
br
:=
NewBlockRes
(
api
.
xeth
()
.
EthBlockByH
ash
(
args
.
Hash
))
if
args
.
Index
>
int64
(
len
(
br
.
Uncles
))
||
args
.
Index
<
0
{
if
args
.
Index
>
int64
(
len
(
br
.
Uncles
))
||
args
.
Index
<
0
{
return
NewValidationError
(
"Index"
,
"does not exist"
)
return
NewValidationError
(
"Index"
,
"does not exist"
)
...
...
rpc/args.go
View file @
3472823b
...
@@ -342,7 +342,7 @@ func (args *BlockNumIndexArgs) UnmarshalJSON(b []byte) (err error) {
...
@@ -342,7 +342,7 @@ func (args *BlockNumIndexArgs) UnmarshalJSON(b []byte) (err error) {
}
}
type
HashIndexArgs
struct
{
type
HashIndexArgs
struct
{
Hash
string
Hash
common
.
Hash
Index
int64
Index
int64
}
}
...
@@ -361,7 +361,7 @@ func (args *HashIndexArgs) UnmarshalJSON(b []byte) (err error) {
...
@@ -361,7 +361,7 @@ func (args *HashIndexArgs) UnmarshalJSON(b []byte) (err error) {
if
!
ok
{
if
!
ok
{
return
NewInvalidTypeError
(
"hash"
,
"not a string"
)
return
NewInvalidTypeError
(
"hash"
,
"not a string"
)
}
}
args
.
Hash
=
arg0
args
.
Hash
=
common
.
HexToHash
(
arg0
)
if
len
(
obj
)
>
1
{
if
len
(
obj
)
>
1
{
arg1
,
ok
:=
obj
[
1
]
.
(
string
)
arg1
,
ok
:=
obj
[
1
]
.
(
string
)
...
...
rpc/args_test.go
View file @
3472823b
...
@@ -1139,7 +1139,7 @@ func TestBlockNumIndexArgsIndexInvalid(t *testing.T) {
...
@@ -1139,7 +1139,7 @@ func TestBlockNumIndexArgsIndexInvalid(t *testing.T) {
func
TestHashIndexArgs
(
t
*
testing
.
T
)
{
func
TestHashIndexArgs
(
t
*
testing
.
T
)
{
input
:=
`["0xc6ef2fc5426d6ad6fd9e2a26abeab0aa2411b7ab17f30a99d3cb96aed1d1055b", "0x1"]`
input
:=
`["0xc6ef2fc5426d6ad6fd9e2a26abeab0aa2411b7ab17f30a99d3cb96aed1d1055b", "0x1"]`
expected
:=
new
(
HashIndexArgs
)
expected
:=
new
(
HashIndexArgs
)
expected
.
Hash
=
"0xc6ef2fc5426d6ad6fd9e2a26abeab0aa2411b7ab17f30a99d3cb96aed1d1055b"
expected
.
Hash
=
common
.
HexToHash
(
"0xc6ef2fc5426d6ad6fd9e2a26abeab0aa2411b7ab17f30a99d3cb96aed1d1055b"
)
expected
.
Index
=
1
expected
.
Index
=
1
args
:=
new
(
HashIndexArgs
)
args
:=
new
(
HashIndexArgs
)
...
@@ -1156,6 +1156,66 @@ func TestHashIndexArgs(t *testing.T) {
...
@@ -1156,6 +1156,66 @@ func TestHashIndexArgs(t *testing.T) {
}
}
}
}
func
TestHashIndexArgsEmpty
(
t
*
testing
.
T
)
{
input
:=
`[]`
args
:=
new
(
HashIndexArgs
)
err
:=
json
.
Unmarshal
([]
byte
(
input
),
&
args
)
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
TestHashIndexArgsInvalid
(
t
*
testing
.
T
)
{
input
:=
`{}`
args
:=
new
(
HashIndexArgs
)
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
TestHashIndexArgsInvalidHash
(
t
*
testing
.
T
)
{
input
:=
`[7, "0x1"]`
args
:=
new
(
HashIndexArgs
)
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
TestHashIndexArgsInvalidIndex
(
t
*
testing
.
T
)
{
input
:=
`["0xc6ef2fc5426d6ad6fd9e2a26abeab0aa2411b7ab17f30a99d3cb96aed1d1055b", false]`
args
:=
new
(
HashIndexArgs
)
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
TestSubmitWorkArgs
(
t
*
testing
.
T
)
{
func
TestSubmitWorkArgs
(
t
*
testing
.
T
)
{
input
:=
`["0x0000000000000001", "0x1234567890abcdef1234567890abcdef", "0xD1GE5700000000000000000000000000"]`
input
:=
`["0x0000000000000001", "0x1234567890abcdef1234567890abcdef", "0xD1GE5700000000000000000000000000"]`
expected
:=
new
(
SubmitWorkArgs
)
expected
:=
new
(
SubmitWorkArgs
)
...
...
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