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

Function TestBlockHeaderScanValue

protocol/bc/blockheader_test.go:51–79  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

49}
50
51func TestBlockHeaderScanValue(t *testing.T) {
52 filledBytes := mustDecodeHex("080310011a0909000000000000000120e80728d0860330013a0909000000000000000242090900000000000000034a090900000000000000045246080110011a4000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000")
53 val, err := filledBlock.Value()
54 if err != nil {
55 t.Fatal(err)
56 }
57 vBytes, ok := val.([]byte)
58 if !ok {
59 t.Fatal("expected value to return byte slice")
60 }
61 if !bytes.Equal(vBytes, filledBytes) {
62 t.Errorf("Value(emptyBlock):\n\tgot: %x\n\twant: %x", vBytes, filledBytes)
63 }
64
65 scanned := new(BlockHeader)
66 err = scanned.Scan(vBytes)
67 if err != nil {
68 t.Fatal(err)
69 }
70
71 if !testutil.DeepEqual(scanned, filledBlock) {
72 t.Errorf("Scan(%x):\n\tgot: %v\n\twant: %v", vBytes, scanned, filledBlock)
73 }
74
75 err = scanned.Scan(int64(5))
76 if err == nil {
77 t.Fatal("expected error for scanning bad Value type")
78 }
79}
80
81func hashPtr(hash Hash) *Hash { return &hash }

Callers

nothing calls this directly

Calls 5

DeepEqualFunction · 0.92
EqualMethod · 0.80
mustDecodeHexFunction · 0.70
ValueMethod · 0.45
ScanMethod · 0.45

Tested by

no test coverage detected