mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-09-28 04:26:26 +02:00
htlcswitch/test: move preimage cache to server level
In this commit the preimage cache is instantiated on the mock server level where it belongs. Previously it was a cache shared across all mock servers.
This commit is contained in:
@@ -131,6 +131,7 @@ type mockServer struct {
|
||||
htlcSwitch *Switch
|
||||
|
||||
registry *mockInvoiceRegistry
|
||||
pCache *mockPreimageCache
|
||||
interceptorFuncs []messageInterceptor
|
||||
}
|
||||
|
||||
@@ -186,19 +187,24 @@ func newMockServer(t testing.TB, name string, startingHeight uint32,
|
||||
h := sha256.Sum256([]byte(name))
|
||||
copy(id[:], h[:])
|
||||
|
||||
pCache := newMockPreimageCache()
|
||||
|
||||
htlcSwitch, err := initSwitchWithDB(startingHeight, db)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
registry := newMockRegistry(defaultDelta)
|
||||
|
||||
return &mockServer{
|
||||
t: t,
|
||||
id: id,
|
||||
name: name,
|
||||
messages: make(chan lnwire.Message, 3000),
|
||||
quit: make(chan struct{}),
|
||||
registry: newMockRegistry(defaultDelta),
|
||||
registry: registry,
|
||||
htlcSwitch: htlcSwitch,
|
||||
pCache: pCache,
|
||||
interceptorFuncs: make([]messageInterceptor, 0),
|
||||
}, nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user