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
1e61b75c
Commit
1e61b75c
authored
Mar 23, 2015
by
Taylor Gerring
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tests + fixes
parent
0330077d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
7 deletions
+37
-7
args.go
rpc/args.go
+4
-5
args_test.go
rpc/args_test.go
+33
-2
No files found.
rpc/args.go
View file @
1e61b75c
...
...
@@ -467,7 +467,7 @@ func (args *BlockFilterArgs) UnmarshalJSON(b []byte) (err error) {
switch
fromstr
{
case
"latest"
:
args
.
Earliest
=
0
args
.
Earliest
=
-
1
default
:
args
.
Earliest
=
int64
(
common
.
Big
(
obj
[
0
]
.
FromBlock
.
(
string
))
.
Int64
())
}
...
...
@@ -479,9 +479,9 @@ func (args *BlockFilterArgs) UnmarshalJSON(b []byte) (err error) {
switch
tostr
{
case
"latest"
:
args
.
Latest
=
0
case
"pending"
:
args
.
Latest
=
-
1
case
"pending"
:
args
.
Latest
=
-
2
default
:
args
.
Latest
=
int64
(
common
.
Big
(
obj
[
0
]
.
ToBlock
.
(
string
))
.
Int64
())
}
...
...
@@ -775,8 +775,7 @@ func (args *SubmitWorkArgs) UnmarshalJSON(b []byte) (err error) {
return
NewDecodeParamError
(
"Nonce is not a string"
)
}
args
.
Nonce
=
common
.
BytesToNumber
(
common
.
Hex2Bytes
(
objstr
))
args
.
Nonce
=
common
.
String2Big
(
objstr
)
.
Uint64
()
if
objstr
,
ok
=
obj
[
1
]
.
(
string
);
!
ok
{
return
NewDecodeParamError
(
"Header is not a string"
)
}
...
...
rpc/args_test.go
View file @
1e61b75c
...
...
@@ -5,6 +5,8 @@ import (
"encoding/json"
"math/big"
"testing"
"github.com/ethereum/go-ethereum/common"
)
func
TestSha3
(
t
*
testing
.
T
)
{
...
...
@@ -440,8 +442,8 @@ func TestBlockFilterArgsWords(t *testing.T) {
"toBlock": "pending"
}]`
expected
:=
new
(
BlockFilterArgs
)
expected
.
Earliest
=
0
expected
.
Latest
=
-
1
expected
.
Earliest
=
-
1
expected
.
Latest
=
-
2
args
:=
new
(
BlockFilterArgs
)
if
err
:=
json
.
Unmarshal
([]
byte
(
input
),
&
args
);
err
!=
nil
{
...
...
@@ -651,6 +653,10 @@ func TestFilterStringArgs(t *testing.T) {
t
.
Error
(
err
)
}
if
err
:=
args
.
requirements
();
err
!=
nil
{
t
.
Error
(
err
)
}
if
expected
.
Word
!=
args
.
Word
{
t
.
Errorf
(
"Word shoud be %#v but is %#v"
,
expected
.
Word
,
args
.
Word
)
}
...
...
@@ -720,3 +726,28 @@ func TestHashIndexArgs(t *testing.T) {
t
.
Errorf
(
"Index shoud be %#v but is %#v"
,
expected
.
Index
,
args
.
Index
)
}
}
func
TestSubmitWorkArgs
(
t
*
testing
.
T
)
{
input
:=
`["0x0000000000000001", "0x1234567890abcdef1234567890abcdef", "0xD1GE5700000000000000000000000000"]`
expected
:=
new
(
SubmitWorkArgs
)
expected
.
Nonce
=
1
expected
.
Header
=
common
.
HexToHash
(
"0x1234567890abcdef1234567890abcdef"
)
expected
.
Digest
=
common
.
HexToHash
(
"0xD1GE5700000000000000000000000000"
)
args
:=
new
(
SubmitWorkArgs
)
if
err
:=
json
.
Unmarshal
([]
byte
(
input
),
&
args
);
err
!=
nil
{
t
.
Error
(
err
)
}
if
expected
.
Nonce
!=
args
.
Nonce
{
t
.
Errorf
(
"Nonce shoud be %d but is %d"
,
expected
.
Nonce
,
args
.
Nonce
)
}
if
expected
.
Header
!=
args
.
Header
{
t
.
Errorf
(
"Header shoud be %#v but is %#v"
,
expected
.
Header
,
args
.
Header
)
}
if
expected
.
Digest
!=
args
.
Digest
{
t
.
Errorf
(
"Digest shoud be %#v but is %#v"
,
expected
.
Digest
,
args
.
Digest
)
}
}
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