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
b414a130
Commit
b414a130
authored
Mar 26, 2015
by
Taylor Gerring
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WhisperIdentityArgs
parent
1f1e98f9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
4 deletions
+40
-4
args.go
rpc/args.go
+10
-4
args_test.go
rpc/args_test.go
+30
-0
No files found.
rpc/args.go
View file @
b414a130
...
...
@@ -687,9 +687,8 @@ type WhisperIdentityArgs struct {
}
func
(
args
*
WhisperIdentityArgs
)
UnmarshalJSON
(
b
[]
byte
)
(
err
error
)
{
var
obj
[]
string
r
:=
bytes
.
NewReader
(
b
)
if
err
:=
json
.
NewDecoder
(
r
)
.
Decode
(
&
obj
);
err
!=
nil
{
var
obj
[]
interface
{}
if
err
:=
json
.
Unmarshal
(
b
,
&
obj
);
err
!=
nil
{
return
NewDecodeParamError
(
err
.
Error
())
}
...
...
@@ -697,7 +696,14 @@ func (args *WhisperIdentityArgs) UnmarshalJSON(b []byte) (err error) {
return
NewInsufficientParamsError
(
len
(
obj
),
1
)
}
args
.
Identity
=
obj
[
0
]
argstr
,
ok
:=
obj
[
0
]
.
(
string
)
if
!
ok
{
return
NewInvalidTypeError
(
"arg0"
,
"not a string"
)
}
// if !common.IsHex(argstr) {
// return NewValidationError("arg0", "not a hexstring")
// }
args
.
Identity
=
argstr
return
nil
}
...
...
rpc/args_test.go
View file @
b414a130
...
...
@@ -1196,6 +1196,36 @@ func TestWhisperIdentityArgs(t *testing.T) {
}
}
func
TestWhisperIdentityArgsInvalid
(
t
*
testing
.
T
)
{
input
:=
`{}`
args
:=
new
(
WhisperIdentityArgs
)
str
:=
ExpectDecodeParamError
(
json
.
Unmarshal
([]
byte
(
input
),
&
args
))
if
len
(
str
)
>
0
{
t
.
Errorf
(
str
)
}
}
func
TestWhisperIdentityArgsEmpty
(
t
*
testing
.
T
)
{
input
:=
`[]`
args
:=
new
(
WhisperIdentityArgs
)
str
:=
ExpectInsufficientParamsError
(
json
.
Unmarshal
([]
byte
(
input
),
&
args
))
if
len
(
str
)
>
0
{
t
.
Errorf
(
str
)
}
}
func
TestWhisperIdentityArgsInt
(
t
*
testing
.
T
)
{
input
:=
`[4]`
args
:=
new
(
WhisperIdentityArgs
)
str
:=
ExpectInvalidTypeError
(
json
.
Unmarshal
([]
byte
(
input
),
&
args
))
if
len
(
str
)
>
0
{
t
.
Errorf
(
str
)
}
}
func
TestBlockNumIndexArgs
(
t
*
testing
.
T
)
{
input
:=
`["0x29a", "0x0"]`
expected
:=
new
(
BlockNumIndexArgs
)
...
...
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