From 3e71ff0c814aff81a71292766262e6dc5797fd01 Mon Sep 17 00:00:00 2001 From: Joost Jager Date: Tue, 23 Jun 2020 12:35:22 +0200 Subject: [PATCH] loopdb: strongly typed constants --- loopdb/swapstate.go | 18 +++++++++--------- loopout_test.go | 4 ++-- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/loopdb/swapstate.go b/loopdb/swapstate.go index eb10f3f7..c463966b 100644 --- a/loopdb/swapstate.go +++ b/loopdb/swapstate.go @@ -19,44 +19,44 @@ const ( // confirmed. This state will mostly coalesce with StateHtlcConfirmed, // except in the case where we wait for fees to come down before we // sweep. - StatePreimageRevealed = 1 + StatePreimageRevealed SwapState = 1 // StateSuccess is the final swap state that is reached when the sweep // tx has the required confirmation depth (SweepConfDepth) and the // server pulled the off-chain htlc. - StateSuccess = 2 + StateSuccess SwapState = 2 // StateFailOffchainPayments indicates that it wasn't possible to find // routes for one or both of the off-chain payments to the server that // satisfied the payment restrictions (fee and timelock limits). - StateFailOffchainPayments = 3 + StateFailOffchainPayments SwapState = 3 // StateFailTimeout indicates that the on-chain htlc wasn't confirmed // before its expiry or confirmed too late (MinPreimageRevealDelta // violated). - StateFailTimeout = 4 + StateFailTimeout SwapState = 4 // StateFailSweepTimeout indicates that the on-chain htlc wasn't swept // before the server revoked the htlc. The server didn't pull the // off-chain htlc (even though it could have) and we timed out the // off-chain htlc ourselves. No funds lost. - StateFailSweepTimeout = 5 + StateFailSweepTimeout SwapState = 5 // StateFailInsufficientValue indicates that the published on-chain htlc // had a value lower than the requested amount. - StateFailInsufficientValue = 6 + StateFailInsufficientValue SwapState = 6 // StateFailTemporary indicates that the swap cannot progress because // of an internal error. This is not a final state. Manual intervention // (like a restart) is required to solve this problem. - StateFailTemporary = 7 + StateFailTemporary SwapState = 7 // StateHtlcPublished means that the client published the on-chain htlc. - StateHtlcPublished = 8 + StateHtlcPublished SwapState = 8 // StateInvoiceSettled means that the swap invoice has been paid by the // server. - StateInvoiceSettled = 9 + StateInvoiceSettled SwapState = 9 ) // SwapStateType defines the types of swap states that exist. Every swap state diff --git a/loopout_test.go b/loopout_test.go index fbbddfe9..956b95d3 100644 --- a/loopout_test.go +++ b/loopout_test.go @@ -529,7 +529,7 @@ func TestPreimagePush(t *testing.T) { cfg.store.(*storeMock).assertLoopOutState(loopdb.StatePreimageRevealed) status := <-statusChan require.Equal( - t, status.State, loopdb.SwapState(loopdb.StatePreimageRevealed), + t, status.State, loopdb.StatePreimageRevealed, ) // We expect the sweep tx to have been published. @@ -578,7 +578,7 @@ func TestPreimagePush(t *testing.T) { cfg.store.(*storeMock).assertLoopOutState(loopdb.StateSuccess) status = <-statusChan require.Equal( - t, status.State, loopdb.SwapState(loopdb.StateSuccess), + t, status.State, loopdb.StateSuccess, ) require.NoError(t, <-errChan)