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

Function TestBlockScan

protocol/bc/block_test.go:131–161  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

129}
130
131func 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
163func TestSignBlock(t *testing.T) {
164 var (

Callers

nothing calls this directly

Calls 6

DeepEqualFunction · 0.92
testBlockFunction · 0.85
EqualMethod · 0.80
BytesMethod · 0.45
ValueMethod · 0.45
ScanMethod · 0.45

Tested by

no test coverage detected