good morning!!!!
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
bor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
open
bor
Commits
5da3d911
Commit
5da3d911
authored
Mar 6, 2015
by
Taylor Gerring
Browse files
Options
Downloads
Patches
Plain Diff
Initial args tests
parent
18b07686
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
rpc/args.go
+13
-13
13 additions, 13 deletions
rpc/args.go
rpc/args_test.go
+125
-0
125 additions, 0 deletions
rpc/args_test.go
with
138 additions
and
13 deletions
rpc/args.go
+
13
−
13
View file @
5da3d911
...
@@ -47,7 +47,7 @@ func (args *GetBlockByNumberArgs) UnmarshalJSON(b []byte) (err error) {
...
@@ -47,7 +47,7 @@ func (args *GetBlockByNumberArgs) UnmarshalJSON(b []byte) (err error) {
if
len
(
obj
)
<
1
{
if
len
(
obj
)
<
1
{
return
errArguments
return
errArguments
}
}
args
.
BlockNumber
=
ethutil
.
B
ytesToNumber
(
fromHex
(
obj
[
0
]
.
(
string
)))
args
.
BlockNumber
=
uint64
(
ethutil
.
B
ig
(
obj
[
0
]
.
(
string
))
.
Int64
()
)
if
len
(
obj
)
>
1
{
if
len
(
obj
)
>
1
{
args
.
Transactions
=
obj
[
1
]
.
(
bool
)
args
.
Transactions
=
obj
[
1
]
.
(
bool
)
...
@@ -110,7 +110,7 @@ func (args *GetStorageArgs) UnmarshalJSON(b []byte) (err error) {
...
@@ -110,7 +110,7 @@ func (args *GetStorageArgs) UnmarshalJSON(b []byte) (err error) {
args
.
Address
=
obj
[
0
]
.
(
string
)
args
.
Address
=
obj
[
0
]
.
(
string
)
if
len
(
obj
)
>
1
{
if
len
(
obj
)
>
1
{
args
.
BlockNumber
=
ethutil
.
B
ytesToNumber
(
fromHex
(
obj
[
1
]
.
(
string
)))
args
.
BlockNumber
=
uint64
(
ethutil
.
B
ig
(
obj
[
1
]
.
(
string
))
.
Int64
()
)
}
}
return
nil
return
nil
...
@@ -179,7 +179,7 @@ func (args *GetTxCountArgs) UnmarshalJSON(b []byte) (err error) {
...
@@ -179,7 +179,7 @@ func (args *GetTxCountArgs) UnmarshalJSON(b []byte) (err error) {
args
.
Address
=
obj
[
0
]
.
(
string
)
args
.
Address
=
obj
[
0
]
.
(
string
)
if
len
(
obj
)
>
1
{
if
len
(
obj
)
>
1
{
args
.
BlockNumber
=
ethutil
.
B
ytesToNumber
(
fromHex
(
obj
[
1
]
.
(
string
)))
args
.
BlockNumber
=
uint64
(
ethutil
.
B
ig
(
obj
[
1
]
.
(
string
))
.
Int64
()
)
}
}
return
nil
return
nil
...
@@ -210,7 +210,7 @@ func (args *GetBalanceArgs) UnmarshalJSON(b []byte) (err error) {
...
@@ -210,7 +210,7 @@ func (args *GetBalanceArgs) UnmarshalJSON(b []byte) (err error) {
args
.
Address
=
obj
[
0
]
.
(
string
)
args
.
Address
=
obj
[
0
]
.
(
string
)
if
len
(
obj
)
>
1
{
if
len
(
obj
)
>
1
{
args
.
BlockNumber
=
ethutil
.
B
ytesToNumber
(
fromHex
(
obj
[
1
]
.
(
string
)))
args
.
BlockNumber
=
uint64
(
ethutil
.
B
ig
(
obj
[
1
]
.
(
string
))
.
Int64
()
)
}
}
return
nil
return
nil
...
@@ -241,7 +241,7 @@ func (args *GetDataArgs) UnmarshalJSON(b []byte) (err error) {
...
@@ -241,7 +241,7 @@ func (args *GetDataArgs) UnmarshalJSON(b []byte) (err error) {
args
.
Address
=
obj
[
0
]
.
(
string
)
args
.
Address
=
obj
[
0
]
.
(
string
)
if
len
(
obj
)
>
1
{
if
len
(
obj
)
>
1
{
args
.
BlockNumber
=
ethutil
.
B
ytesToNumber
(
fromHex
(
obj
[
1
]
.
(
string
)))
args
.
BlockNumber
=
uint64
(
ethutil
.
B
ig
(
obj
[
1
]
.
(
string
))
.
Int64
()
)
}
}
return
nil
return
nil
...
@@ -299,10 +299,10 @@ func (args *FilterArgs) UnmarshalJSON(b []byte) (err error) {
...
@@ -299,10 +299,10 @@ func (args *FilterArgs) UnmarshalJSON(b []byte) (err error) {
if
len
(
obj
)
<
1
{
if
len
(
obj
)
<
1
{
return
errArguments
return
errArguments
}
}
args
.
FromBlock
=
ethutil
.
B
ytesToNumber
(
fromHex
(
obj
[
0
]
.
FromBlock
))
args
.
FromBlock
=
uint64
(
ethutil
.
B
ig
(
obj
[
0
]
.
FromBlock
)
.
Int64
()
)
args
.
ToBlock
=
ethutil
.
B
ytesToNumber
(
fromHex
(
obj
[
0
]
.
ToBlock
))
args
.
ToBlock
=
uint64
(
ethutil
.
B
ig
(
obj
[
0
]
.
ToBlock
)
.
Int64
()
)
args
.
Limit
=
ethutil
.
B
ytesToNumber
(
fromHex
(
obj
[
0
]
.
Limit
))
args
.
Limit
=
uint64
(
ethutil
.
B
ig
(
obj
[
0
]
.
Limit
)
.
Int64
()
)
args
.
Offset
=
ethutil
.
B
ytesToNumber
(
fromHex
(
obj
[
0
]
.
Offset
))
args
.
Offset
=
uint64
(
ethutil
.
B
ig
(
obj
[
0
]
.
Offset
)
.
Int64
()
)
args
.
Address
=
obj
[
0
]
.
Address
args
.
Address
=
obj
[
0
]
.
Address
args
.
Topics
=
obj
[
0
]
.
Topics
args
.
Topics
=
obj
[
0
]
.
Topics
...
@@ -335,10 +335,10 @@ func (args *FilterOptions) UnmarshalJSON(b []byte) (err error) {
...
@@ -335,10 +335,10 @@ func (args *FilterOptions) UnmarshalJSON(b []byte) (err error) {
if
len
(
obj
)
<
1
{
if
len
(
obj
)
<
1
{
return
errArguments
return
errArguments
}
}
args
.
Earliest
=
int64
(
ethutil
.
B
ytesToNumber
(
fromHex
(
obj
[
0
]
.
FromBlock
)))
args
.
Earliest
=
int64
(
ethutil
.
B
ig
(
obj
[
0
]
.
FromBlock
)
.
Int64
(
))
args
.
Latest
=
int64
(
ethutil
.
B
ytesToNumber
(
fromHex
(
obj
[
0
]
.
ToBlock
)))
args
.
Latest
=
int64
(
ethutil
.
B
ig
(
obj
[
0
]
.
ToBlock
)
.
Int64
(
))
args
.
Max
=
int
(
ethutil
.
B
ytesToNumber
(
fromHex
(
obj
[
0
]
.
Limit
)))
args
.
Max
=
int
(
ethutil
.
B
ig
(
obj
[
0
]
.
Limit
)
.
Int64
(
))
args
.
Skip
=
int
(
ethutil
.
B
ytesToNumber
(
fromHex
(
obj
[
0
]
.
Offset
)))
args
.
Skip
=
int
(
ethutil
.
B
ig
(
obj
[
0
]
.
Offset
)
.
Int64
(
))
args
.
Address
=
obj
[
0
]
.
Address
args
.
Address
=
obj
[
0
]
.
Address
args
.
Topic
=
obj
[
0
]
.
Topics
args
.
Topic
=
obj
[
0
]
.
Topics
...
...
This diff is collapsed.
Click to expand it.
rpc/args_test.go
0 → 100644
+
125
−
0
View file @
5da3d911
package
rpc
import
(
"bytes"
"encoding/json"
"math/big"
"testing"
)
func
TestSha3
(
t
*
testing
.
T
)
{
input
:=
`["0x68656c6c6f20776f726c64"]`
expected
:=
"0x68656c6c6f20776f726c64"
args
:=
new
(
Sha3Args
)
json
.
Unmarshal
([]
byte
(
input
),
&
args
)
if
args
.
Data
!=
expected
{
t
.
Error
(
"got %s expected %s"
,
input
,
expected
)
}
}
func
TestGetBalanceArgs
(
t
*
testing
.
T
)
{
input
:=
`["0x407d73d8a49eeb85d32cf465507dd71d507100c1", "0x1f"]`
expected
:=
new
(
GetBalanceArgs
)
expected
.
Address
=
"0x407d73d8a49eeb85d32cf465507dd71d507100c1"
expected
.
BlockNumber
=
31
args
:=
new
(
GetBalanceArgs
)
if
err
:=
json
.
Unmarshal
([]
byte
(
input
),
&
args
);
err
!=
nil
{
t
.
Error
(
err
)
}
if
args
.
Address
!=
expected
.
Address
{
t
.
Errorf
(
"Address should be %v but is %v"
,
expected
.
Address
,
args
.
Address
)
}
if
args
.
BlockNumber
!=
expected
.
BlockNumber
{
t
.
Errorf
(
"BlockNumber should be %v but is %v"
,
expected
.
BlockNumber
,
args
.
BlockNumber
)
}
}
func
TestGetBlockByHashArgs
(
t
*
testing
.
T
)
{
input
:=
`["0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331", true]`
expected
:=
new
(
GetBlockByHashArgs
)
expected
.
BlockHash
=
"0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331"
expected
.
Transactions
=
true
args
:=
new
(
GetBlockByHashArgs
)
if
err
:=
json
.
Unmarshal
([]
byte
(
input
),
&
args
);
err
!=
nil
{
t
.
Error
(
err
)
}
if
args
.
BlockHash
!=
expected
.
BlockHash
{
t
.
Errorf
(
"BlockHash should be %v but is %v"
,
expected
.
BlockHash
,
args
.
BlockHash
)
}
if
args
.
Transactions
!=
expected
.
Transactions
{
t
.
Errorf
(
"Transactions should be %v but is %v"
,
expected
.
Transactions
,
args
.
Transactions
)
}
}
func
TestGetBlockByNumberArgs
(
t
*
testing
.
T
)
{
input
:=
`["0x1b4", false]`
expected
:=
new
(
GetBlockByNumberArgs
)
expected
.
BlockNumber
=
436
expected
.
Transactions
=
false
args
:=
new
(
GetBlockByNumberArgs
)
if
err
:=
json
.
Unmarshal
([]
byte
(
input
),
&
args
);
err
!=
nil
{
t
.
Error
(
err
)
}
if
args
.
BlockNumber
!=
expected
.
BlockNumber
{
t
.
Errorf
(
"BlockHash should be %v but is %v"
,
expected
.
BlockNumber
,
args
.
BlockNumber
)
}
if
args
.
Transactions
!=
expected
.
Transactions
{
t
.
Errorf
(
"Transactions should be %v but is %v"
,
expected
.
Transactions
,
args
.
Transactions
)
}
}
func
TestNewTxArgs
(
t
*
testing
.
T
)
{
input
:=
`[{"from": "0xb60e8dd61c5d32be8058bb8eb970870f07233155",
"to": "0xd46e8dd67c5d32be8058bb8eb970870f072445675",
"gas": "0x76c0",
"gasPrice": "0x9184e72a000",
"value": "0x9184e72a000",
"data": "0xd46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675"}]`
expected
:=
new
(
NewTxArgs
)
expected
.
From
=
"0xb60e8dd61c5d32be8058bb8eb970870f07233155"
expected
.
To
=
"0xd46e8dd67c5d32be8058bb8eb970870f072445675"
expected
.
Gas
=
big
.
NewInt
(
30400
)
expected
.
GasPrice
=
big
.
NewInt
(
10000000000000
)
expected
.
Value
=
big
.
NewInt
(
10000000000000
)
expected
.
Data
=
"0xd46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675"
args
:=
new
(
NewTxArgs
)
if
err
:=
json
.
Unmarshal
([]
byte
(
input
),
&
args
);
err
!=
nil
{
t
.
Error
(
err
)
}
if
expected
.
From
!=
args
.
From
{
t
.
Errorf
(
"From shoud be %#v but is %#v"
,
expected
.
From
,
args
.
From
)
}
if
expected
.
To
!=
args
.
To
{
t
.
Errorf
(
"To shoud be %#v but is %#v"
,
expected
.
To
,
args
.
To
)
}
if
bytes
.
Compare
(
expected
.
Gas
.
Bytes
(),
args
.
Gas
.
Bytes
())
!=
0
{
t
.
Errorf
(
"Gas shoud be %#v but is %#v"
,
expected
.
Gas
.
Bytes
(),
args
.
Gas
.
Bytes
())
}
if
bytes
.
Compare
(
expected
.
GasPrice
.
Bytes
(),
args
.
GasPrice
.
Bytes
())
!=
0
{
t
.
Errorf
(
"GasPrice shoud be %#v but is %#v"
,
expected
.
GasPrice
,
args
.
GasPrice
)
}
if
bytes
.
Compare
(
expected
.
Value
.
Bytes
(),
args
.
Value
.
Bytes
())
!=
0
{
t
.
Errorf
(
"Value shoud be %#v but is %#v"
,
expected
.
Value
,
args
.
Value
)
}
if
expected
.
Data
!=
args
.
Data
{
t
.
Errorf
(
"Data shoud be %#v but is %#v"
,
expected
.
Data
,
args
.
Data
)
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment