MCPcopy Create free account
hub / github.com/GoEdgeLab/EdgeNode / TestMetaBlock

Function TestMetaBlock

internal/utils/bfs/meta_block_test.go:12–52  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

10)
11
12func TestMetaBlock(t *testing.T) {
13 var a = assert.NewAssertion(t)
14
15 {
16 var srcHash = bfs.Hash("a")
17 b, err := bfs.EncodeMetaBlock(bfs.MetaActionNew, srcHash, []byte{1, 2, 3})
18 if err != nil {
19 t.Fatal(err)
20 }
21 t.Log(b)
22
23 {
24 action, hash, data, decodeErr := bfs.DecodeMetaBlock(b)
25 if decodeErr != nil {
26 t.Fatal(err)
27 }
28 a.IsTrue(action == bfs.MetaActionNew)
29 a.IsTrue(hash == srcHash)
30 a.IsTrue(bytes.Equal(data, []byte{1, 2, 3}))
31 }
32 }
33
34 {
35 var srcHash = bfs.Hash("bcd")
36
37 b, err := bfs.EncodeMetaBlock(bfs.MetaActionRemove, srcHash, []byte{1, 2, 3})
38 if err != nil {
39 t.Fatal(err)
40 }
41 t.Log(b)
42 {
43 action, hash, data, decodeErr := bfs.DecodeMetaBlock(b)
44 if decodeErr != nil {
45 t.Fatal(err)
46 }
47 a.IsTrue(action == bfs.MetaActionRemove)
48 a.IsTrue(hash == srcHash)
49 a.IsTrue(len(data) == 0)
50 }
51 }
52}

Callers

nothing calls this directly

Calls 4

HashFunction · 0.92
EncodeMetaBlockFunction · 0.92
DecodeMetaBlockFunction · 0.92
LogMethod · 0.80

Tested by

no test coverage detected