(t *testing.T)
| 93 | } |
| 94 | |
| 95 | func TestAncestor(t *testing.T) { |
| 96 | index := newBlockIndex() |
| 97 | parent := (*blockNode)(nil) |
| 98 | |
| 99 | for h, b := range testBlocks { |
| 100 | bn := newBlockNode(int32(h), b, parent) |
| 101 | index.addBlock(bn) |
| 102 | parent = bn |
| 103 | } |
| 104 | |
| 105 | for i, b := range testBlocks { |
| 106 | bn := index.lookupNode(b.BlockHash()) |
| 107 | |
| 108 | if bn == nil { |
| 109 | t.Fatalf("unexpected loopup result: %v", bn) |
| 110 | } |
| 111 | |
| 112 | for j := int32(i - 1); j < int32(i+1); j++ { |
| 113 | a := bn.ancestor(j) |
| 114 | |
| 115 | if j < 0 || j > bn.count { |
| 116 | if a != nil { |
| 117 | t.Fatalf("unexpected ancestor: %v", a) |
| 118 | } |
| 119 | } else { |
| 120 | if a.count != j { |
| 121 | t.Fatalf("unexpected ancestor height: got %d while expecting %d", a.count, j) |
| 122 | } |
| 123 | } |
| 124 | } |
| 125 | } |
| 126 | } |
| 127 | |
| 128 | func TestIndex(t *testing.T) { |
| 129 | index := newBlockIndex() |
nothing calls this directly
no test coverage detected