TestNewHashFromStr executes tests against the NewHashFromStr function.
(t *testing.T)
| 144 | |
| 145 | // TestNewHashFromStr executes tests against the NewHashFromStr function. |
| 146 | func 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 |
nothing calls this directly
no test coverage detected