def test_contract_storage_size_on_latest(initial_scenario): block = initial_scenario.get_block() db = initial_scenario.db state = StateDataset(db, decode_hex(block.stateRoot)) contract_address = initial_scenario.contract_address contract_size = initial_scenario.contract_storage_size logging.info('w3 code size %i on acc: %s on latest blk', contract_size, contract_address) contract = state.get_account(contract_address) assert contract_size == contract.storage_size(db)
def test_get_account(initial_scenario): latest_block = initial_scenario.get_block() latest_block_nbr = latest_block['number'] for n in range(NBR_RANDOM_TESTS): is_block_with_txn = False while not is_block_with_txn: n_blk = initial_scenario.get_block( random.randrange(1, latest_block_nbr)) if len(n_blk['transactions']) > 0: is_block_with_txn = True n_blk_nbr = n_blk['number'] to_account = random.choice(initial_scenario.accounts) to_account_nonce = initial_scenario.get_account_nonce( to_account, n_blk_nbr) logging.info('w3 nonce %i on acc: %s on blk: %i', to_account_nonce, to_account, n_blk_nbr) db = initial_scenario.db state = StateDataset(db, decode_hex(n_blk.stateRoot)) account = state.get_account(to_account) assert to_account_nonce == account.nonce