test.py: bogus tracking wallet data fixes

This commit is contained in:
The MMGen Project 2020-06-04 11:45:22 +00:00
commit 29f553e5f9
Signed by: mmgen
GPG key ID: 3F8B1861E32B7DA2
7 changed files with 9 additions and 8 deletions

View file

@ -604,4 +604,7 @@ async def rpc_init(proto,backend=None):
proto.chain_name.upper(),
rpc.chain.upper() ))
if g.bogus_wallet_data:
rpc.blockcount = 1000000
return rpc

View file

@ -169,8 +169,8 @@ Actions: [q]uit view, [p]rint to file, pager [v]iew, [w]ide view, add [l]abel:
return await self.rpc.call('listunspent',self.minconf,*add_args)
async def get_unspent_data(self,sort_key=None,reverse_sort=False):
if g.bogus_wallet_data: # for debugging purposes only
us_raw = eval(get_data_from_file(g.bogus_wallet_data)) # testing, so ok
if g.bogus_wallet_data: # for debugging and test suite
us_raw = json.loads(get_data_from_file(g.bogus_wallet_data),parse_float=Decimal)
else:
us_raw = await self.get_unspent_rpc()

View file

@ -746,6 +746,7 @@ class TestSuiteRunner(object):
if not quiet:
bmsg('Executing ' + m)
os.environ['MMGEN_BOGUS_WALLET_DATA'] = '' # zero this here, so test group doesn't have to
self.ts = self.gm.gm_init_group(self,gname,self.spawn_wrapper)
if opt.resume_after:

View file

@ -311,7 +311,6 @@ class TestSuiteEthdev(TestSuiteBase,TestSuiteShared):
self.proto = init_proto(g.coin,network='regtest')
from mmgen.daemon import CoinDaemon
self.rpc_port = CoinDaemon(proto=self.proto,test_suite=True).rpc_port
os.environ['MMGEN_BOGUS_WALLET_DATA'] = ''
@property
def eth_args(self):

View file

@ -418,7 +418,9 @@ class TestSuiteMain(TestSuiteBase,TestSuiteShared):
silence()
ad,tx_data = self._create_tx_data(sources,addrs_per_wallet)
dfake = self._create_fake_unspent_data(ad,tx_data,non_mmgen_input,non_mmgen_input_compressed)
self._write_fake_data_to_file(repr(dfake))
import json
from mmgen.rpc import json_encoder
self._write_fake_data_to_file(json.dumps(dfake,cls=json_encoder))
cmd_args = self._make_txcreate_cmdline(tx_data)
if cmdline_inputs:

View file

@ -269,7 +269,6 @@ class TestSuiteRegtest(TestSuiteBase,TestSuiteShared):
end_silence()
def setup(self):
os.environ['MMGEN_BOGUS_WALLET_DATA'] = ''
try: shutil.rmtree(joinpath(self.tr.data_dir,'regtest'))
except: pass
os.environ['MMGEN_TEST_SUITE'] = '' # mnemonic is piped to stdin, so stop being a terminal

View file

@ -75,11 +75,8 @@ class TestSuiteTool(TestSuiteMain,TestSuiteBase):
return t
def tool_twview_bad_comment(self): # test correct operation of get_tw_label()
bw_save = os.getenv('MMGEN_BOGUS_WALLET_DATA')
os.environ['MMGEN_BOGUS_WALLET_DATA'] = joinpath(ref_dir,'bad-comment-unspent.json')
t = self.spawn('mmgen-tool',['twview'])
if bw_save:
os.environ['MMGEN_BOGUS_WALLET_DATA'] = bw_save
t.read()
t.req_exit_val = 2
return t