add tmhash

This commit is contained in:
Ethan Buchman
2018-05-22 12:46:15 -04:00
parent 134fdf7169
commit 4663ffdf08
5 changed files with 75 additions and 11 deletions

23
tmhash/hash_test.go Normal file
View File

@ -0,0 +1,23 @@
package tmhash_test
import (
"crypto/sha256"
"testing"
"github.com/stretchr/testify/assert"
"github.com/tendermint/go-crypto/tmhash"
)
func TestHash(t *testing.T) {
testVector := []byte("abc")
hasher := tmhash.New()
hasher.Write(testVector)
bz := hasher.Sum(nil)
hasher = sha256.New()
hasher.Write(testVector)
bz2 := hasher.Sum(nil)
bz2 = bz2[:20]
assert.Equal(t, bz, bz2)
}