From 19961605765995682496d4d860a2aa1325cc044d Mon Sep 17 00:00:00 2001 From: George Tsagkarelis Date: Thu, 2 Feb 2023 13:59:22 +0200 Subject: [PATCH] loop: extend store mock to implement new methods --- store_mock_test.go | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/store_mock_test.go b/store_mock_test.go index 4e8a0ad..ccf6305 100644 --- a/store_mock_test.go +++ b/store_mock_test.go @@ -70,6 +70,36 @@ func (s *storeMock) FetchLoopOutSwaps() ([]*loopdb.LoopOut, error) { return result, nil } +// FetchLoopOutSwaps returns all swaps currently in the store. +// +// NOTE: Part of the loopdb.SwapStore interface. +func (s *storeMock) FetchLoopOutSwap( + hash lntypes.Hash) (*loopdb.LoopOut, error) { + + contract, ok := s.loopOutSwaps[hash] + if !ok { + return nil, errors.New("swap not found") + } + + updates := s.loopOutUpdates[hash] + events := make([]*loopdb.LoopEvent, len(updates)) + for i, u := range updates { + events[i] = &loopdb.LoopEvent{ + SwapStateData: u, + } + } + + swap := &loopdb.LoopOut{ + Loop: loopdb.Loop{ + Hash: hash, + Events: events, + }, + Contract: contract, + } + + return swap, nil +} + // CreateLoopOut adds an initiated swap to the store. // // NOTE: Part of the loopdb.SwapStore interface.