diff options
author | Daniel A. Nagy <nagy.da@gmail.com> | 2015-05-09 01:37:35 +0800 |
---|---|---|
committer | Daniel A. Nagy <nagy.da@gmail.com> | 2015-05-09 01:37:35 +0800 |
commit | 1fe70a66ba2ef0f148affa7a72b4e65023474859 (patch) | |
tree | 1835492907c5b7fdf3b46091c785649c3c49dd72 | |
parent | 62dd9833ec768e2026bccb1cf7a8ef4263b9286d (diff) | |
download | dexon-1fe70a66ba2ef0f148affa7a72b4e65023474859.tar dexon-1fe70a66ba2ef0f148affa7a72b4e65023474859.tar.gz dexon-1fe70a66ba2ef0f148affa7a72b4e65023474859.tar.bz2 dexon-1fe70a66ba2ef0f148affa7a72b4e65023474859.tar.lz dexon-1fe70a66ba2ef0f148affa7a72b4e65023474859.tar.xz dexon-1fe70a66ba2ef0f148affa7a72b4e65023474859.tar.zst dexon-1fe70a66ba2ef0f148affa7a72b4e65023474859.zip |
Signature test.
-rw-r--r-- | cmd/geth/js_test.go | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/cmd/geth/js_test.go b/cmd/geth/js_test.go index 5587fe2b2..0c54f21dd 100644 --- a/cmd/geth/js_test.go +++ b/cmd/geth/js_test.go @@ -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) |