From 1dd693480cbfea6cffb1d1fa947fb1ccbb9d3acb Mon Sep 17 00:00:00 2001 From: Conner Fromknecht Date: Tue, 2 Feb 2021 12:42:28 -0800 Subject: [PATCH] txscript/hashcache_test: always add inputs during getTxn TestHashCacheAddContainsHashes flakes fairly regularly when rebasing PR #1684 with: 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. --- txscript/hashcache_test.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/txscript/hashcache_test.go b/txscript/hashcache_test.go index 389918e2..09b71faf 100644 --- a/txscript/hashcache_test.go +++ b/txscript/hashcache_test.go @@ -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{ @@ -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(),