loopdb: store outgoing channel set

Upgrade the database schema to allow for multiple outgoing channels.
This is implemented as an on-the-fly migration leaving the old key in
place.
This commit is contained in:
Joost Jager 2020-05-19 09:54:27 +02:00
parent 044c1c12dd
commit 8c544bf2ba
No known key found for this signature in database
GPG key ID: A61B9D4C393C59C7
9 changed files with 188 additions and 38 deletions

View file

@ -3,6 +3,7 @@ package loop
import (
"context"
"errors"
"reflect"
"testing"
"time"
@ -47,8 +48,11 @@ func TestLoopOutPaymentParameters(t *testing.T) {
const maxParts = 5
// Initiate the swap.
req := *testRequest
req.OutgoingChanSet = loopdb.ChannelSet{2, 3}
swap, err := newLoopOutSwap(
context.Background(), cfg, height, testRequest,
context.Background(), cfg, height, &req,
)
if err != nil {
t.Fatal(err)
@ -99,6 +103,13 @@ func TestLoopOutPaymentParameters(t *testing.T) {
maxParts, swapPayment.MaxParts)
}
// Verify the outgoing channel set restriction.
if !reflect.DeepEqual(
[]uint64(req.OutgoingChanSet), swapPayment.OutgoingChanIds,
) {
t.Fatalf("Unexpected outgoing channel set")
}
// Swap is expected to register for confirmation of the htlc. Assert
// this to prevent a blocked channel in the mock.
ctx.AssertRegisterConf()