aboutsummaryrefslogtreecommitdiffstats
path: root/crypto/crypto_test.go
diff options
context:
space:
mode:
authorYondon Fu <yondon.fu@gmail.com>2017-12-19 06:17:41 +0800
committerYondon Fu <yondon.fu@gmail.com>2017-12-19 06:17:41 +0800
commit3857cdc267e3192697f561df0a0f827f65dfb6b5 (patch)
tree401c52c4972a68229ea283a394a0b0a5f3cfdc8e /crypto/crypto_test.go
parenta5330fe0c569b75cb8a524f60f7e8dc06498262b (diff)
parentfe070ab5c32702033489f1b9d1655ea1b894c29e (diff)
downloaddexon-3857cdc267e3192697f561df0a0f827f65dfb6b5.tar
dexon-3857cdc267e3192697f561df0a0f827f65dfb6b5.tar.gz
dexon-3857cdc267e3192697f561df0a0f827f65dfb6b5.tar.bz2
dexon-3857cdc267e3192697f561df0a0f827f65dfb6b5.tar.lz
dexon-3857cdc267e3192697f561df0a0f827f65dfb6b5.tar.xz
dexon-3857cdc267e3192697f561df0a0f827f65dfb6b5.tar.zst
dexon-3857cdc267e3192697f561df0a0f827f65dfb6b5.zip
Merge branch 'master' into abi-offset-fixed-arrays
Diffstat (limited to 'crypto/crypto_test.go')
-rw-r--r--crypto/crypto_test.go17
1 files changed, 10 insertions, 7 deletions
diff --git a/crypto/crypto_test.go b/crypto/crypto_test.go
index 92302948e..835035462 100644
--- a/crypto/crypto_test.go
+++ b/crypto/crypto_test.go
@@ -20,12 +20,10 @@ import (
"bytes"
"crypto/ecdsa"
"encoding/hex"
- "fmt"
"io/ioutil"
"math/big"
"os"
"testing"
- "time"
"github.com/ethereum/go-ethereum/common"
)
@@ -42,15 +40,20 @@ func TestKeccak256Hash(t *testing.T) {
checkhash(t, "Sha3-256-array", func(in []byte) []byte { h := Keccak256Hash(in); return h[:] }, msg, exp)
}
+func TestToECDSAErrors(t *testing.T) {
+ if _, err := HexToECDSA("0000000000000000000000000000000000000000000000000000000000000000"); err == nil {
+ t.Fatal("HexToECDSA should've returned error")
+ }
+ if _, err := HexToECDSA("ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"); err == nil {
+ t.Fatal("HexToECDSA should've returned error")
+ }
+}
+
func BenchmarkSha3(b *testing.B) {
a := []byte("hello world")
- amount := 1000000
- start := time.Now()
- for i := 0; i < amount; i++ {
+ for i := 0; i < b.N; i++ {
Keccak256(a)
}
-
- fmt.Println(amount, ":", time.Since(start))
}
func TestSign(t *testing.T) {