MCPcopy Create free account
hub / github.com/chain/txvm / TestHashBytes

Function TestHashBytes

protocol/bc/hash_test.go:8–25  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

6)
7
8func TestHashBytes(t *testing.T) {
9 bits := [32]byte{
10 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
11 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
12 }
13 hash := NewHash(bits)
14
15 gotBits := hash.Byte32()
16 if !bytes.Equal(bits[:], gotBits[:]) {
17 t.Errorf("NewHash(%x).Byte32 = %x", bits, gotBits)
18 }
19
20 hash = HashFromBytes(bits[:])
21 gotBits = hash.Byte32()
22 if !bytes.Equal(bits[:], gotBits[:]) {
23 t.Errorf("HashFromBytes(%x).Byte32 = %x", bits, gotBits)
24 }
25}
26
27func TestHashMarshalText(t *testing.T) {
28 hash := NewHash([32]byte{1})

Callers

nothing calls this directly

Calls 4

Byte32Method · 0.95
NewHashFunction · 0.85
HashFromBytesFunction · 0.85
EqualMethod · 0.80

Tested by

no test coverage detected