Skip to content

Commit 1996160

Browse files
committed
loop: extend store mock to implement new methods
1 parent 7c6abc0 commit 1996160

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

store_mock_test.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,36 @@ func (s *storeMock) FetchLoopOutSwaps() ([]*loopdb.LoopOut, error) {
7070
return result, nil
7171
}
7272

73+
// FetchLoopOutSwaps returns all swaps currently in the store.
74+
//
75+
// NOTE: Part of the loopdb.SwapStore interface.
76+
func (s *storeMock) FetchLoopOutSwap(
77+
hash lntypes.Hash) (*loopdb.LoopOut, error) {
78+
79+
contract, ok := s.loopOutSwaps[hash]
80+
if !ok {
81+
return nil, errors.New("swap not found")
82+
}
83+
84+
updates := s.loopOutUpdates[hash]
85+
events := make([]*loopdb.LoopEvent, len(updates))
86+
for i, u := range updates {
87+
events[i] = &loopdb.LoopEvent{
88+
SwapStateData: u,
89+
}
90+
}
91+
92+
swap := &loopdb.LoopOut{
93+
Loop: loopdb.Loop{
94+
Hash: hash,
95+
Events: events,
96+
},
97+
Contract: contract,
98+
}
99+
100+
return swap, nil
101+
}
102+
73103
// CreateLoopOut adds an initiated swap to the store.
74104
//
75105
// NOTE: Part of the loopdb.SwapStore interface.

0 commit comments

Comments
 (0)