multi: move StoreMock to loopdb

This commit is contained in:
George Tsagkarelis 2024-01-18 12:26:07 +01:00
parent 99608ad515
commit e0d85958f7
No known key found for this signature in database
GPG key ID: E08DEA9B12B66AF6
8 changed files with 402 additions and 375 deletions

View file

@ -36,7 +36,7 @@ type testContext struct {
serverMock *serverMock
swapClient *Client
statusChan chan SwapInfo
store *storeMock
store *loopdb.StoreMock
expiryChan chan time.Time
runErr chan error
stop func()
@ -83,15 +83,15 @@ func createClientTestContext(t *testing.T,
clientLnd := test.NewMockLnd()
serverMock := newServerMock(clientLnd)
store := newStoreMock(t)
store := loopdb.NewStoreMock(t)
for _, s := range pendingSwaps {
store.loopOutSwaps[s.Hash] = s.Contract
store.LoopOutSwaps[s.Hash] = s.Contract
updates := []loopdb.SwapStateData{}
for _, e := range s.Events {
updates = append(updates, e.SwapStateData)
}
store.loopOutUpdates[s.Hash] = updates
store.LoopOutUpdates[s.Hash] = updates
}
expiryChan := make(chan time.Time)
@ -147,7 +147,7 @@ func (ctx *testContext) finish() {
}
func (ctx *testContext) assertIsDone() {
require.NoError(ctx.Context.T, ctx.Context.Lnd.IsDone())
require.NoError(ctx.Context.T, ctx.store.isDone())
require.NoError(ctx.Context.T, ctx.store.IsDone())
select {
case <-ctx.statusChan:
@ -159,19 +159,19 @@ func (ctx *testContext) assertIsDone() {
func (ctx *testContext) assertStored() {
ctx.Context.T.Helper()
ctx.store.assertLoopOutStored()
ctx.store.AssertLoopOutStored()
}
func (ctx *testContext) assertStorePreimageReveal() {
ctx.Context.T.Helper()
ctx.store.assertStorePreimageReveal()
ctx.store.AssertStorePreimageReveal()
}
func (ctx *testContext) assertStoreFinished(expectedResult loopdb.SwapState) {
ctx.Context.T.Helper()
ctx.store.assertStoreFinished(expectedResult)
ctx.store.AssertStoreFinished(expectedResult)
}
func (ctx *testContext) assertStatus(expectedState loopdb.SwapState) {