sweeper_test: return unique wallet utxos

We also increase the value of the wallet UTXO, as it is needed when we
want to afford fees for larger transactions.
This commit is contained in:
Johan T. Halseth
2020-11-09 18:49:44 +01:00
parent 0cba47dac0
commit 7f9df26efd
2 changed files with 18 additions and 6 deletions

View File

@@ -27,6 +27,7 @@ type mockBackend struct {
publishChan chan wire.MsgTx
walletUtxos []*lnwallet.Utxo
utxoCnt int
}
func newMockBackend(t *testing.T, notifier *MockNotifier) *mockBackend {
@@ -88,6 +89,16 @@ func (b *mockBackend) PublishTransaction(tx *wire.MsgTx, _ string) error {
func (b *mockBackend) ListUnspentWitness(minconfirms, maxconfirms int32) (
[]*lnwallet.Utxo, error) {
b.lock.Lock()
defer b.lock.Unlock()
// Each time we list output, we increment the utxo counter, to
// ensure we don't return the same outpoint every time.
b.utxoCnt++
for i := range b.walletUtxos {
b.walletUtxos[i].OutPoint.Hash[0] = byte(b.utxoCnt)
}
return b.walletUtxos, nil
}