Add target count to verify, rehabilitate eth import balancE

This commit is contained in:
nolash 2021-08-19 08:08:57 +02:00
parent fffb2bc3f4
commit 2c29dd56dc
Signed by untrusted user who does not match committer: lash
GPG Key ID: 21D2E7BB88C2A746
3 changed files with 12 additions and 8 deletions

View File

@ -9,8 +9,8 @@ import semver
version = (
0,
12,
2,
'alpha.4',
3,
'alpha.1',
)
version_object = semver.VersionInfo(

View File

@ -37,7 +37,8 @@ from crypto_dev_signer.eth.signer import ReferenceSigner as EIP155Signer
from crypto_dev_signer.keystore.dict import DictKeystore
from cic_types.models.person import Person
from eth_erc20 import ERC20
from cic_base.eth.syncer import chain_interface
#from cic_base.eth.syncer import chain_interface
from cic_eth.cli.chain import chain_interface
from eth_accounts_index import AccountsIndex
from eth_contract_registry import Registry
from eth_token_index import TokenUniqueSymbolIndex
@ -172,6 +173,7 @@ class Handler:
erc20 = ERC20(self.chain_spec, signer=self.signer, gas_oracle=self.gas_oracle, nonce_oracle=self.nonce_oracle)
o = erc20.decimals(self.token_address)
r = conn.do(o)
logg.debug('parse dec {}'.format(r))
decimals = erc20.parse_decimals(r)
multiplier = 10 ** decimals
balance_full = balance * multiplier

View File

@ -205,8 +205,9 @@ def send_ussd_request(address, data_dir):
class VerifierState:
def __init__(self, item_keys, active_tests=None):
def __init__(self, item_keys, target_count, active_tests=None):
self.items = {}
self.target_count = target_count
for k in item_keys:
self.items[k] = 0
if active_tests == None:
@ -223,7 +224,7 @@ class VerifierState:
r = ''
for k in self.items.keys():
if k in self.active_tests:
r += '{}: {}\n'.format(k, self.items[k])
r += '{}: {}/{}\n'.format(k, self.items[k], self.target_count)
else:
r += '{}: skipped\n'.format(k)
return r
@ -244,7 +245,7 @@ class VerifierError(Exception):
class Verifier:
# TODO: what an awful function signature
def __init__(self, conn, cic_eth_api, gas_oracle, chain_spec, index_address, token_address, faucet_address, data_dir, exit_on_error=False):
def __init__(self, conn, target_count, cic_eth_api, gas_oracle, chain_spec, index_address, token_address, faucet_address, data_dir, exit_on_error=False):
self.conn = conn
self.gas_oracle = gas_oracle
self.chain_spec = chain_spec
@ -268,7 +269,7 @@ class Verifier:
self.faucet_amount = self.faucet_tx_factory.parse_token_amount(r)
logg.info('faucet amount set to {} at verify initialization time'.format(self.faucet_amount))
self.state = VerifierState(verifymethods, active_tests=active_tests)
self.state = VerifierState(verifymethods, target_count, active_tests=active_tests)
def verify_accounts_index(self, address, balance=None):
@ -481,7 +482,7 @@ def main():
f.close()
verifier = Verifier(conn, api, gas_oracle, chain_spec, account_index_address, token_address, faucet_address, user_dir, exit_on_error)
verifier = Verifier(conn, i, api, gas_oracle, chain_spec, account_index_address, token_address, faucet_address, user_dir, exit_on_error)
user_new_dir = os.path.join(user_dir, 'new')
i = 0
@ -517,6 +518,7 @@ def main():
verifier.verify(new_address, balance, debug_stem=s)
i += 1
print()
print(verifier)