| 129 | } |
| 130 | |
| 131 | func TestBlockScan(t *testing.T) { |
| 132 | block := testBlock() |
| 133 | |
| 134 | wantBytes, err := block.Bytes() |
| 135 | if err != nil { |
| 136 | t.Fatal(err) |
| 137 | } |
| 138 | |
| 139 | gotVal, err := block.Value() |
| 140 | if err != nil { |
| 141 | t.Fatal(err) |
| 142 | } |
| 143 | gotBytes, ok := gotVal.([]byte) |
| 144 | if !ok { |
| 145 | t.Fatal("expected bytes from Value") |
| 146 | } |
| 147 | |
| 148 | if !bytes.Equal(wantBytes, gotBytes) { |
| 149 | t.Errorf("Value(%v):\ngot: %x\n\twant: %x", block, gotBytes, wantBytes) |
| 150 | } |
| 151 | |
| 152 | gotBlock := new(Block) |
| 153 | err = gotBlock.Scan(wantBytes) |
| 154 | if err != nil { |
| 155 | t.Fatal(err) |
| 156 | } |
| 157 | |
| 158 | if !testutil.DeepEqual(gotBlock, block) { |
| 159 | t.Errorf("Scan(%x):\ngot: %v\n\twant: %v", wantBytes, gotBlock, block) |
| 160 | } |
| 161 | } |
| 162 | |
| 163 | func TestSignBlock(t *testing.T) { |
| 164 | var ( |