diff options
author | Taylor Gerring <taylor.gerring@gmail.com> | 2015-02-02 21:22:20 +0800 |
---|---|---|
committer | Taylor Gerring <taylor.gerring@gmail.com> | 2015-02-02 21:22:20 +0800 |
commit | 1e60919d47ac2767706c135332a1a4f79bbf3960 (patch) | |
tree | 3db2f5d5446f451d700bf67ef756d85da0fdda25 /crypto/crypto_test.go | |
parent | 313cfba7d43529db647789ae826bc426d9da7de3 (diff) | |
parent | 0d97c3ce1322083fb9683a5afec004b2626b620a (diff) | |
download | go-tangerine-1e60919d47ac2767706c135332a1a4f79bbf3960.tar go-tangerine-1e60919d47ac2767706c135332a1a4f79bbf3960.tar.gz go-tangerine-1e60919d47ac2767706c135332a1a4f79bbf3960.tar.bz2 go-tangerine-1e60919d47ac2767706c135332a1a4f79bbf3960.tar.lz go-tangerine-1e60919d47ac2767706c135332a1a4f79bbf3960.tar.xz go-tangerine-1e60919d47ac2767706c135332a1a4f79bbf3960.tar.zst go-tangerine-1e60919d47ac2767706c135332a1a4f79bbf3960.zip |
Merge pull request #3 from ethereum/develop
Update to develop
Diffstat (limited to 'crypto/crypto_test.go')
-rw-r--r-- | crypto/crypto_test.go | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/crypto/crypto_test.go b/crypto/crypto_test.go index af62a02a2..441733f93 100644 --- a/crypto/crypto_test.go +++ b/crypto/crypto_test.go @@ -3,7 +3,12 @@ package crypto import ( "bytes" "encoding/hex" + "fmt" "testing" + "time" + + "github.com/ethereum/go-ethereum/crypto/secp256k1" + "github.com/ethereum/go-ethereum/ethutil" ) // These tests are sanity checks. @@ -34,3 +39,36 @@ func checkhash(t *testing.T, name string, f func([]byte) []byte, msg, exp []byte t.Errorf("hash %s returned wrong result.\ngot: %x\nwant: %x", name, sum, exp) } } + +func BenchmarkSha3(b *testing.B) { + a := []byte("hello world") + amount := 1000000 + start := time.Now() + for i := 0; i < amount; i++ { + Sha3(a) + } + + fmt.Println(amount, ":", time.Since(start)) +} + +func Test0Key(t *testing.T) { + t.Skip() + key := ethutil.Hex2Bytes("1111111111111111111111111111111111111111111111111111111111111111") + + p, err := secp256k1.GeneratePubKey(key) + addr := Sha3(p[1:])[12:] + fmt.Printf("%x\n", p) + fmt.Printf("%v %x\n", err, addr) +} + +func TestInvalidSign(t *testing.T) { + _, err := Sign(make([]byte, 1), nil) + if err == nil { + t.Errorf("expected sign with hash 1 byte to error") + } + + _, err = Sign(make([]byte, 33), nil) + if err == nil { + t.Errorf("expected sign with hash 33 byte to error") + } +} |