diff --git a/pkg/crypto/hash/hash_test.go b/pkg/crypto/hash/hash_test.go index 272b744fd..105bfd4b6 100644 --- a/pkg/crypto/hash/hash_test.go +++ b/pkg/crypto/hash/hash_test.go @@ -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))) + } +}