channeldb: fail migration for accepted hodl invoices
This commit is contained in:
parent
31f72f6c7d
commit
ac7c93f544
@ -69,6 +69,11 @@ func migrateInvoices(tx *bbolt.Tx) error {
|
||||
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
|
||||
// avoid passing a the active network to channeldb. This would
|
||||
// be a layering violation, while this migration is only running
|
||||
|
@ -127,6 +127,32 @@ func TestMigrateInvoices(t *testing.T) {
|
||||
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
|
||||
// test payment requests.
|
||||
func signDigestCompact(hash []byte) ([]byte, error) {
|
||||
|
Loading…
Reference in New Issue
Block a user