forked from TrueCloudLab/neoneo-go
crypto: add missing tests for hash pkg
This commit is contained in:
parent
2d41450ac9
commit
4d82419776
1 changed files with 17 additions and 0 deletions
|
@ -1,10 +1,12 @@
|
|||
package hash
|
||||
|
||||
import (
|
||||
"encoding/binary"
|
||||
"encoding/hex"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestSha256(t *testing.T) {
|
||||
|
@ -47,3 +49,18 @@ func TestHash160(t *testing.T) {
|
|||
actual := hex.EncodeToString(data.Bytes())
|
||||
assert.Equal(t, expected, actual)
|
||||
}
|
||||
|
||||
func TestChecksum(t *testing.T) {
|
||||
testCases := []struct {
|
||||
data []byte
|
||||
sum uint32
|
||||
}{
|
||||
{nil, 0xe2e0f65d},
|
||||
{[]byte{}, 0xe2e0f65d},
|
||||
{[]byte{1, 2, 3, 4}, 0xe272e48d},
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
require.Equal(t, tc.sum, binary.LittleEndian.Uint32(Checksum(tc.data)))
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue