Skip to content

Commit 5c47042

Browse files
authored
Fix dummy funding tx generation (joemphilips#73)
The test suite's ProvideFundingTx function would randomly (50% of the time) return an incorrect funding output index. This is because NBitcoin was shuffling the funding tx's txouts, but the function would always return an output index of 0. This fixes the problem by making ProvideFundingTx disable txout shuffling on the transaction builder and always return an output index of 1.
1 parent b24b237 commit 5c47042

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

tests/DotNetLightning.Infrastructure.Tests/Constants.fs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ type DummyFundingTxProvider(n: Network) =
4141
interface IFundingTxProvider with
4242
member this.ProvideFundingTx(dest: IDestination, amount: Money, feerate: FeeRatePerKw) =
4343
let txb = n.CreateTransactionBuilder()
44+
txb.ShuffleRandom <- null
4445
let dummyKey =
4546
"5555555555555555555555555555555555555555555555555555555555555555"
4647
|> hex.DecodeData |> Key
@@ -59,7 +60,7 @@ type DummyFundingTxProvider(n: Network) =
5960
let fees = txb.EstimateFees(feerate.AsNBitcoinFeeRate())
6061
txb.SendFees(fees) |> ignore
6162
this.DummyTx <- txb.BuildTransaction(true)
62-
(this.DummyTx |> FinalizedTx, 0us |> TxOutIndex) |> Ok
63+
(this.DummyTx |> FinalizedTx, 1us |> TxOutIndex) |> Ok
6364

6465
type DummyBroadCaster() =
6566
interface IBroadCaster with

0 commit comments

Comments
 (0)