cmdtest eth*: method renames, MRO fixes, cleanups
This commit is contained in:
parent
21fb6a8195
commit
961eb0bd4f
6 changed files with 75 additions and 62 deletions
|
|
@ -20,13 +20,14 @@ from mmgen.util import ymsg, suf
|
|||
|
||||
from ..include.common import imsg, omsg_r
|
||||
|
||||
from .include.common import cleanup_env, dfl_words_file
|
||||
from .include.common import cleanup_env, dfl_words_file, dfl_sid
|
||||
from .include.runner import CmdTestRunner
|
||||
from .httpd.thornode import ThornodeServer
|
||||
|
||||
from .ethdev import CmdTestEthdev, CmdTestEthdevMethods, dfl_sid
|
||||
from .ethdev import CmdTestEthdev, CmdTestEthdevMethods
|
||||
from .regtest import CmdTestRegtest
|
||||
from .swap import CmdTestSwapMethods
|
||||
from .ethswap import CmdTestEthSwapMethods
|
||||
|
||||
thornode_server = ThornodeServer()
|
||||
burn_addr = 'beefcafe22' * 4
|
||||
|
|
@ -113,12 +114,14 @@ class CmdTestEthBumpMethods:
|
|||
|
||||
return 'ok'
|
||||
|
||||
class CmdTestEthBump(CmdTestEthBumpMethods, CmdTestEthdev, CmdTestSwapMethods):
|
||||
class CmdTestEthBump(CmdTestEthBumpMethods, CmdTestEthSwapMethods, CmdTestSwapMethods, CmdTestEthdev):
|
||||
'Ethereum transaction bumping operations'
|
||||
|
||||
networks = ('eth',)
|
||||
tmpdir_nums = [42]
|
||||
dfl_devnet_block_period = {'geth': 7, 'reth': 9}
|
||||
fund_amt = 100000
|
||||
token_fund_amt = 1000
|
||||
|
||||
cmd_group_in = (
|
||||
('subgroup.ltc_init', []),
|
||||
|
|
@ -140,9 +143,9 @@ class CmdTestEthBump(CmdTestEthBumpMethods, CmdTestEthdev, CmdTestSwapMethods):
|
|||
('addrimport', 'importing addresses'),
|
||||
('addrimport_devaddr', 'importing the dev address'),
|
||||
('fund_devaddr', 'funding the dev address'),
|
||||
('fund_mmgen_addr1', 'spend from dev address to address :1)'),
|
||||
('fund_mmgen_addr2', 'spend from dev address to address :11)'),
|
||||
('fund_mmgen_addr3', 'spend from dev address to address :21)'),
|
||||
('fund_mmgen_addr1', 'funding user address :1)'),
|
||||
('fund_mmgen_addr2', 'funding user address :11)'),
|
||||
('fund_mmgen_addr3', 'funding user address :21)'),
|
||||
('wait1', 'waiting for block'),
|
||||
),
|
||||
'ltc_init': (
|
||||
|
|
@ -253,15 +256,6 @@ class CmdTestEthBump(CmdTestEthBumpMethods, CmdTestEthdev, CmdTestSwapMethods):
|
|||
|
||||
thornode_server.start()
|
||||
|
||||
def fund_mmgen_addr1(self):
|
||||
return self._fund_mmgen_addr(arg=f'{dfl_sid}:E:1,100000')
|
||||
|
||||
def fund_mmgen_addr2(self):
|
||||
return self._fund_mmgen_addr(arg=f'{dfl_sid}:E:11,100000')
|
||||
|
||||
def fund_mmgen_addr3(self):
|
||||
return self._fund_mmgen_addr(arg=f'{dfl_sid}:E:21,100000')
|
||||
|
||||
def txcreate1(self):
|
||||
return self._txcreate(args=[f'{burn_addr},987'], acct='1')
|
||||
|
||||
|
|
@ -303,27 +297,6 @@ class CmdTestEthBump(CmdTestEthBumpMethods, CmdTestEthdev, CmdTestSwapMethods):
|
|||
def bal4(self):
|
||||
return self._bal_check(pat=rf'{dfl_sid}:E:12\s+4444\.3333\s')
|
||||
|
||||
async def token_deploy_a(self):
|
||||
return await self._token_deploy_math(num=1, get_receipt=False)
|
||||
|
||||
async def token_deploy_b(self):
|
||||
return await self._token_deploy_owned(num=1, get_receipt=False)
|
||||
|
||||
async def token_deploy_c(self):
|
||||
return await self._token_deploy_token(num=1, get_receipt=False)
|
||||
|
||||
def token_fund_user(self):
|
||||
return self._token_transfer_ops(op='fund_user', mm_idxs=[1], get_receipt=False)
|
||||
|
||||
def token_addrgen(self):
|
||||
return self._token_addrgen(mm_idxs=[1], naddrs=5)
|
||||
|
||||
def token_addrimport(self):
|
||||
return self._token_addrimport('token_addr1', '1-5', expect='5/5')
|
||||
|
||||
def token_bal1(self):
|
||||
return self._token_bal_check(pat=rf'{dfl_sid}:E:1\s+1000\s')
|
||||
|
||||
def token_txdo1(self):
|
||||
return self._token_txcreate(cmd='txdo', args=[f'{dfl_sid}:E:2,1.23456', dfl_words_file])
|
||||
|
||||
|
|
@ -373,7 +346,7 @@ class CmdTestEthBump(CmdTestEthBumpMethods, CmdTestEthdev, CmdTestSwapMethods):
|
|||
swaptxbump1sign = swaptxbump2sign = token_txbump2sign
|
||||
swaptxbump1send = swaptxbump2send = token_txbump2send
|
||||
|
||||
class CmdTestEthBumpLTC(CmdTestRegtest, CmdTestSwapMethods):
|
||||
class CmdTestEthBumpLTC(CmdTestSwapMethods, CmdTestRegtest):
|
||||
network = ('ltc',)
|
||||
tmpdir_nums = [43]
|
||||
cmd_group_in = CmdTestRegtest.cmd_group_in + (
|
||||
|
|
|
|||
|
|
@ -49,6 +49,7 @@ from ..include.common import (
|
|||
from .include.common import (
|
||||
ref_dir,
|
||||
dfl_words_file,
|
||||
dfl_sid,
|
||||
tx_comment_jp,
|
||||
tx_comment_lat_cyr_gr,
|
||||
tw_comment_zh,
|
||||
|
|
@ -65,7 +66,6 @@ from .httpd.etherscan import EtherscanServer
|
|||
etherscan_server = EtherscanServer()
|
||||
|
||||
del_addrs = ('4', '1')
|
||||
dfl_sid = '98831F3A'
|
||||
|
||||
# The OpenEthereum dev address with lots of coins. Create with "ethkey -b info ''":
|
||||
dfl_devaddr = '00a329c0648769a73afac7f9381e08fb43dbea72'
|
||||
|
|
@ -124,7 +124,7 @@ def set_vbals(daemon_id):
|
|||
|
||||
coin = cfg.coin
|
||||
|
||||
class CmdTestEthdevMethods: # mixin class
|
||||
class CmdTestEthdevMethods:
|
||||
|
||||
def _del_addr(self, addr):
|
||||
t = self.spawn('mmgen-tool', self.eth_opts + ['remove_address', addr])
|
||||
|
|
@ -186,6 +186,15 @@ class CmdTestEthdevMethods: # mixin class
|
|||
return_early = True,
|
||||
env = cleanup_env(cfg=self.cfg))
|
||||
|
||||
def fund_mmgen_addr1(self):
|
||||
return self._fund_mmgen_addr(arg=f'{dfl_sid}:E:1,{self.fund_amt}')
|
||||
|
||||
def fund_mmgen_addr2(self):
|
||||
return self._fund_mmgen_addr(arg=f'{dfl_sid}:E:11,{self.fund_amt}')
|
||||
|
||||
def fund_mmgen_addr3(self):
|
||||
return self._fund_mmgen_addr(arg=f'{dfl_sid}:E:21,{self.fund_amt}')
|
||||
|
||||
def _fund_mmgen_addr(self, arg):
|
||||
return self._txdo(
|
||||
args = [f'--keys-from-file={joinpath(self.tmpdir, dfl_devkey_fn)}', arg, dfl_words_file],
|
||||
|
|
@ -352,7 +361,7 @@ class CmdTestEthdevMethods: # mixin class
|
|||
end_silence()
|
||||
return 'ok'
|
||||
|
||||
class CmdTestEthdev(CmdTestBase, CmdTestShared, CmdTestEthdevMethods):
|
||||
class CmdTestEthdev(CmdTestEthdevMethods, CmdTestBase, CmdTestShared):
|
||||
'Ethereum transacting, token deployment and tracking wallet operations'
|
||||
networks = ('eth', 'etc')
|
||||
passthru_opts = ('coin', 'daemon_id', 'eth_daemon_id', 'http_timeout', 'rpc_backend')
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ from mmgen.cfg import Config
|
|||
from mmgen.protocol import init_proto
|
||||
|
||||
from .include.runner import CmdTestRunner
|
||||
from .include.common import dfl_seed_id
|
||||
from .include.common import dfl_sid
|
||||
from .httpd.thornode import ThornodeServer
|
||||
|
||||
from .regtest import CmdTestRegtest
|
||||
|
|
@ -31,7 +31,34 @@ def {name}(self):
|
|||
return ethswap_eth.run_test("{eth_name}", sub=True)
|
||||
"""
|
||||
|
||||
class CmdTestEthSwap(CmdTestRegtest, CmdTestSwapMethods):
|
||||
class CmdTestEthSwapMethods:
|
||||
|
||||
async def token_deploy_a(self):
|
||||
return await self._token_deploy_math(num=1, get_receipt=False)
|
||||
|
||||
async def token_deploy_b(self):
|
||||
return await self._token_deploy_owned(num=1, get_receipt=False)
|
||||
|
||||
async def token_deploy_c(self):
|
||||
return await self._token_deploy_token(num=1, get_receipt=False)
|
||||
|
||||
def token_fund_user(self):
|
||||
return self._token_transfer_ops(
|
||||
op = 'fund_user',
|
||||
mm_idxs = [1],
|
||||
amt = self.token_fund_amt,
|
||||
get_receipt = False)
|
||||
|
||||
def token_addrgen(self):
|
||||
return self._token_addrgen(mm_idxs=[1], naddrs=5)
|
||||
|
||||
def token_addrimport(self):
|
||||
return self._token_addrimport('token_addr1', '1-5', expect='5/5')
|
||||
|
||||
def token_bal1(self):
|
||||
return self._token_bal_check(pat=rf'{dfl_sid}:E:1\s+{self.token_fund_amt}\s')
|
||||
|
||||
class CmdTestEthSwap(CmdTestSwapMethods, CmdTestRegtest):
|
||||
'Ethereum swap operations'
|
||||
|
||||
bdb_wallet = True
|
||||
|
|
@ -76,10 +103,9 @@ class CmdTestEthSwap(CmdTestRegtest, CmdTestSwapMethods):
|
|||
),
|
||||
'eth_fund': (
|
||||
'funding the ETH tracking wallet',
|
||||
('eth_txcreate1', ''),
|
||||
('eth_txsign1', ''),
|
||||
('eth_txsend1', ''),
|
||||
('eth_bal1', ''),
|
||||
('eth_fund_mmgen_addr1', ''),
|
||||
('eth_fund_mmgen_addr2', ''),
|
||||
('eth_bal1', ''),
|
||||
),
|
||||
'swap': (
|
||||
'swap operations (BTC -> ETH)',
|
||||
|
|
@ -142,7 +168,7 @@ class CmdTestEthSwap(CmdTestRegtest, CmdTestSwapMethods):
|
|||
return self._swaptxcreate_ui_common(t)
|
||||
|
||||
def swaptxcreate2(self):
|
||||
t = self._swaptxcreate(['BTC', '8.765', 'ETH', f'{dfl_seed_id}:E:1'])
|
||||
t = self._swaptxcreate(['BTC', '8.765', 'ETH', f'{dfl_sid}:E:1'])
|
||||
t.expect('OK? (Y/n): ', 'y')
|
||||
return self._swaptxcreate_ui_common(t)
|
||||
|
||||
|
|
@ -159,12 +185,12 @@ class CmdTestEthSwap(CmdTestRegtest, CmdTestSwapMethods):
|
|||
return self._swaptxsend()
|
||||
|
||||
def swaptxbump1(self): # create one-output TX back to self to rescue funds
|
||||
return self._swaptxbump('40s', output_args=[f'{dfl_seed_id}:B:1'])
|
||||
return self._swaptxbump('40s', output_args=[f'{dfl_sid}:B:1'])
|
||||
|
||||
def swaptxdo1(self):
|
||||
return self._swaptxcreate_ui_common(
|
||||
self._swaptxcreate(
|
||||
['BTC', '0.223344', f'{dfl_seed_id}:B:3', 'ETH', f'{dfl_seed_id}:E:2'],
|
||||
['BTC', '0.223344', f'{dfl_sid}:B:3', 'ETH', f'{dfl_sid}:E:2'],
|
||||
action = 'txdo'),
|
||||
sign_and_send = True,
|
||||
file_desc = 'Sent transaction')
|
||||
|
|
@ -180,11 +206,13 @@ class CmdTestEthSwap(CmdTestRegtest, CmdTestSwapMethods):
|
|||
thornode_server.stop()
|
||||
return 'ok'
|
||||
|
||||
class CmdTestEthSwapEth(CmdTestEthdev, CmdTestSwapMethods):
|
||||
class CmdTestEthSwapEth(CmdTestEthSwapMethods, CmdTestSwapMethods, CmdTestEthdev):
|
||||
'Ethereum swap operations - Ethereum wallet'
|
||||
|
||||
networks = ('eth',)
|
||||
tmpdir_nums = [48]
|
||||
fund_amt = '123.456'
|
||||
token_fund_amt = 1000
|
||||
|
||||
bals = lambda self, k: {
|
||||
'swap1': [('98831F3A:E:1', '123.456')],
|
||||
|
|
@ -192,13 +220,15 @@ class CmdTestEthSwapEth(CmdTestEthdev, CmdTestSwapMethods):
|
|||
}[k]
|
||||
|
||||
cmd_group_in = CmdTestEthdev.cmd_group_in + (
|
||||
('swaptxcreate1', 'creating an ETH->BTC swap transaction'),
|
||||
('swaptxcreate2', 'creating an ETH->BTC swap transaction (specific address, trade limit)'),
|
||||
('swaptxsign1', 'signing the transaction'),
|
||||
('swaptxsend1', 'sending the transaction'),
|
||||
('swaptxstatus1', 'getting the transaction status (with --verbose)'),
|
||||
('bal1', 'the ETH balance'),
|
||||
('bal2', 'the ETH balance'),
|
||||
('fund_mmgen_addr1', 'funding user address :1)'),
|
||||
('fund_mmgen_addr2', 'funding user address :11)'),
|
||||
('swaptxcreate1', 'creating an ETH->BTC swap transaction'),
|
||||
('swaptxcreate2', 'creating an ETH->BTC swap transaction (specific address, trade limit)'),
|
||||
('swaptxsign1', 'signing the transaction'),
|
||||
('swaptxsend1', 'sending the transaction'),
|
||||
('swaptxstatus1', 'getting the transaction status (with --verbose)'),
|
||||
('bal1', 'the ETH balance'),
|
||||
('bal2', 'the ETH balance'),
|
||||
)
|
||||
|
||||
def swaptxcreate1(self):
|
||||
|
|
@ -209,7 +239,7 @@ class CmdTestEthSwapEth(CmdTestEthdev, CmdTestSwapMethods):
|
|||
def swaptxcreate2(self):
|
||||
return self._swaptxcreate_ui_common(
|
||||
self._swaptxcreate(
|
||||
['ETH', '8.765', 'BTC', f'{dfl_seed_id}:B:4'],
|
||||
['ETH', '8.765', 'BTC', f'{dfl_sid}:B:4'],
|
||||
add_opts = ['--trade-limit=3%']),
|
||||
expect = ':2019e4/1/0')
|
||||
|
||||
|
|
|
|||
|
|
@ -32,7 +32,6 @@ ref_wallet_brainpass = 'abc'
|
|||
ref_wallet_hash_preset = '1'
|
||||
ref_wallet_incog_offset = 123
|
||||
|
||||
dfl_seed_id = '98831F3A'
|
||||
dfl_addr_idx_list = '1010,500-501,31-33,1,33,500,1011'
|
||||
dfl_wpasswd = 'reference password'
|
||||
|
||||
|
|
@ -46,6 +45,8 @@ incog_id_fn = 'incog_id'
|
|||
non_mmgen_fn = 'coinkey'
|
||||
|
||||
ref_dir = os.path.join('test', 'ref')
|
||||
|
||||
dfl_sid = '98831F3A'
|
||||
dfl_words_file = os.path.join(ref_dir, '98831F3A.mmwords')
|
||||
dfl_bip39_file = os.path.join(ref_dir, '98831F3A.bip39')
|
||||
|
||||
|
|
|
|||
|
|
@ -170,6 +170,8 @@ class CmdTestRegtest(CmdTestBase, CmdTestShared):
|
|||
deterministic = False
|
||||
test_rbf = False
|
||||
bdb_wallet = False
|
||||
menu_prompt = 'abel:\b'
|
||||
input_sels_prompt = 'to spend: '
|
||||
|
||||
cmd_group_in = (
|
||||
('setup', 'regtest (Bob and Alice) mode setup'),
|
||||
|
|
|
|||
|
|
@ -30,8 +30,6 @@ sample1 = gr_uc[:24]
|
|||
sample2 = '00010203040506'
|
||||
|
||||
class CmdTestSwapMethods:
|
||||
menu_prompt = 'abel:\b'
|
||||
input_sels_prompt = 'to spend: '
|
||||
|
||||
@property
|
||||
def bob_opt(self):
|
||||
|
|
@ -265,7 +263,7 @@ class CmdTestSwapMethods:
|
|||
assert data
|
||||
return 'ok'
|
||||
|
||||
class CmdTestSwap(CmdTestRegtest, CmdTestAutosignThreaded, CmdTestSwapMethods):
|
||||
class CmdTestSwap(CmdTestSwapMethods, CmdTestRegtest, CmdTestAutosignThreaded):
|
||||
bdb_wallet = True
|
||||
networks = ('btc',)
|
||||
tmpdir_nums = [37]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue