Skip to content

Commit

Permalink
txscript/hashcache_test: always add inputs during getTxn
Browse files Browse the repository at this point in the history
TestHashCacheAddContainsHashes flakes fairly regularly when rebasing
PR btcsuite#1684 with:
    txid <txid> wasn't inserted into cache but was found.

With probabilty 1/10^2 there will be no inputs on the transaction. This
reduces the entropy in the txid, and I belive is the primary cause of
the flake.
  • Loading branch information
cfromknecht committed Feb 2, 2021
1 parent 77fd967 commit 1dd6934
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions txscript/hashcache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func genTestTx() (*wire.MsgTx, error) {
tx := wire.NewMsgTx(2)
tx.Version = rand.Int31()

numTxins := rand.Intn(11)
numTxins := 1 + rand.Intn(11)
for i := 0; i < numTxins; i++ {
randTxIn := wire.TxIn{
PreviousOutPoint: wire.OutPoint{
Expand All @@ -34,7 +34,7 @@ func genTestTx() (*wire.MsgTx, error) {
tx.TxIn = append(tx.TxIn, &randTxIn)
}

numTxouts := rand.Intn(11)
numTxouts := 1 + rand.Intn(11)
for i := 0; i < numTxouts; i++ {
randTxOut := wire.TxOut{
Value: rand.Int63(),
Expand Down

0 comments on commit 1dd6934

Please sign in to comment.