Merge pull request #1745 from halseth/channeldb-avoid-create-buckets

channeldb: avoid creating empty buckets
This commit is contained in:
Olaoluwa Osuntokun
2018-12-17 20:01:29 -08:00
committed by GitHub
3 changed files with 87 additions and 77 deletions

View File

@ -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.
@ -519,10 +519,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.
@ -623,10 +623,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.
@ -758,10 +758,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.
@ -1000,10 +1000,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{
@ -1033,10 +1033,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())
@ -1302,10 +1302,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
@ -1505,10 +1505,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
@ -1695,10 +1695,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
@ -1848,10 +1848,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))
@ -1906,10 +1906,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.
@ -1988,10 +1988,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.
@ -2041,10 +2041,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.