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
1f1e98f9
Commit
1f1e98f9
authored
Mar 26, 2015
by
Taylor Gerring
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
FilterIdArgs
parent
62ebf999
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
4 deletions
+37
-4
args.go
rpc/args.go
+7
-4
args_test.go
rpc/args_test.go
+30
-0
No files found.
rpc/args.go
View file @
1f1e98f9
...
@@ -664,9 +664,8 @@ type FilterIdArgs struct {
...
@@ -664,9 +664,8 @@ type FilterIdArgs struct {
}
}
func
(
args
*
FilterIdArgs
)
UnmarshalJSON
(
b
[]
byte
)
(
err
error
)
{
func
(
args
*
FilterIdArgs
)
UnmarshalJSON
(
b
[]
byte
)
(
err
error
)
{
var
obj
[]
string
var
obj
[]
interface
{}
r
:=
bytes
.
NewReader
(
b
)
if
err
:=
json
.
Unmarshal
(
b
,
&
obj
);
err
!=
nil
{
if
err
:=
json
.
NewDecoder
(
r
)
.
Decode
(
&
obj
);
err
!=
nil
{
return
NewDecodeParamError
(
err
.
Error
())
return
NewDecodeParamError
(
err
.
Error
())
}
}
...
@@ -674,7 +673,11 @@ func (args *FilterIdArgs) UnmarshalJSON(b []byte) (err error) {
...
@@ -674,7 +673,11 @@ func (args *FilterIdArgs) UnmarshalJSON(b []byte) (err error) {
return
NewInsufficientParamsError
(
len
(
obj
),
1
)
return
NewInsufficientParamsError
(
len
(
obj
),
1
)
}
}
args
.
Id
=
int
(
common
.
Big
(
obj
[
0
])
.
Int64
())
var
num
int64
if
err
:=
numString
(
obj
[
0
],
&
num
);
err
!=
nil
{
return
err
}
args
.
Id
=
int
(
num
)
return
nil
return
nil
}
}
...
...
rpc/args_test.go
View file @
1f1e98f9
...
@@ -1056,6 +1056,36 @@ func TestFilterIdArgs(t *testing.T) {
...
@@ -1056,6 +1056,36 @@ func TestFilterIdArgs(t *testing.T) {
}
}
}
}
func
TestFilterIdArgsInvalid
(
t
*
testing
.
T
)
{
input
:=
`{}`
args
:=
new
(
FilterIdArgs
)
str
:=
ExpectDecodeParamError
(
json
.
Unmarshal
([]
byte
(
input
),
&
args
))
if
len
(
str
)
>
0
{
t
.
Errorf
(
str
)
}
}
func
TestFilterIdArgsEmpty
(
t
*
testing
.
T
)
{
input
:=
`[]`
args
:=
new
(
FilterIdArgs
)
str
:=
ExpectInsufficientParamsError
(
json
.
Unmarshal
([]
byte
(
input
),
&
args
))
if
len
(
str
)
>
0
{
t
.
Errorf
(
str
)
}
}
func
TestFilterIdArgsBool
(
t
*
testing
.
T
)
{
input
:=
`[true]`
args
:=
new
(
FilterIdArgs
)
str
:=
ExpectInvalidTypeError
(
json
.
Unmarshal
([]
byte
(
input
),
&
args
))
if
len
(
str
)
>
0
{
t
.
Errorf
(
str
)
}
}
func
TestWhsiperFilterArgs
(
t
*
testing
.
T
)
{
func
TestWhsiperFilterArgs
(
t
*
testing
.
T
)
{
input
:=
`[{"topics": ["0x68656c6c6f20776f726c64"], "to": "0x34ag445g3455b34"}]`
input
:=
`[{"topics": ["0x68656c6c6f20776f726c64"], "to": "0x34ag445g3455b34"}]`
expected
:=
new
(
WhisperFilterArgs
)
expected
:=
new
(
WhisperFilterArgs
)
...
...
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