Fix randrange bug
Also make seed change daily only
This commit is contained in:
parent
acb9784ccc
commit
ba5d18d9d5
@ -1,8 +1,9 @@
|
|||||||
|
import datetime
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
from functools import partial
|
from functools import partial
|
||||||
from random import randrange, choice
|
from random import randrange, choice, seed
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from aiorpcx import Event, TaskGroup, sleep, spawn, ignore_after
|
from aiorpcx import Event, TaskGroup, sleep, spawn, ignore_after
|
||||||
@ -16,6 +17,8 @@ from electrumx.lib.util import make_logger
|
|||||||
|
|
||||||
coin = BitcoinCash
|
coin = BitcoinCash
|
||||||
tx_hash_fn = coin.DESERIALIZER.TX_HASH_FN
|
tx_hash_fn = coin.DESERIALIZER.TX_HASH_FN
|
||||||
|
# Change seed daily
|
||||||
|
seed(datetime.date.today().toordinal)
|
||||||
|
|
||||||
|
|
||||||
def random_tx(hash160s, utxos):
|
def random_tx(hash160s, utxos):
|
||||||
@ -40,7 +43,7 @@ def random_tx(hash160s, utxos):
|
|||||||
outputs = []
|
outputs = []
|
||||||
n_outputs = randrange(1, 4)
|
n_outputs = randrange(1, 4)
|
||||||
for n in range(n_outputs):
|
for n in range(n_outputs):
|
||||||
value = randrange(input_value)
|
value = randrange(input_value + 1)
|
||||||
input_value -= value
|
input_value -= value
|
||||||
pk_script = coin.hash160_to_P2PKH_script(choice(hash160s))
|
pk_script = coin.hash160_to_P2PKH_script(choice(hash160s))
|
||||||
outputs.append(TxOutput(value, pk_script))
|
outputs.append(TxOutput(value, pk_script))
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user