Merge pull request #1689 from cfromknecht/hashcache-flake
txscript/hashcache_test: fix flake due to resetting RNG
This commit is contained in:
commit
fa683a69dc
1 changed files with 6 additions and 8 deletions
|
@ -13,12 +13,16 @@ import (
|
||||||
"github.com/davecgh/go-spew/spew"
|
"github.com/davecgh/go-spew/spew"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
rand.Seed(time.Now().Unix())
|
||||||
|
}
|
||||||
|
|
||||||
// genTestTx creates a random transaction for uses within test cases.
|
// genTestTx creates a random transaction for uses within test cases.
|
||||||
func genTestTx() (*wire.MsgTx, error) {
|
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 +38,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(),
|
||||||
|
@ -56,8 +60,6 @@ func genTestTx() (*wire.MsgTx, error) {
|
||||||
func TestHashCacheAddContainsHashes(t *testing.T) {
|
func TestHashCacheAddContainsHashes(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
rand.Seed(time.Now().Unix())
|
|
||||||
|
|
||||||
cache := NewHashCache(10)
|
cache := NewHashCache(10)
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
|
@ -109,8 +111,6 @@ func TestHashCacheAddContainsHashes(t *testing.T) {
|
||||||
func TestHashCacheAddGet(t *testing.T) {
|
func TestHashCacheAddGet(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
rand.Seed(time.Now().Unix())
|
|
||||||
|
|
||||||
cache := NewHashCache(10)
|
cache := NewHashCache(10)
|
||||||
|
|
||||||
// To start, we'll generate a random transaction and compute the set of
|
// To start, we'll generate a random transaction and compute the set of
|
||||||
|
@ -144,8 +144,6 @@ func TestHashCacheAddGet(t *testing.T) {
|
||||||
func TestHashCachePurge(t *testing.T) {
|
func TestHashCachePurge(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
rand.Seed(time.Now().Unix())
|
|
||||||
|
|
||||||
cache := NewHashCache(10)
|
cache := NewHashCache(10)
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
|
|
Loading…
Reference in a new issue