channeldb: fail migration for accepted hodl invoices
This commit is contained in:
2 files changed
+31
No files matched your search
@@ -69,6 +69,11 @@ func migrateInvoices(tx *bbolt.Tx) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if invoice.Terms.State == ContractAccepted {
|
||||||
|
return fmt.Errorf("cannot upgrade with invoice(s) " +
|
||||||
|
"in accepted state, see release notes")
|
||||||
|
}
|
||||||
|
|
||||||
// Try to decode the payment request for every possible net to
|
// Try to decode the payment request for every possible net to
|
||||||
// avoid passing a the active network to channeldb. This would
|
// avoid passing a the active network to channeldb. This would
|
||||||
// be a layering violation, while this migration is only running
|
// be a layering violation, while this migration is only running
|
||||||
|
|||||||
@@ -127,6 +127,32 @@ func TestMigrateInvoices(t *testing.T) {
|
|||||||
false)
|
false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TestMigrateInvoicesHodl checks that a hodl invoice in the accepted state
|
||||||
|
// fails the migration.
|
||||||
|
func TestMigrateInvoicesHodl(t *testing.T) {
|
||||||
|
t.Parallel()
|
||||||
|
|
||||||
|
payReqBtc, err := getPayReq(&bitcoinCfg.MainNetParams)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
invoices := []Invoice{
|
||||||
|
{
|
||||||
|
PaymentRequest: []byte(payReqBtc),
|
||||||
|
Terms: ContractTerm{
|
||||||
|
State: ContractAccepted,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
applyMigration(t,
|
||||||
|
func(d *DB) { beforeMigrationFuncV11(t, d, invoices) },
|
||||||
|
func(d *DB) {},
|
||||||
|
migrateInvoices,
|
||||||
|
true)
|
||||||
|
}
|
||||||
|
|
||||||
// signDigestCompact generates a test signature to be used in the generation of
|
// signDigestCompact generates a test signature to be used in the generation of
|
||||||
// test payment requests.
|
// test payment requests.
|
||||||
func signDigestCompact(hash []byte) ([]byte, error) {
|
func signDigestCompact(hash []byte) ([]byte, error) {
|
||||||
|
|||||||
Reference in new issue
Block a user