(t *testing.T)
| 10 | ) |
| 11 | |
| 12 | func 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 | } |
nothing calls this directly
no test coverage detected