@@ -25,6 +25,7 @@ import (
2525 "github.com/lightninglabs/taproot-assets/fn"
2626 "github.com/lightninglabs/taproot-assets/rfqmsg"
2727 "github.com/lightningnetwork/lnd/chainntnfs"
28+ "github.com/lightningnetwork/lnd/clock"
2829 "github.com/lightningnetwork/lnd/lnrpc"
2930 "github.com/lightningnetwork/lnd/lntypes"
3031 paymentsdb "github.com/lightningnetwork/lnd/payments/db"
@@ -192,7 +193,7 @@ func newLoopOutSwap(globalCtx context.Context, cfg *swapConfig,
192193
193194 // Instantiate a struct that contains all required data to start the
194195 // swap.
195- initiationTime := time .Now ()
196+ initiationTime := cfg . clock .Now ()
196197
197198 contract := loopdb.LoopOutContract {
198199 SwapInvoice : swapResp .swapInvoice ,
@@ -633,7 +634,7 @@ func (s *loopOutSwap) executeSwap(globalCtx context.Context) error {
633634
634635// persistState updates the swap state and sends out an update notification.
635636func (s * loopOutSwap ) persistState (ctx context.Context ) error {
636- updateTime := time .Now ()
637+ updateTime := s . clock .Now ()
637638
638639 s .lastUpdateTime = updateTime
639640
@@ -864,12 +865,12 @@ func (s *loopOutSwap) payInvoiceAsync(ctx context.Context,
864865 payCtx , cancel := context .WithCancel (ctx )
865866 defer cancel ()
866867
867- start := time .Now ()
868+ start := s . clock .Now ()
868869 paymentStatus , attempts , err := s .sendPaymentWithRetry (
869870 payCtx , hash , & req , maxRetries , routingPlugin , pluginType ,
870871 )
871872
872- dt := time . Since (start )
873+ dt := s . clock . Now (). Sub (start )
873874 paymentSuccess := err == nil &&
874875 paymentStatus .State == lnrpc .Payment_SUCCEEDED
875876
@@ -1543,6 +1544,7 @@ type resumeManager struct {
15431544 swapStore loopdb.SwapStore
15441545 swapClient swapserverrpc.SwapServerClient
15451546 lnd * lndclient.GrpcLndServices
1547+ clock clock.Clock
15461548
15471549 reqChan chan * swapserverrpc.ServerUnfinishedSwapNotification
15481550}
@@ -1552,13 +1554,14 @@ type resumeManager struct {
15521554func Resume (ctx context.Context , ntfnManager NotificationManager ,
15531555 swapStore loopdb.SwapStore ,
15541556 swapClientConn * grpc.ClientConn ,
1555- lnd * lndclient.GrpcLndServices ) {
1557+ lnd * lndclient.GrpcLndServices , clock clock. Clock ) {
15561558
15571559 resumeManager := & resumeManager {
15581560 ntfnManager : ntfnManager ,
15591561 swapStore : swapStore ,
15601562 swapClient : swapserverrpc .NewSwapServerClient (swapClientConn ),
15611563 lnd : lnd ,
1564+ clock : clock ,
15621565 reqChan : make (chan * swapserverrpc.ServerUnfinishedSwapNotification , 1 ),
15631566 }
15641567 go resumeManager .start (ctx )
@@ -1717,7 +1720,7 @@ func (m *resumeManager) resumeLoopOutPayment(ctx context.Context,
17171720 cost .Server = payResp .Value .ToSatoshis () - amtRequested
17181721 cost .Offchain = payResp .Fee .ToSatoshis ()
17191722 // Payment succeeded.
1720- updateTime := time .Now ()
1723+ updateTime := m . clock .Now ()
17211724
17221725 // Update state in store.
17231726 err = m .swapStore .UpdateLoopOut (
0 commit comments