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
e21ce9a9
Commit
e21ce9a9
authored
Mar 26, 2015
by
Taylor Gerring
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
DbHexArgs tests
parent
f68ca2b6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
80 additions
and
2 deletions
+80
-2
args.go
rpc/args.go
+2
-2
args_test.go
rpc/args_test.go
+78
-0
No files found.
rpc/args.go
View file @
e21ce9a9
...
...
@@ -567,10 +567,10 @@ func (args *DbHexArgs) UnmarshalJSON(b []byte) (err error) {
func
(
a
*
DbHexArgs
)
requirements
()
error
{
if
len
(
a
.
Database
)
==
0
{
return
New
InvalidType
Error
(
"Database"
,
"cannot be blank"
)
return
New
Validation
Error
(
"Database"
,
"cannot be blank"
)
}
if
len
(
a
.
Key
)
==
0
{
return
New
InvalidType
Error
(
"Key"
,
"cannot be blank"
)
return
New
Validation
Error
(
"Key"
,
"cannot be blank"
)
}
return
nil
}
...
...
rpc/args_test.go
View file @
e21ce9a9
...
...
@@ -919,6 +919,84 @@ func TestDbHexArgs(t *testing.T) {
}
}
func
TestDbHexArgsInvalid
(
t
*
testing
.
T
)
{
input
:=
`{}`
args
:=
new
(
DbHexArgs
)
str
:=
ExpectDecodeParamError
(
json
.
Unmarshal
([]
byte
(
input
),
&
args
))
if
len
(
str
)
>
0
{
t
.
Error
(
str
)
}
}
func
TestDbHexArgsEmpty
(
t
*
testing
.
T
)
{
input
:=
`[]`
args
:=
new
(
DbHexArgs
)
str
:=
ExpectInsufficientParamsError
(
json
.
Unmarshal
([]
byte
(
input
),
&
args
))
if
len
(
str
)
>
0
{
t
.
Error
(
str
)
}
}
func
TestDbHexArgsDatabaseType
(
t
*
testing
.
T
)
{
input
:=
`[true, "keyval", "valval"]`
args
:=
new
(
DbHexArgs
)
str
:=
ExpectInvalidTypeError
(
json
.
Unmarshal
([]
byte
(
input
),
&
args
))
if
len
(
str
)
>
0
{
t
.
Error
(
str
)
}
}
func
TestDbHexArgsKeyType
(
t
*
testing
.
T
)
{
input
:=
`["dbval", 3, "valval"]`
args
:=
new
(
DbHexArgs
)
str
:=
ExpectInvalidTypeError
(
json
.
Unmarshal
([]
byte
(
input
),
&
args
))
if
len
(
str
)
>
0
{
t
.
Error
(
str
)
}
}
func
TestDbHexArgsValType
(
t
*
testing
.
T
)
{
input
:=
`["dbval", "keyval", {}]`
args
:=
new
(
DbHexArgs
)
str
:=
ExpectInvalidTypeError
(
json
.
Unmarshal
([]
byte
(
input
),
&
args
))
if
len
(
str
)
>
0
{
t
.
Error
(
str
)
}
}
func
TestDbHexArgsDatabaseEmpty
(
t
*
testing
.
T
)
{
input
:=
`["", "keyval", "valval"]`
args
:=
new
(
DbHexArgs
)
if
err
:=
json
.
Unmarshal
([]
byte
(
input
),
&
args
);
err
!=
nil
{
t
.
Error
(
err
.
Error
())
}
str
:=
ExpectValidationError
(
args
.
requirements
())
if
len
(
str
)
>
0
{
t
.
Error
(
str
)
}
}
func
TestDbHexArgsKeyEmpty
(
t
*
testing
.
T
)
{
input
:=
`["dbval", "", "valval"]`
args
:=
new
(
DbHexArgs
)
if
err
:=
json
.
Unmarshal
([]
byte
(
input
),
&
args
);
err
!=
nil
{
t
.
Error
(
err
.
Error
())
}
str
:=
ExpectValidationError
(
args
.
requirements
())
if
len
(
str
)
>
0
{
t
.
Error
(
str
)
}
}
func
TestWhisperMessageArgs
(
t
*
testing
.
T
)
{
input
:=
`[{"from":"0xc931d93e97ab07fe42d923478ba2465f2",
"topics": ["0x68656c6c6f20776f726c64"],
...
...
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