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
62ebf999
Commit
62ebf999
authored
Mar 26, 2015
by
Taylor Gerring
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
FilterStringArgs tests
parent
e21ce9a9
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
35 additions
and
18 deletions
+35
-18
api.go
rpc/api.go
+0
-4
args.go
rpc/args.go
+2
-7
args_test.go
rpc/args_test.go
+33
-7
No files found.
rpc/api.go
View file @
62ebf999
...
...
@@ -297,10 +297,6 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err
if
err
:=
json
.
Unmarshal
(
req
.
Params
,
&
args
);
err
!=
nil
{
return
err
}
if
err
:=
args
.
requirements
();
err
!=
nil
{
return
err
}
id
:=
api
.
xeth
()
.
NewFilterString
(
args
.
Word
)
*
reply
=
common
.
ToHex
(
big
.
NewInt
(
int64
(
id
))
.
Bytes
())
case
"eth_uninstallFilter"
:
...
...
rpc/args.go
View file @
62ebf999
...
...
@@ -649,18 +649,13 @@ func (args *FilterStringArgs) UnmarshalJSON(b []byte) (err error) {
if
!
ok
{
return
NewInvalidTypeError
(
"filter"
,
"not a string"
)
}
args
.
Word
=
argstr
return
nil
}
func
(
args
*
FilterStringArgs
)
requirements
()
error
{
switch
args
.
Word
{
switch
argstr
{
case
"latest"
,
"pending"
:
break
default
:
return
NewValidationError
(
"Word"
,
"Must be `latest` or `pending`"
)
}
args
.
Word
=
argstr
return
nil
}
...
...
rpc/args_test.go
View file @
62ebf999
...
...
@@ -1106,10 +1106,6 @@ 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
)
}
...
...
@@ -1119,9 +1115,39 @@ func TestFilterStringEmptyArgs(t *testing.T) {
input
:=
`[]`
args
:=
new
(
FilterStringArgs
)
err
:=
json
.
Unmarshal
([]
byte
(
input
),
&
args
)
if
err
==
nil
{
t
.
Error
(
"Expected error but didn't get one"
)
str
:=
ExpectInsufficientParamsError
(
json
.
Unmarshal
([]
byte
(
input
),
&
args
))
if
len
(
str
)
>
0
{
t
.
Errorf
(
str
)
}
}
func
TestFilterStringInvalidArgs
(
t
*
testing
.
T
)
{
input
:=
`{}`
args
:=
new
(
FilterStringArgs
)
str
:=
ExpectDecodeParamError
(
json
.
Unmarshal
([]
byte
(
input
),
&
args
))
if
len
(
str
)
>
0
{
t
.
Errorf
(
str
)
}
}
func
TestFilterStringWordInt
(
t
*
testing
.
T
)
{
input
:=
`[7]`
args
:=
new
(
FilterStringArgs
)
str
:=
ExpectInvalidTypeError
(
json
.
Unmarshal
([]
byte
(
input
),
&
args
))
if
len
(
str
)
>
0
{
t
.
Errorf
(
str
)
}
}
func
TestFilterStringWordWrong
(
t
*
testing
.
T
)
{
input
:=
`["foo"]`
args
:=
new
(
FilterStringArgs
)
str
:=
ExpectValidationError
(
json
.
Unmarshal
([]
byte
(
input
),
&
args
))
if
len
(
str
)
>
0
{
t
.
Errorf
(
str
)
}
}
...
...
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