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
39085905
Commit
39085905
authored
Apr 02, 2015
by
Taylor Gerring
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make "To" field optional in whisper filter
parent
876ce0fb
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
5 deletions
+33
-5
args.go
rpc/args.go
+8
-5
args_test.go
rpc/args_test.go
+25
-0
No files found.
rpc/args.go
View file @
39085905
...
@@ -1021,12 +1021,15 @@ func (args *WhisperFilterArgs) UnmarshalJSON(b []byte) (err error) {
...
@@ -1021,12 +1021,15 @@ func (args *WhisperFilterArgs) UnmarshalJSON(b []byte) (err error) {
return
NewInsufficientParamsError
(
len
(
obj
),
1
)
return
NewInsufficientParamsError
(
len
(
obj
),
1
)
}
}
var
argstr
string
if
obj
[
0
]
.
To
==
nil
{
argstr
,
ok
:=
obj
[
0
]
.
To
.
(
string
)
args
.
To
=
""
if
!
ok
{
}
else
{
return
NewInvalidTypeError
(
"to"
,
"is not a string"
)
argstr
,
ok
:=
obj
[
0
]
.
To
.
(
string
)
if
!
ok
{
return
NewInvalidTypeError
(
"to"
,
"is not a string"
)
}
args
.
To
=
argstr
}
}
args
.
To
=
argstr
t
:=
make
([]
string
,
len
(
obj
[
0
]
.
Topics
))
t
:=
make
([]
string
,
len
(
obj
[
0
]
.
Topics
))
for
i
,
j
:=
range
obj
[
0
]
.
Topics
{
for
i
,
j
:=
range
obj
[
0
]
.
Topics
{
...
...
rpc/args_test.go
View file @
39085905
...
@@ -1805,6 +1805,16 @@ func TestWhisperFilterArgsEmpty(t *testing.T) {
...
@@ -1805,6 +1805,16 @@ func TestWhisperFilterArgsEmpty(t *testing.T) {
}
}
}
}
func
TestWhisperFilterArgsToInt
(
t
*
testing
.
T
)
{
input
:=
`[{"to": 2}]`
args
:=
new
(
WhisperFilterArgs
)
str
:=
ExpectInvalidTypeError
(
json
.
Unmarshal
([]
byte
(
input
),
args
))
if
len
(
str
)
>
0
{
t
.
Error
(
str
)
}
}
func
TestWhisperFilterArgsToBool
(
t
*
testing
.
T
)
{
func
TestWhisperFilterArgsToBool
(
t
*
testing
.
T
)
{
input
:=
`[{"topics": ["0x68656c6c6f20776f726c64"], "to": false}]`
input
:=
`[{"topics": ["0x68656c6c6f20776f726c64"], "to": false}]`
...
@@ -1815,6 +1825,21 @@ func TestWhisperFilterArgsToBool(t *testing.T) {
...
@@ -1815,6 +1825,21 @@ func TestWhisperFilterArgsToBool(t *testing.T) {
}
}
}
}
func
TestWhisperFilterArgsToMissing
(
t
*
testing
.
T
)
{
input
:=
`[{"topics": ["0x68656c6c6f20776f726c64"]}]`
expected
:=
new
(
WhisperFilterArgs
)
expected
.
To
=
""
args
:=
new
(
WhisperFilterArgs
)
if
err
:=
json
.
Unmarshal
([]
byte
(
input
),
&
args
);
err
!=
nil
{
t
.
Error
(
err
)
}
if
args
.
To
!=
expected
.
To
{
t
.
Errorf
(
"To shoud be %v but is %v"
,
expected
.
To
,
args
.
To
)
}
}
func
TestWhisperFilterArgsTopicInt
(
t
*
testing
.
T
)
{
func
TestWhisperFilterArgsTopicInt
(
t
*
testing
.
T
)
{
input
:=
`[{"topics": [6], "to": "0x34ag445g3455b34"}]`
input
:=
`[{"topics": [6], "to": "0x34ag445g3455b34"}]`
...
...
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