routing: update tests to adhere to new newMockChainView API
This commit is contained in:
parent
3be905109c
commit
2824f45aad
@ -104,7 +104,7 @@ func createTestCtx(startingHeight uint32, testGraph ...string) (*testCtx, func()
|
|||||||
// any p2p functionality, the peer send and switch send messages won't
|
// any p2p functionality, the peer send and switch send messages won't
|
||||||
// be populated.
|
// be populated.
|
||||||
chain := newMockChain(startingHeight)
|
chain := newMockChain(startingHeight)
|
||||||
chainView := newMockChainView()
|
chainView := newMockChainView(chain)
|
||||||
router, err := New(Config{
|
router, err := New(Config{
|
||||||
Graph: graph,
|
Graph: graph,
|
||||||
Chain: chain,
|
Chain: chain,
|
||||||
@ -123,18 +123,20 @@ func createTestCtx(startingHeight uint32, testGraph ...string) (*testCtx, func()
|
|||||||
return nil, nil, fmt.Errorf("unable to start router: %v", err)
|
return nil, nil, fmt.Errorf("unable to start router: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
cleanUp := func() {
|
ctx := &testCtx{
|
||||||
router.Stop()
|
|
||||||
cleanup()
|
|
||||||
}
|
|
||||||
|
|
||||||
return &testCtx{
|
|
||||||
router: router,
|
router: router,
|
||||||
graph: graph,
|
graph: graph,
|
||||||
aliases: aliasMap,
|
aliases: aliasMap,
|
||||||
chain: chain,
|
chain: chain,
|
||||||
chainView: chainView,
|
chainView: chainView,
|
||||||
}, cleanUp, nil
|
}
|
||||||
|
|
||||||
|
cleanUp := func() {
|
||||||
|
ctx.router.Stop()
|
||||||
|
cleanup()
|
||||||
|
}
|
||||||
|
|
||||||
|
return ctx, cleanUp, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// TestFindRoutesFeeSorting asserts that routes found by the FindRoutes method
|
// TestFindRoutesFeeSorting asserts that routes found by the FindRoutes method
|
||||||
@ -956,8 +958,8 @@ func TestWakeUpOnStaleBranch(t *testing.T) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// TestDisconnectedBlocks checks that the router handles a reorg happening
|
// TestDisconnectedBlocks checks that the router handles a reorg happening when
|
||||||
// when it is active.
|
// it is active.
|
||||||
func TestDisconnectedBlocks(t *testing.T) {
|
func TestDisconnectedBlocks(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
@ -970,11 +972,8 @@ func TestDisconnectedBlocks(t *testing.T) {
|
|||||||
|
|
||||||
const chanValue = 10000
|
const chanValue = 10000
|
||||||
|
|
||||||
// chanID1 will not be reorged out.
|
// chanID1 will not be reorged out, while chanID2 will be reorged out.
|
||||||
var chanID1 uint64
|
var chanID1, chanID2 uint64
|
||||||
|
|
||||||
// chanID2 will be reorged out.
|
|
||||||
var chanID2 uint64
|
|
||||||
|
|
||||||
// Create 10 common blocks, confirming chanID1.
|
// Create 10 common blocks, confirming chanID1.
|
||||||
for i := uint32(1); i <= 10; i++ {
|
for i := uint32(1); i <= 10; i++ {
|
||||||
@ -1101,10 +1100,9 @@ func TestDisconnectedBlocks(t *testing.T) {
|
|||||||
t.Fatalf("could not find edge in graph")
|
t.Fatalf("could not find edge in graph")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a 15 block fork. We first let the chainView notify the
|
// Create a 15 block fork. We first let the chainView notify the router
|
||||||
// router about stale blocks, before sending the now connected
|
// about stale blocks, before sending the now connected blocks. We do
|
||||||
// blocks. We do this because we expect this order from the
|
// this because we expect this order from the chainview.
|
||||||
// chainview.
|
|
||||||
for i := len(minorityChain) - 1; i >= 0; i-- {
|
for i := len(minorityChain) - 1; i >= 0; i-- {
|
||||||
block := minorityChain[i]
|
block := minorityChain[i]
|
||||||
height := uint32(forkHeight) + uint32(i) + 1
|
height := uint32(forkHeight) + uint32(i) + 1
|
||||||
@ -1125,8 +1123,8 @@ func TestDisconnectedBlocks(t *testing.T) {
|
|||||||
// Give time to process new blocks
|
// Give time to process new blocks
|
||||||
time.Sleep(time.Millisecond * 500)
|
time.Sleep(time.Millisecond * 500)
|
||||||
|
|
||||||
// The with chanID2 should not be in the database anymore, since it is
|
// chanID2 should not be in the database anymore, since it is not
|
||||||
// not confirmed on the longest chain. chanID1 should still be.
|
// confirmed on the longest chain. chanID1 should still be.
|
||||||
_, _, has, err = ctx.graph.HasChannelEdge(chanID1)
|
_, _, has, err = ctx.graph.HasChannelEdge(chanID1)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("error looking for edge: %v", chanID1)
|
t.Fatalf("error looking for edge: %v", chanID1)
|
||||||
|
Loading…
Reference in New Issue
Block a user