From 2c29dd56dc74aa3da20c1bcdd46694fee209acfc Mon Sep 17 00:00:00 2001 From: nolash Date: Thu, 19 Aug 2021 08:08:57 +0200 Subject: [PATCH] Add target count to verify, rehabilitate eth import balancE --- apps/cic-eth/cic_eth/version.py | 4 ++-- apps/data-seeding/eth/import_balance.py | 4 +++- apps/data-seeding/verify.py | 12 +++++++----- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/apps/cic-eth/cic_eth/version.py b/apps/cic-eth/cic_eth/version.py index f9ac618b..d2140054 100644 --- a/apps/cic-eth/cic_eth/version.py +++ b/apps/cic-eth/cic_eth/version.py @@ -9,8 +9,8 @@ import semver version = ( 0, 12, - 2, - 'alpha.4', + 3, + 'alpha.1', ) version_object = semver.VersionInfo( diff --git a/apps/data-seeding/eth/import_balance.py b/apps/data-seeding/eth/import_balance.py index e70bce49..62374503 100644 --- a/apps/data-seeding/eth/import_balance.py +++ b/apps/data-seeding/eth/import_balance.py @@ -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 diff --git a/apps/data-seeding/verify.py b/apps/data-seeding/verify.py index 1c227740..c64e42d6 100644 --- a/apps/data-seeding/verify.py +++ b/apps/data-seeding/verify.py @@ -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)