MCPcopy Index your code
hub / github.com/CovenantSQL/CovenantSQL / TestNewHashFromStr

Function TestNewHashFromStr

crypto/hash/hash_test.go:146–229  ·  view source on GitHub ↗

TestNewHashFromStr executes tests against the NewHashFromStr function.

(t *testing.T)

Source from the content-addressed store, hash-verified

144
145// TestNewHashFromStr executes tests against the NewHashFromStr function.
146func TestNewHashFromStr(t *testing.T) {
147 tests := []struct {
148 in string
149 want Hash
150 err error
151 }{
152 // Genesis hash.
153 {
154 "000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f",
155 mainNetGenesisHash,
156 nil,
157 },
158
159 // Genesis hash with stripped leading zeros.
160 {
161 "19d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f",
162 mainNetGenesisHash,
163 nil,
164 },
165
166 // Empty string.
167 {
168 "",
169 Hash{},
170 nil,
171 },
172
173 // Single digit hash.
174 {
175 "1",
176 Hash([HashSize]byte{ // Make go vet happy.
177 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
178 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
179 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
180 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
181 }),
182 nil,
183 },
184
185 // Block 203707 with stripped leading zeros.
186 {
187 "3264bc2ac36a60840790ba1d475d01367e7c723da941069e9dc",
188 Hash([HashSize]byte{ // Make go vet happy.
189 0xdc, 0xe9, 0x69, 0x10, 0x94, 0xda, 0x23, 0xc7,
190 0xe7, 0x67, 0x13, 0xd0, 0x75, 0xd4, 0xa1, 0x0b,
191 0x79, 0x40, 0x08, 0xa6, 0x36, 0xac, 0xc2, 0x4b,
192 0x26, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
193 }),
194 nil,
195 },
196
197 // Hash string that is too long.
198 {
199 "01234567890123456789012345678901234567890123456789012345678912345",
200 Hash{},
201 ErrHashStrSize,
202 },
203

Callers

nothing calls this directly

Calls 4

HashTypeAlias · 0.85
NewHashFromStrFunction · 0.85
ErrorfMethod · 0.80
IsEqualMethod · 0.45

Tested by

no test coverage detected