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

Function TestHashScan

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

Source from the content-addressed store, hash-verified

107}
108
109func TestHashScan(t *testing.T) {
110 cases := []struct {
111 encoded interface{}
112 want Hash
113 wantErr bool
114 }{{
115 encoded: int64(1),
116 wantErr: true,
117 }, {
118 encoded: []byte("short"),
119 wantErr: true,
120 }, {
121 encoded: mustDecodeHex("0100000000000000000000000000000000000000000000000000000000000000"),
122 want: NewHash([32]byte{1}),
123 }}
124
125 for _, c := range cases {
126 var got Hash
127 err := got.Scan(c.encoded)
128 if err != nil && !c.wantErr {
129 t.Errorf("Scan(%v) error = %v want nil", c.encoded, err)
130 }
131 if got != c.want {
132 t.Errorf("Scan(%v) = %x want %x", c.encoded, got.Bytes(), c.want.Bytes())
133 }
134 }
135}
136
137func TestHashReadFrom(t *testing.T) {
138 cases := []struct {

Callers

nothing calls this directly

Calls 4

ScanMethod · 0.95
BytesMethod · 0.95
NewHashFunction · 0.85
mustDecodeHexFunction · 0.70

Tested by

no test coverage detected