mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-07-17 00:22:33 +02:00
lnd+test: update unit tests to account for recent API changes
This commit is contained in:
27
mock.go
27
mock.go
@ -1,7 +1,9 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"crypto/sha256"
|
||||
"fmt"
|
||||
"sync"
|
||||
|
||||
"github.com/lightningnetwork/lnd/chainntnfs"
|
||||
"github.com/lightningnetwork/lnd/lnwallet"
|
||||
@ -267,3 +269,28 @@ func (*mockWalletController) Start() error {
|
||||
func (*mockWalletController) Stop() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
type mockPreimageCache struct {
|
||||
sync.Mutex
|
||||
preimageMap map[[32]byte][]byte
|
||||
}
|
||||
|
||||
func (m *mockPreimageCache) LookupPreimage(hash []byte) ([]byte, bool) {
|
||||
m.Lock()
|
||||
defer m.Unlock()
|
||||
|
||||
var h [32]byte
|
||||
copy(h[:], hash)
|
||||
|
||||
p, ok := m.preimageMap[h]
|
||||
return p, ok
|
||||
}
|
||||
|
||||
func (m *mockPreimageCache) AddPreimage(preimage []byte) error {
|
||||
m.Lock()
|
||||
defer m.Unlock()
|
||||
|
||||
m.preimageMap[sha256.Sum256(preimage[:])] = preimage
|
||||
|
||||
return nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user