mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-01-19 05:45:21 +01:00
utxonursery: assert empty database
This commit is contained in:
parent
b5da791271
commit
b89db6d614
@ -7,6 +7,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"github.com/lightningnetwork/lnd/channeldb"
|
"github.com/lightningnetwork/lnd/channeldb"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
"math"
|
||||||
"reflect"
|
"reflect"
|
||||||
"sync"
|
"sync"
|
||||||
"testing"
|
"testing"
|
||||||
@ -515,7 +516,8 @@ func (ctx *nurseryTestContext) finish() {
|
|||||||
select {
|
select {
|
||||||
case <-signalChan:
|
case <-signalChan:
|
||||||
case <-time.After(time.Second):
|
case <-time.After(time.Second):
|
||||||
ctx.t.Fatalf("lingering goroutines detected after test is finished")
|
ctx.t.Fatalf("lingering goroutines detected after test " +
|
||||||
|
"is finished")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Restore waitgroup state to what it was before.
|
// Restore waitgroup state to what it was before.
|
||||||
@ -530,6 +532,25 @@ func (ctx *nurseryTestContext) finish() {
|
|||||||
ctx.t.Fatalf("unexpected transactions published")
|
ctx.t.Fatalf("unexpected transactions published")
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Assert that the database is empty. All channels removed and height
|
||||||
|
// index cleared.
|
||||||
|
nurseryChannels, err := ctx.nursery.cfg.Store.ListChannels()
|
||||||
|
if err != nil {
|
||||||
|
ctx.t.Fatal(err)
|
||||||
|
}
|
||||||
|
if len(nurseryChannels) > 0 {
|
||||||
|
ctx.t.Fatalf("Expected all channels to be removed from store")
|
||||||
|
}
|
||||||
|
|
||||||
|
activeHeights, err := ctx.nursery.cfg.Store.HeightsBelowOrEqual(
|
||||||
|
math.MaxUint32)
|
||||||
|
if err != nil {
|
||||||
|
ctx.t.Fatal(err)
|
||||||
|
}
|
||||||
|
if len(activeHeights) > 0 {
|
||||||
|
ctx.t.Fatalf("Expected height index to be empty")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func createOutgoingRes(onLocalCommitment bool) *lnwallet.OutgoingHtlcResolution {
|
func createOutgoingRes(onLocalCommitment bool) *lnwallet.OutgoingHtlcResolution {
|
||||||
|
Loading…
Reference in New Issue
Block a user