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

Function TestNewChainHeight

protocol/protocol_test.go:11–31  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

9)
10
11func TestNewChainHeight(t *testing.T) {
12 ctx, cancel := context.WithCancel(context.Background())
13
14 block := &bc.Block{UnsignedBlock: &bc.UnsignedBlock{BlockHeader: &bc.BlockHeader{NextPredicate: &bc.Predicate{}}}}
15 heights := make(chan uint64, 4)
16 c, err := NewChain(ctx, block, memstore.New(), heights)
17 if err != nil {
18 t.Fatal(err)
19 }
20
21 heights <- 1
22 heights <- 2
23 heights <- 0
24 heights <- 3
25
26 <-c.BlockWaiter(3)
27 if got := c.Height(); got != 3 {
28 t.Errorf("c.Height() = %d, want %d", got, 3)
29 }
30 cancel()
31}

Callers

nothing calls this directly

Calls 4

BlockWaiterMethod · 0.95
HeightMethod · 0.95
NewFunction · 0.92
NewChainFunction · 0.70

Tested by

no test coverage detected