txscript/hashcache_test: always add inputs during getTxn

TestHashCacheAddContainsHashes flakes fairly regularly when rebasing
PR #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.
This commit is contained in:
Conner Fromknecht 2021-02-02 12:42:28 -08:00
parent 77fd96753c
commit 1dd693480c
No known key found for this signature in database
GPG key ID: E7D737B67FA592C7

View file

@ -18,7 +18,7 @@ func genTestTx() (*wire.MsgTx, error) {
tx := wire.NewMsgTx(2) tx := wire.NewMsgTx(2)
tx.Version = rand.Int31() tx.Version = rand.Int31()
numTxins := rand.Intn(11) numTxins := 1 + rand.Intn(11)
for i := 0; i < numTxins; i++ { for i := 0; i < numTxins; i++ {
randTxIn := wire.TxIn{ randTxIn := wire.TxIn{
PreviousOutPoint: wire.OutPoint{ PreviousOutPoint: wire.OutPoint{
@ -34,7 +34,7 @@ func genTestTx() (*wire.MsgTx, error) {
tx.TxIn = append(tx.TxIn, &randTxIn) tx.TxIn = append(tx.TxIn, &randTxIn)
} }
numTxouts := rand.Intn(11) numTxouts := 1 + rand.Intn(11)
for i := 0; i < numTxouts; i++ { for i := 0; i < numTxouts; i++ {
randTxOut := wire.TxOut{ randTxOut := wire.TxOut{
Value: rand.Int63(), Value: rand.Int63(),