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
9ca87afd
Commit
9ca87afd
authored
Mar 26, 2015
by
Taylor Gerring
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WhisperFilterArgs
parent
81f36df9
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
60 additions
and
13 deletions
+60
-13
api.go
rpc/api.go
+1
-1
args.go
rpc/args.go
+18
-6
args_test.go
rpc/args_test.go
+41
-6
No files found.
rpc/api.go
View file @
9ca87afd
...
...
@@ -417,7 +417,7 @@ func (api *EthereumApi) GetRequestReply(req *RpcRequest, reply *interface{}) err
return
err
}
opts
:=
new
(
xeth
.
Options
)
opts
.
From
=
args
.
From
//
opts.From = args.From
opts
.
To
=
args
.
To
opts
.
Topics
=
args
.
Topics
id
:=
api
.
xeth
()
.
NewWhisperFilter
(
opts
)
...
...
rpc/args.go
View file @
9ca87afd
...
...
@@ -720,9 +720,8 @@ type WhisperFilterArgs struct {
func
(
args
*
WhisperFilterArgs
)
UnmarshalJSON
(
b
[]
byte
)
(
err
error
)
{
var
obj
[]
struct
{
To
string
From
string
Topics
[]
string
To
interface
{}
Topics
[]
interface
{}
}
if
err
=
json
.
Unmarshal
(
b
,
&
obj
);
err
!=
nil
{
...
...
@@ -733,9 +732,22 @@ func (args *WhisperFilterArgs) UnmarshalJSON(b []byte) (err error) {
return
NewInsufficientParamsError
(
len
(
obj
),
1
)
}
args
.
To
=
obj
[
0
]
.
To
args
.
From
=
obj
[
0
]
.
From
args
.
Topics
=
obj
[
0
]
.
Topics
var
argstr
string
argstr
,
ok
:=
obj
[
0
]
.
To
.
(
string
)
if
!
ok
{
return
NewInvalidTypeError
(
"to"
,
"is not a string"
)
}
args
.
To
=
argstr
t
:=
make
([]
string
,
len
(
obj
[
0
]
.
Topics
))
for
i
,
j
:=
range
obj
[
0
]
.
Topics
{
argstr
,
ok
:=
j
.
(
string
)
if
!
ok
{
return
NewInvalidTypeError
(
"topics["
+
string
(
i
)
+
"]"
,
"is not a string"
)
}
t
[
i
]
=
argstr
}
args
.
Topics
=
t
return
nil
}
...
...
rpc/args_test.go
View file @
9ca87afd
...
...
@@ -1086,10 +1086,9 @@ func TestFilterIdArgsBool(t *testing.T) {
}
}
func
TestWh
si
perFilterArgs
(
t
*
testing
.
T
)
{
func
TestWh
is
perFilterArgs
(
t
*
testing
.
T
)
{
input
:=
`[{"topics": ["0x68656c6c6f20776f726c64"], "to": "0x34ag445g3455b34"}]`
expected
:=
new
(
WhisperFilterArgs
)
expected
.
From
=
""
expected
.
To
=
"0x34ag445g3455b34"
expected
.
Topics
=
[]
string
{
"0x68656c6c6f20776f726c64"
}
...
...
@@ -1098,10 +1097,6 @@ func TestWhsiperFilterArgs(t *testing.T) {
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
)
}
...
...
@@ -1111,6 +1106,46 @@ func TestWhsiperFilterArgs(t *testing.T) {
// }
}
func
TestWhisperFilterArgsInvalid
(
t
*
testing
.
T
)
{
input
:=
`{}`
args
:=
new
(
WhisperFilterArgs
)
str
:=
ExpectDecodeParamError
(
json
.
Unmarshal
([]
byte
(
input
),
args
))
if
len
(
str
)
>
0
{
t
.
Error
(
str
)
}
}
func
TestWhisperFilterArgsEmpty
(
t
*
testing
.
T
)
{
input
:=
`[]`
args
:=
new
(
WhisperFilterArgs
)
str
:=
ExpectInsufficientParamsError
(
json
.
Unmarshal
([]
byte
(
input
),
args
))
if
len
(
str
)
>
0
{
t
.
Error
(
str
)
}
}
func
TestWhisperFilterArgsToBool
(
t
*
testing
.
T
)
{
input
:=
`[{"topics": ["0x68656c6c6f20776f726c64"], "to": false}]`
args
:=
new
(
WhisperFilterArgs
)
str
:=
ExpectInvalidTypeError
(
json
.
Unmarshal
([]
byte
(
input
),
args
))
if
len
(
str
)
>
0
{
t
.
Error
(
str
)
}
}
func
TestWhisperFilterArgsTopicInt
(
t
*
testing
.
T
)
{
input
:=
`[{"topics": [6], "to": "0x34ag445g3455b34"}]`
args
:=
new
(
WhisperFilterArgs
)
str
:=
ExpectInvalidTypeError
(
json
.
Unmarshal
([]
byte
(
input
),
args
))
if
len
(
str
)
>
0
{
t
.
Error
(
str
)
}
}
func
TestCompileArgs
(
t
*
testing
.
T
)
{
input
:=
`["contract test { function multiply(uint a) returns(uint d) { return a * 7; } }"]`
expected
:=
new
(
CompileArgs
)
...
...
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