lnd+test: update unit tests to account for recent API changes
This commit is contained in:
parent
5758a4e1af
commit
b391049e49
6
lnd.go
6
lnd.go
@ -281,10 +281,11 @@ func lndMain() error {
|
||||
|
||||
for _, channel := range dbChannels {
|
||||
if chanID.IsChanPoint(&channel.FundingOutpoint) {
|
||||
// TODO(rosbeef): populate baecon
|
||||
return lnwallet.NewLightningChannel(
|
||||
activeChainControl.signer,
|
||||
activeChainControl.chainNotifier,
|
||||
activeChainControl.feeEstimator,
|
||||
server.witnessBeacon,
|
||||
channel)
|
||||
}
|
||||
}
|
||||
@ -358,6 +359,9 @@ func lndMain() error {
|
||||
}
|
||||
return delay
|
||||
},
|
||||
ArbitrateNewChan: func(c *channeldb.OpenChannel) error {
|
||||
return server.chainArb.RequestChannelArbitration(c)
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
|
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
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ import (
|
||||
|
||||
"github.com/lightningnetwork/lnd/chainntnfs"
|
||||
"github.com/lightningnetwork/lnd/channeldb"
|
||||
"github.com/lightningnetwork/lnd/contractcourt"
|
||||
"github.com/lightningnetwork/lnd/htlcswitch"
|
||||
"github.com/lightningnetwork/lnd/lnwallet"
|
||||
"github.com/lightningnetwork/lnd/lnwire"
|
||||
@ -220,13 +221,15 @@ func createTestPeer(notifier chainntnfs.ChainNotifier,
|
||||
aliceSigner := &mockSigner{aliceKeyPriv}
|
||||
bobSigner := &mockSigner{bobKeyPriv}
|
||||
|
||||
channelAlice, err := lnwallet.NewLightningChannel(aliceSigner, notifier,
|
||||
estimator, aliceChannelState)
|
||||
channelAlice, err := lnwallet.NewLightningChannel(
|
||||
aliceSigner, notifier, nil, aliceChannelState,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, nil, nil, nil, err
|
||||
}
|
||||
channelBob, err := lnwallet.NewLightningChannel(bobSigner, notifier,
|
||||
estimator, bobChannelState)
|
||||
channelBob, err := lnwallet.NewLightningChannel(
|
||||
bobSigner, notifier, nil, bobChannelState,
|
||||
)
|
||||
if err != nil {
|
||||
return nil, nil, nil, nil, err
|
||||
}
|
||||
@ -249,10 +252,15 @@ func createTestPeer(notifier chainntnfs.ChainNotifier,
|
||||
settledContracts: make(chan *wire.OutPoint, 10),
|
||||
}
|
||||
|
||||
chainArb := contractcourt.NewChainArbitrator(
|
||||
contractcourt.ChainArbitratorConfig{}, nil,
|
||||
)
|
||||
|
||||
s := &server{
|
||||
chanDB: dbAlice,
|
||||
cc: cc,
|
||||
breachArbiter: breachArbiter,
|
||||
chainArb: chainArb,
|
||||
}
|
||||
s.htlcSwitch = htlcswitch.New(htlcswitch.Config{})
|
||||
s.htlcSwitch.Start()
|
||||
|
Loading…
Reference in New Issue
Block a user