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
1fe70a66
Commit
1fe70a66
authored
May 08, 2015
by
Daniel A. Nagy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Signature test.
parent
62dd9833
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
0 deletions
+28
-0
js_test.go
cmd/geth/js_test.go
+28
-0
No files found.
cmd/geth/js_test.go
View file @
1fe70a66
...
...
@@ -29,6 +29,8 @@ const (
testKey
=
"e6fab74a43941f82d89cb7faa408e227cdad3153c4720e540e855c19b15e6674"
testAddress
=
"0x8605cdbbdb6d264aa742e77020dcbc58fcdce182"
testBalance
=
"10000000000000000000"
// of empty string
testHash
=
"0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470"
)
var
(
...
...
@@ -215,6 +217,32 @@ func TestCheckTestAccountBalance(t *testing.T) {
checkEvalJSON
(
t
,
repl
,
`eth.getBalance(primary)`
,
`"`
+
testBalance
+
`"`
)
}
func
TestSignature
(
t
*
testing
.
T
)
{
tmp
,
repl
,
ethereum
:=
testJEthRE
(
t
)
if
err
:=
ethereum
.
Start
();
err
!=
nil
{
t
.
Errorf
(
"error starting ethereum: %v"
,
err
)
return
}
defer
ethereum
.
Stop
()
defer
os
.
RemoveAll
(
tmp
)
val
,
err
:=
repl
.
re
.
Run
(
`eth.sign({from: "`
+
testAddress
+
`", data: "`
+
testHash
+
`"})`
)
// This is a very preliminary test, lacking actual signature verification
if
err
!=
nil
{
t
.
Errorf
(
"Error runnig js: %v"
,
err
)
return
}
output
:=
val
.
String
()
t
.
Logf
(
"Output: %v"
,
output
)
regex
:=
regexp
.
MustCompile
(
`^0x[0-9a-f]{130}$`
)
if
!
regex
.
MatchString
(
output
)
{
t
.
Errorf
(
"Signature is not 65 bytes represented in hexadecimal."
)
return
}
}
func
TestContract
(
t
*
testing
.
T
)
{
tmp
,
repl
,
ethereum
:=
testJEthRE
(
t
)
...
...
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