multi: migrate instances of mockSigner to the mock package
This commit moves all localized instances of mock implementations of the Signer interface to the lntest/mock package. This allows us to remove a lot of code and have it housed under a single interface in many cases.
This commit is contained in:
1 parent
e4764a67cc
commit
49d8f04197
12 files changed
+156
-287
No files matched your search
@@ -14,6 +14,7 @@ import (
|
||||
"github.com/lightningnetwork/lnd/build"
|
||||
"github.com/lightningnetwork/lnd/input"
|
||||
"github.com/lightningnetwork/lnd/keychain"
|
||||
"github.com/lightningnetwork/lnd/lntest/mock"
|
||||
"github.com/lightningnetwork/lnd/lnwallet"
|
||||
"github.com/lightningnetwork/lnd/lnwallet/chainfee"
|
||||
)
|
||||
@@ -128,7 +129,7 @@ func createSweeperTestContext(t *testing.T) *sweeperTestContext {
|
||||
return c
|
||||
},
|
||||
Store: store,
|
||||
Signer: &mockSigner{},
|
||||
Signer: &mock.DummySigner{},
|
||||
GenSweepScript: func() ([]byte, error) {
|
||||
script := []byte{outputScriptCount}
|
||||
outputScriptCount++
|
||||
|
||||
@@ -6,11 +6,9 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/btcsuite/btcd/btcec"
|
||||
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
"github.com/lightningnetwork/lnd/chainntnfs"
|
||||
"github.com/lightningnetwork/lnd/input"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -19,31 +17,6 @@ var (
|
||||
mockChainHeight = int32(100)
|
||||
)
|
||||
|
||||
type dummySignature struct{}
|
||||
|
||||
func (s *dummySignature) Serialize() []byte {
|
||||
return []byte{}
|
||||
}
|
||||
|
||||
func (s *dummySignature) Verify(_ []byte, _ *btcec.PublicKey) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
type mockSigner struct {
|
||||
}
|
||||
|
||||
func (m *mockSigner) SignOutputRaw(tx *wire.MsgTx,
|
||||
signDesc *input.SignDescriptor) (input.Signature, error) {
|
||||
|
||||
return &dummySignature{}, nil
|
||||
}
|
||||
|
||||
func (m *mockSigner) ComputeInputScript(tx *wire.MsgTx,
|
||||
signDesc *input.SignDescriptor) (*input.Script, error) {
|
||||
|
||||
return &input.Script{}, nil
|
||||
}
|
||||
|
||||
// MockNotifier simulates the chain notifier for test purposes. This type is
|
||||
// exported because it is used in nursery tests.
|
||||
type MockNotifier struct {
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
"github.com/btcsuite/btcd/txscript"
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
"github.com/btcsuite/btcutil"
|
||||
"github.com/lightningnetwork/lnd/lntest/mock"
|
||||
"github.com/lightningnetwork/lnd/lnwallet"
|
||||
"github.com/lightningnetwork/lnd/lnwallet/chainfee"
|
||||
)
|
||||
@@ -335,7 +336,7 @@ func TestCraftSweepAllTx(t *testing.T) {
|
||||
|
||||
// First, we'll make a mock signer along with a fee estimator, We'll
|
||||
// use zero fees to we can assert a precise output value.
|
||||
signer := &mockSigner{}
|
||||
signer := &mock.DummySigner{}
|
||||
feeEstimator := newMockFeeEstimator(0, 0)
|
||||
|
||||
// For our UTXO source, we'll pass in all the UTXOs that we know of,
|
||||
|
||||
Reference in new issue
Block a user