Skip to content

Commit 3e71ff0

Browse files
committed
loopdb: strongly typed constants
1 parent fc8f3c9 commit 3e71ff0

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

loopdb/swapstate.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,44 +19,44 @@ const (
1919
// confirmed. This state will mostly coalesce with StateHtlcConfirmed,
2020
// except in the case where we wait for fees to come down before we
2121
// sweep.
22-
StatePreimageRevealed = 1
22+
StatePreimageRevealed SwapState = 1
2323

2424
// StateSuccess is the final swap state that is reached when the sweep
2525
// tx has the required confirmation depth (SweepConfDepth) and the
2626
// server pulled the off-chain htlc.
27-
StateSuccess = 2
27+
StateSuccess SwapState = 2
2828

2929
// StateFailOffchainPayments indicates that it wasn't possible to find
3030
// routes for one or both of the off-chain payments to the server that
3131
// satisfied the payment restrictions (fee and timelock limits).
32-
StateFailOffchainPayments = 3
32+
StateFailOffchainPayments SwapState = 3
3333

3434
// StateFailTimeout indicates that the on-chain htlc wasn't confirmed
3535
// before its expiry or confirmed too late (MinPreimageRevealDelta
3636
// violated).
37-
StateFailTimeout = 4
37+
StateFailTimeout SwapState = 4
3838

3939
// StateFailSweepTimeout indicates that the on-chain htlc wasn't swept
4040
// before the server revoked the htlc. The server didn't pull the
4141
// off-chain htlc (even though it could have) and we timed out the
4242
// off-chain htlc ourselves. No funds lost.
43-
StateFailSweepTimeout = 5
43+
StateFailSweepTimeout SwapState = 5
4444

4545
// StateFailInsufficientValue indicates that the published on-chain htlc
4646
// had a value lower than the requested amount.
47-
StateFailInsufficientValue = 6
47+
StateFailInsufficientValue SwapState = 6
4848

4949
// StateFailTemporary indicates that the swap cannot progress because
5050
// of an internal error. This is not a final state. Manual intervention
5151
// (like a restart) is required to solve this problem.
52-
StateFailTemporary = 7
52+
StateFailTemporary SwapState = 7
5353

5454
// StateHtlcPublished means that the client published the on-chain htlc.
55-
StateHtlcPublished = 8
55+
StateHtlcPublished SwapState = 8
5656

5757
// StateInvoiceSettled means that the swap invoice has been paid by the
5858
// server.
59-
StateInvoiceSettled = 9
59+
StateInvoiceSettled SwapState = 9
6060
)
6161

6262
// SwapStateType defines the types of swap states that exist. Every swap state

loopout_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ func TestPreimagePush(t *testing.T) {
529529
cfg.store.(*storeMock).assertLoopOutState(loopdb.StatePreimageRevealed)
530530
status := <-statusChan
531531
require.Equal(
532-
t, status.State, loopdb.SwapState(loopdb.StatePreimageRevealed),
532+
t, status.State, loopdb.StatePreimageRevealed,
533533
)
534534

535535
// We expect the sweep tx to have been published.
@@ -578,7 +578,7 @@ func TestPreimagePush(t *testing.T) {
578578
cfg.store.(*storeMock).assertLoopOutState(loopdb.StateSuccess)
579579
status = <-statusChan
580580
require.Equal(
581-
t, status.State, loopdb.SwapState(loopdb.StateSuccess),
581+
t, status.State, loopdb.StateSuccess,
582582
)
583583

584584
require.NoError(t, <-errChan)

0 commit comments

Comments
 (0)