lnd+test: update unit tests to account for recent API changes

This commit is contained in:
Olaoluwa Osuntokun
2018-01-16 20:56:51 -08:00
parent 5758a4e1af
commit b391049e49
3 changed files with 44 additions and 5 deletions

27
mock.go
View File

@ -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
}