sweep: create wallet interface

We need access to additional wallet functionality. This commit creates
an interface to prevent passing in multiple function pointers.
This commit is contained in:
Joost Jager committed 2019-12-17 22:00:35 +01:00
1 parent b325aae4f2
commit 34c9193bfc
5 files changed
+43 -23

No files matched your search

+3 -13
View File
@@ -98,14 +98,13 @@ func createSweeperTestContext(t *testing.T) *sweeperTestContext {
store := NewMockSweeperStore()
backend := newMockBackend(notifier)
backend := newMockBackend(t, notifier)
estimator := newMockFeeEstimator(10000, chainfee.FeePerKwFloor)
publishChan := make(chan wire.MsgTx, 2)
ctx := &sweeperTestContext{
notifier: notifier,
publishChan: publishChan,
publishChan: backend.publishChan,
t: t,
estimator: estimator,
backend: backend,
@@ -116,16 +115,7 @@ func createSweeperTestContext(t *testing.T) *sweeperTestContext {
var outputScriptCount byte
ctx.sweeper = New(&UtxoSweeperConfig{
Notifier: notifier,
PublishTransaction: func(tx *wire.MsgTx) error {
log.Tracef("Publishing tx %v", tx.TxHash())
err := backend.publishTransaction(tx)
select {
case publishChan <- *tx:
case <-time.After(defaultTestTimeout):
t.Fatalf("unexpected tx published")
}
return err
},
Wallet: backend,
NewBatchTimer: func() <-chan time.Time {
c := make(chan time.Time, 1)
ctx.timeoutChan <- c