eth, cmdtest.py ethdev: minor changes, cleanups
This commit is contained in:
parent
6ceff42ff8
commit
ef8e994266
4 changed files with 21 additions and 34 deletions
|
|
@ -112,24 +112,17 @@ class geth_daemon(ethereum_daemon):
|
|||
|
||||
def init_subclass(self):
|
||||
|
||||
def have_authrpc():
|
||||
from subprocess import run, PIPE
|
||||
try:
|
||||
return b'authrpc' in run(['geth', 'help'], check=True, stdout=PIPE).stdout
|
||||
except:
|
||||
return False
|
||||
|
||||
self.coind_args = list_gen(
|
||||
['--verbosity=0'],
|
||||
['--ipcdisable'], # IPC-RPC: if path to socket is longer than 108 chars, geth fails to start
|
||||
['--http'],
|
||||
['--http.api=eth,web3,txpool'],
|
||||
[f'--http.port={self.rpc_port}'],
|
||||
[f'--authrpc.port={self.authrpc_port}', have_authrpc()],
|
||||
[f'--authrpc.port={self.authrpc_port}'],
|
||||
[f'--port={self.p2p_port}', self.p2p_port], # geth binds p2p port even with --maxpeers=0
|
||||
['--maxpeers=0', not self.opt.online],
|
||||
[f'--datadir={self.datadir}', self.non_dfl_datadir],
|
||||
['--goerli', self.network=='testnet'],
|
||||
['--holesky', self.network=='testnet'],
|
||||
['--dev', self.network=='regtest'],
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -67,10 +67,10 @@ class Base(TxBase.Base):
|
|||
gas_sent = Int(tx['gas'], 16),
|
||||
gas_used = Int(rx['gasUsed'], 16),
|
||||
gas_price = self.proto.coin_amt(int(tx['gasPrice'], 16), from_unit='wei'),
|
||||
contract_addr = self.proto.coin_addr(rx['contractAddress'][2:]) if rx['contractAddress'] else None,
|
||||
tx = tx,
|
||||
rx = rx,
|
||||
)
|
||||
contract_addr = self.proto.coin_addr(rx['contractAddress'][2:])
|
||||
if rx['contractAddress'] else None,
|
||||
tx = tx,
|
||||
rx = rx)
|
||||
|
||||
def check_serialized_integrity(self): # TODO
|
||||
return True
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ dfl_devkey = '4d5db4107d237df6a3d58ee5f70ae63d73d7658d4026f2eefd2f204c81682cb7'
|
|||
burn_addr = 'deadbeef'*5
|
||||
burn_addr2 = 'beadcafe'*5
|
||||
|
||||
amt1 = '999999.12345689012345678'
|
||||
amt1 = '999777.12345689012345678'
|
||||
amt2 = '888.111122223333444455'
|
||||
|
||||
parity_devkey_fn = 'parity.devkey'
|
||||
|
|
@ -81,9 +81,9 @@ def set_vbals(daemon_id):
|
|||
vbal2 = '99.996560752'
|
||||
vbal3 = '1.2314176'
|
||||
vbal4 = '127.0287834'
|
||||
vbal5 = '1000126.14775104212345678'
|
||||
vbal6 = '1000126.14880104212345678'
|
||||
vbal7 = '1000124.91891764212345678'
|
||||
vbal5 = '999904.14775104212345678'
|
||||
vbal6 = '999904.14880104212345678'
|
||||
vbal7 = '999902.91891764212345678'
|
||||
vbal9 = '1.2262504'
|
||||
else:
|
||||
vbal1 = '1.2288396'
|
||||
|
|
@ -153,7 +153,7 @@ token_bals = lambda k: {
|
|||
}[k]
|
||||
|
||||
token_bals_getbalance = lambda k: {
|
||||
'1': (vbal4, '999999.12345689012345678'),
|
||||
'1': (vbal4, '999777.12345689012345678'),
|
||||
'2': ('111.888877776666555545', '888.111122223333444455')
|
||||
}[k]
|
||||
|
||||
|
|
@ -267,8 +267,6 @@ class CmdTestEthdev(CmdTestBase, CmdTestShared):
|
|||
('token_deploy2a', 'deploying ERC20 token #2 (SafeMath)'),
|
||||
('token_deploy2b', 'deploying ERC20 token #2 (Owned)'),
|
||||
('token_deploy2c', 'deploying ERC20 token #2 (Token)'),
|
||||
|
||||
('contract_deploy', 'deploying contract (create, sign, send)'),
|
||||
),
|
||||
'token': (
|
||||
'creating, signing, sending and bumping ERC20 token transactions',
|
||||
|
|
@ -436,14 +434,14 @@ class CmdTestEthdev(CmdTestBase, CmdTestShared):
|
|||
async def setup(self):
|
||||
self.spawn('', msg_only=True)
|
||||
|
||||
d = self.daemon
|
||||
|
||||
if not self.using_solc:
|
||||
srcdir = os.path.join(self.tr.repo_root, 'test', 'ref', 'ethereum', 'bin')
|
||||
from shutil import copytree
|
||||
for d in ('mm1', 'mm2'):
|
||||
copytree(os.path.join(srcdir, d), os.path.join(self.tmpdir, d))
|
||||
|
||||
d = self.daemon
|
||||
|
||||
if d.id in ('geth', 'erigon'):
|
||||
self.genesis_setup(d)
|
||||
set_vt100()
|
||||
|
|
@ -596,7 +594,10 @@ class CmdTestEthdev(CmdTestBase, CmdTestShared):
|
|||
return await self._wallet_upgrade('tracking-wallet-v2.json', 'token params field', 'network field')
|
||||
|
||||
def addrgen(self, addrs='1-3,11-13,21-23'):
|
||||
t = self.spawn('mmgen-addrgen', self.eth_args + [dfl_words_file, addrs])
|
||||
t = self.spawn(
|
||||
'mmgen-addrgen',
|
||||
[f'--coin={self.proto.coin}'] + self.eth_args + [dfl_words_file, addrs],
|
||||
no_passthru_opts = True)
|
||||
t.written_to_file('Addresses')
|
||||
return t
|
||||
|
||||
|
|
@ -1035,16 +1036,13 @@ class CmdTestEthdev(CmdTestBase, CmdTestShared):
|
|||
def bal6(self):
|
||||
return self.bal5()
|
||||
|
||||
async def token_deploy2a(self):
|
||||
return await self.token_deploy(num=2, key='SafeMath', gas=500_000)
|
||||
async def token_deploy2a(self): # test create, sign, send:
|
||||
return await self.token_deploy(num=2, key='SafeMath', gas=500_000, mmgen_cmd='txcreate')
|
||||
async def token_deploy2b(self):
|
||||
return await self.token_deploy(num=2, key='Owned', gas=1_000_000)
|
||||
async def token_deploy2c(self):
|
||||
return await self.token_deploy(num=2, key='Token', gas=4_000_000)
|
||||
|
||||
async def contract_deploy(self): # test create, sign, send
|
||||
return await self.token_deploy(num=2, key='SafeMath', gas=500_000, mmgen_cmd='txcreate')
|
||||
|
||||
async def token_transfer_ops(self, op, amt=1000, num_tokens=2):
|
||||
self.spawn('', msg_only=True)
|
||||
sid = dfl_sid
|
||||
|
|
|
|||
|
|
@ -110,16 +110,12 @@ class CmdTestInput(CmdTestBase):
|
|||
def get_seed_from_stdin(self):
|
||||
self.spawn('', msg_only=True)
|
||||
from subprocess import run, PIPE
|
||||
cmd = ['python3', 'cmds/mmgen-walletconv', '--in-fmt=words', '--out-fmt=words', '--outdir=test/trash']
|
||||
cmd = ['python3', 'cmds/mmgen-walletconv', '--skip-cfg-file', '--in-fmt=words', '--out-fmt=words', '--outdir=test/trash']
|
||||
mn = sample_mn['mmgen']['mn']
|
||||
run_env = dict(os.environ)
|
||||
run_env['MMGEN_TEST_SUITE'] = ''
|
||||
|
||||
# the test can fail the first time if cfg file has changed, so run it twice if necessary:
|
||||
for _ in range(2):
|
||||
cp = run(cmd, input=mn.encode(), stdout=PIPE, stderr=PIPE, env=run_env)
|
||||
if b'written to file' in cp.stderr:
|
||||
break
|
||||
cp = run(cmd, input=mn.encode(), stdout=PIPE, stderr=PIPE, env=run_env)
|
||||
|
||||
from mmgen.color import set_vt100
|
||||
set_vt100()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue