test.py: begin implementing TEST_SUITE_DETERMINISTIC
This commit is contained in:
parent
565dd6da62
commit
e91b139c99
4 changed files with 18 additions and 6 deletions
|
|
@ -127,6 +127,7 @@ class GlobalContext(Lockable):
|
|||
debug_utf8 = False
|
||||
traceback = False
|
||||
test_suite = False
|
||||
test_suite_deterministic = False
|
||||
test_suite_regtest = False
|
||||
test_suite_popen_spawn = False
|
||||
terminal_width = 0
|
||||
|
|
@ -204,6 +205,7 @@ class GlobalContext(Lockable):
|
|||
'MMGEN_DEBUG_ALL', # special: there is no g.debug_all var
|
||||
|
||||
'MMGEN_TEST_SUITE',
|
||||
'MMGEN_TEST_SUITE_DETERMINISTIC',
|
||||
'MMGEN_TEST_SUITE_REGTEST',
|
||||
'MMGEN_TEST_SUITE_POPEN_SPAWN',
|
||||
'MMGEN_TERMINAL_WIDTH',
|
||||
|
|
|
|||
|
|
@ -66,12 +66,21 @@ sample_mn = {
|
|||
ref_kafile_pass = 'kafile password'
|
||||
ref_kafile_hash_preset = '1'
|
||||
|
||||
def getrandnum(n): return int(os.urandom(n).hex(),16)
|
||||
def getrandhex(n): return os.urandom(n).hex()
|
||||
def ts_urandom(n):
|
||||
assert n < 70, f'{n} > len(sample_text) (69 bytes)'
|
||||
return sample_text.encode()[:n] if g.test_suite_deterministic else os.urandom(n)
|
||||
|
||||
def getrandnum(n):
|
||||
return int(ts_urandom(n).hex(),16)
|
||||
|
||||
def getrandhex(n):
|
||||
return ts_urandom(n).hex()
|
||||
|
||||
def getrandnum_range(nbytes,rn_max):
|
||||
while True:
|
||||
rn = int(os.urandom(nbytes).hex(),16)
|
||||
if rn < rn_max: return rn
|
||||
rn = int(ts_urandom(nbytes).hex(),16)
|
||||
if rn < rn_max:
|
||||
return rn
|
||||
|
||||
def getrandstr(num_chars,no_space=False):
|
||||
n,m = 95,32
|
||||
|
|
|
|||
|
|
@ -145,6 +145,7 @@ def get_label(do_shuffle=False):
|
|||
try:
|
||||
return next(label_iter)
|
||||
except:
|
||||
if do_shuffle: shuffle(labels)
|
||||
if do_shuffle:
|
||||
shuffle(labels)
|
||||
label_iter = iter(labels)
|
||||
return next(label_iter)
|
||||
|
|
|
|||
|
|
@ -327,7 +327,7 @@ class TestSuiteMain(TestSuiteBase,TestSuiteShared):
|
|||
for d in tx_data.values():
|
||||
al = adata.addrlist(al_id=d['al_id'])
|
||||
for n,(idx,coinaddr) in enumerate(al.addrpairs()):
|
||||
lbl = get_label(do_shuffle=True)
|
||||
lbl = get_label(do_shuffle=not g.test_suite_deterministic)
|
||||
out.append(self._create_fake_unspent_entry(coinaddr,d['al_id'],idx,lbl,segwit=d['segwit']))
|
||||
if n == 0: # create a duplicate address. This means addrs_per_wallet += 1
|
||||
out.append(self._create_fake_unspent_entry(coinaddr,d['al_id'],idx,lbl,segwit=d['segwit']))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue