| 177 | } |
| 178 | |
| 179 | func TestReadBits(t *testing.T) { |
| 180 | check := func(input string) { |
| 181 | want, _ := hex.DecodeString(input) |
| 182 | int, _ := new(big.Int).SetString(input, 16) |
| 183 | buf := make([]byte, len(want)) |
| 184 | ReadBits(int, buf) |
| 185 | if !bytes.Equal(buf, want) { |
| 186 | t.Errorf("have: %x\nwant: %x", buf, want) |
| 187 | } |
| 188 | } |
| 189 | check("000000000000000000000000000000000000000000000000000000FEFCF3F8F0") |
| 190 | check("0000000000012345000000000000000000000000000000000000FEFCF3F8F0") |
| 191 | check("18F8F8F1000111000110011100222004330052300000000000000000FEFCF3F8F0") |
| 192 | } |
| 193 | |
| 194 | func TestU256(t *testing.T) { |
| 195 | tests := []struct{ x, y *big.Int }{ |