(t *testing.T)
| 84 | } |
| 85 | |
| 86 | func TestWaitForBlockSoonWaits(t *testing.T) { |
| 87 | // This test is inherently racy. It's possible |
| 88 | // that the block creation might run before |
| 89 | // the wait's internal test loop finds no block. |
| 90 | // In that case, the test will pass, but it will |
| 91 | // not have tested anything. |
| 92 | // |
| 93 | // It's the best we can do. |
| 94 | |
| 95 | c, _ := newTestChain(t, time.Now()) |
| 96 | makeEmptyBlock(t, c) // height=2 |
| 97 | |
| 98 | go func() { |
| 99 | time.Sleep(10 * time.Millisecond) // sorry for the slow test |
| 100 | makeEmptyBlock(t, c) // height=3 |
| 101 | }() |
| 102 | |
| 103 | err := <-c.BlockSoonWaiter(context.Background(), 3) |
| 104 | if err != nil { |
| 105 | t.Fatal(err) |
| 106 | } |
| 107 | if g := c.Height(); g != 3 { |
| 108 | t.Errorf("height after waiting = %d want 3", g) |
| 109 | } |
| 110 | } |
| 111 | |
| 112 | func TestWaitForBlockSoonTimesout(t *testing.T) { |
| 113 | c, _ := newTestChain(t, time.Now()) |
nothing calls this directly
no test coverage detected