Correct token registry used as account registry, add token symbol to verify
This commit is contained in:
parent
30d86884a4
commit
b11fb9542c
@ -352,7 +352,14 @@ class TrafficSyncHandler:
|
||||
recipient_index = random.randint(0, len(traffic_provisioner.accounts)-1)
|
||||
recipient = traffic_provisioner.accounts[recipient_index]
|
||||
|
||||
logg.debug('trigger item {} tokens {} sender {} recipient {} balance {}')
|
||||
logg.debug('trigger item {} tokens {} sender {} recipient {} balance {}'.format(
|
||||
traffic_item,
|
||||
token_pair,
|
||||
sender,
|
||||
recipient,
|
||||
balance_full,
|
||||
)
|
||||
)
|
||||
(e, t, balance_result,) = traffic_item.method(
|
||||
token_pair,
|
||||
sender,
|
||||
|
@ -33,7 +33,7 @@ def do(token_pair, sender, recipient, sender_balance, aux, block_number):
|
||||
balance_units = int(sender_balance_value / decimals)
|
||||
|
||||
if balance_units <= 0:
|
||||
return (AttributeError('sender {} has zero balance'), None, 0,)
|
||||
return (AttributeError('sender {} has zero balance ({} / {})'.format(sender, sender_balance_value, decimals)), None, 0,)
|
||||
|
||||
spend_units = random.randint(1, balance_units)
|
||||
spend_value = spend_units * decimals
|
||||
|
@ -101,14 +101,14 @@ def main():
|
||||
logg.info('using token registry {}'.format(token_registry))
|
||||
token_cache = TokenRegistryCache(chain_spec, token_registry)
|
||||
|
||||
account_registry = registry.lookup('TokenRegistry')
|
||||
account_registry = registry.lookup('AccountRegistry')
|
||||
logg.info('using account registry {}'.format(account_registry))
|
||||
account_cache = AccountRegistryCache(chain_spec, account_registry)
|
||||
|
||||
# Set up provisioner for common task input data
|
||||
#TrafficProvisioner.oracles['token']= common.registry.TokenOracle(w3, config.get('CIC_CHAIN_SPEC'), registry)
|
||||
#TrafficProvisioner.oracles['account'] = common.registry.AccountsOracle(w3, config.get('CIC_CHAIN_SPEC'), registry)
|
||||
TrafficProvisioner.oracles['token']= token_cache
|
||||
TrafficProvisioner.oracles['token'] = token_cache
|
||||
TrafficProvisioner.oracles['account'] = account_cache
|
||||
|
||||
TrafficProvisioner.default_aux = {
|
||||
|
@ -1,4 +1,4 @@
|
||||
[traffic]
|
||||
#local.noop_traffic = 2
|
||||
local.account = 2
|
||||
#local.account = 2
|
||||
local.transfer = 2
|
||||
|
@ -1,5 +1,5 @@
|
||||
cic-base[full_graph]==0.1.2b9
|
||||
cic-base[full_graph]==0.1.2b11
|
||||
sarafu-faucet==0.0.3a3
|
||||
cic-eth==0.11.0b13
|
||||
cic-eth==0.11.0b14
|
||||
cic-types==0.1.0a11
|
||||
crypto-dev-signer==0.4.14b3
|
||||
|
@ -72,6 +72,7 @@ argparser.add_argument('--ussd-provider', type=str, dest='ussd_provider', defaul
|
||||
argparser.add_argument('--skip-custodial', dest='skip_custodial', action='store_true', help='skip all custodial verifications')
|
||||
argparser.add_argument('--exclude', action='append', type=str, default=[], help='skip specified verification')
|
||||
argparser.add_argument('--include', action='append', type=str, help='include specified verification')
|
||||
argparser.add_argument('--token-symbol', default='SRF', type=str, dest='token_symbol', help='Token symbol to use for trnsactions')
|
||||
argparser.add_argument('-r', '--registry-address', type=str, dest='r', help='CIC Registry address')
|
||||
argparser.add_argument('--env-prefix', default=os.environ.get('CONFINI_ENV_PREFIX'), dest='env_prefix', type=str, help='environment prefix for variables to overwrite configuration')
|
||||
argparser.add_argument('-x', '--exit-on-error', dest='x', action='store_true', help='Halt exection on error')
|
||||
@ -101,6 +102,8 @@ config.censor('PASSWORD', 'SSL')
|
||||
config.add(args.meta_provider, '_META_PROVIDER', True)
|
||||
config.add(args.ussd_provider, '_USSD_PROVIDER', True)
|
||||
|
||||
token_symbol = args.token_symbol
|
||||
|
||||
logg.debug('config loaded from {}:\n{}'.format(config_dir, config))
|
||||
|
||||
celery_app = celery.Celery(backend=config.get('CELERY_RESULT_URL'), broker=config.get('CELERY_BROKER_URL'))
|
||||
@ -273,7 +276,10 @@ class Verifier:
|
||||
def verify_balance(self, address, balance):
|
||||
o = self.erc20_tx_factory.balance(self.token_address, address)
|
||||
r = self.conn.do(o)
|
||||
actual_balance = int(strip_0x(r), 16)
|
||||
try:
|
||||
actual_balance = int(strip_0x(r), 16)
|
||||
except ValueError:
|
||||
actual_balance = int(r)
|
||||
balance = int(balance / 1000000) * 1000000
|
||||
logg.debug('balance for {}: {}'.format(address, balance))
|
||||
if balance != actual_balance:
|
||||
@ -461,7 +467,7 @@ def main():
|
||||
tx = txf.template(ZERO_ADDRESS, token_index_address)
|
||||
data = add_0x(registry_addressof_method)
|
||||
h = hashlib.new('sha256')
|
||||
h.update(b'SRF')
|
||||
h.update(token_symbol.encode('utf-8'))
|
||||
z = h.digest()
|
||||
data += eth_abi.encode_single('bytes32', z).hex()
|
||||
txf.set_code(tx, data)
|
||||
|
Loading…
Reference in New Issue
Block a user