router test: only cleanup if context creation succeeds

This commit is contained in:
Johan T. Halseth 2018-12-04 11:20:37 +01:00
parent 45f49899ae
commit 87df6b71c5
No known key found for this signature in database
GPG Key ID: 15BAADA29DA20D26

@ -170,10 +170,10 @@ func TestFindRoutesFeeSorting(t *testing.T) {
const startingBlockHeight = 101
ctx, cleanUp, err := createTestCtxFromFile(startingBlockHeight, basicGraphFilePath)
defer cleanUp()
if err != nil {
t.Fatalf("unable to create router: %v", err)
}
defer cleanUp()
// In this test we'd like to ensure proper integration of the various
// functions that are involved in path finding, and also route
@ -225,10 +225,10 @@ func TestFindRoutesWithFeeLimit(t *testing.T) {
ctx, cleanUp, err := createTestCtxFromFile(
startingBlockHeight, basicGraphFilePath,
)
defer cleanUp()
if err != nil {
t.Fatalf("unable to create router: %v", err)
}
defer cleanUp()
// This test will attempt to find routes from roasbeef to sophon for 100
// satoshis with a fee limit of 10 satoshis. There are two routes from
@ -280,10 +280,10 @@ func TestSendPaymentRouteFailureFallback(t *testing.T) {
const startingBlockHeight = 101
ctx, cleanUp, err := createTestCtxFromFile(startingBlockHeight, basicGraphFilePath)
defer cleanUp()
if err != nil {
t.Fatalf("unable to create router: %v", err)
}
defer cleanUp()
// Craft a LightningPayment struct that'll send a payment from roasbeef
// to luo ji for 1000 satoshis, with a maximum of 1000 satoshis in fees.
@ -516,10 +516,10 @@ func TestSendPaymentErrorRepeatedFeeInsufficient(t *testing.T) {
const startingBlockHeight = 101
ctx, cleanUp, err := createTestCtxFromFile(startingBlockHeight, basicGraphFilePath)
defer cleanUp()
if err != nil {
t.Fatalf("unable to create router: %v", err)
}
defer cleanUp()
// Craft a LightningPayment struct that'll send a payment from roasbeef
// to luo ji for 100 satoshis.
@ -620,10 +620,10 @@ func TestSendPaymentErrorNonFinalTimeLockErrors(t *testing.T) {
const startingBlockHeight = 101
ctx, cleanUp, err := createTestCtxFromFile(startingBlockHeight, basicGraphFilePath)
defer cleanUp()
if err != nil {
t.Fatalf("unable to create router: %v", err)
}
defer cleanUp()
// Craft a LightningPayment struct that'll send a payment from roasbeef
// to sophon for 1k satoshis.
@ -755,10 +755,10 @@ func TestSendPaymentErrorPathPruning(t *testing.T) {
const startingBlockHeight = 101
ctx, cleanUp, err := createTestCtxFromFile(startingBlockHeight, basicGraphFilePath)
defer cleanUp()
if err != nil {
t.Fatalf("unable to create router: %v", err)
}
defer cleanUp()
// Craft a LightningPayment struct that'll send a payment from roasbeef
// to luo ji for 1000 satoshis, with a maximum of 1000 satoshis in fees.
@ -997,10 +997,10 @@ func TestIgnoreNodeAnnouncement(t *testing.T) {
const startingBlockHeight = 101
ctx, cleanUp, err := createTestCtxFromFile(startingBlockHeight,
basicGraphFilePath)
defer cleanUp()
if err != nil {
t.Fatalf("unable to create router: %v", err)
}
defer cleanUp()
pub := priv1.PubKey()
node := &channeldb.LightningNode{
@ -1030,10 +1030,10 @@ func TestAddEdgeUnknownVertexes(t *testing.T) {
const startingBlockHeight = 101
ctx, cleanUp, err := createTestCtxFromFile(startingBlockHeight,
basicGraphFilePath)
defer cleanUp()
if err != nil {
t.Fatalf("unable to create router: %v", err)
}
defer cleanUp()
var pub1 [33]byte
copy(pub1[:], priv1.PubKey().SerializeCompressed())
@ -1299,10 +1299,10 @@ func TestWakeUpOnStaleBranch(t *testing.T) {
const startingBlockHeight = 101
ctx, cleanUp, err := createTestCtxSingleNode(startingBlockHeight)
defer cleanUp()
if err != nil {
t.Fatalf("unable to create router: %v", err)
}
defer cleanUp()
const chanValue = 10000
@ -1502,10 +1502,10 @@ func TestDisconnectedBlocks(t *testing.T) {
const startingBlockHeight = 101
ctx, cleanUp, err := createTestCtxSingleNode(startingBlockHeight)
defer cleanUp()
if err != nil {
t.Fatalf("unable to create router: %v", err)
}
defer cleanUp()
const chanValue = 10000
@ -1692,10 +1692,10 @@ func TestRouterChansClosedOfflinePruneGraph(t *testing.T) {
const startingBlockHeight = 101
ctx, cleanUp, err := createTestCtxSingleNode(startingBlockHeight)
defer cleanUp()
if err != nil {
t.Fatalf("unable to create router: %v", err)
}
defer cleanUp()
const chanValue = 10000
@ -1845,10 +1845,10 @@ func TestFindPathFeeWeighting(t *testing.T) {
const startingBlockHeight = 101
ctx, cleanUp, err := createTestCtxFromFile(startingBlockHeight, basicGraphFilePath)
defer cleanUp()
if err != nil {
t.Fatalf("unable to create router: %v", err)
}
defer cleanUp()
var preImage [32]byte
copy(preImage[:], bytes.Repeat([]byte{9}, 32))
@ -1903,10 +1903,10 @@ func TestIsStaleNode(t *testing.T) {
const startingBlockHeight = 101
ctx, cleanUp, err := createTestCtxSingleNode(startingBlockHeight)
defer cleanUp()
if err != nil {
t.Fatalf("unable to create router: %v", err)
}
defer cleanUp()
// Before we can insert a node in to the database, we need to create a
// channel that it's linked to.
@ -1985,10 +1985,10 @@ func TestIsKnownEdge(t *testing.T) {
const startingBlockHeight = 101
ctx, cleanUp, err := createTestCtxSingleNode(startingBlockHeight)
defer cleanUp()
if err != nil {
t.Fatalf("unable to create router: %v", err)
}
defer cleanUp()
// First, we'll create a new channel edge (just the info) and insert it
// into the database.
@ -2038,10 +2038,10 @@ func TestIsStaleEdgePolicy(t *testing.T) {
const startingBlockHeight = 101
ctx, cleanUp, err := createTestCtxFromFile(startingBlockHeight,
basicGraphFilePath)
defer cleanUp()
if err != nil {
t.Fatalf("unable to create router: %v", err)
}
defer cleanUp()
// First, we'll create a new channel edge (just the info) and insert it
// into the database.