def test_get_account_list_no_dir(self): """ The keystore directory should be created if it doesn't exist, refs: https://github.com/AndreMiras/PyWallet/issues/133 """ # nominal case when the directory already exists with TemporaryDirectory() as keystore_dir: self.assertTrue(os.path.isdir(keystore_dir)) account_utils = AccountUtils(keystore_dir) self.assertEqual(account_utils.get_account_list(), []) # when the directory doesn't exist it should also be created self.assertFalse(os.path.isdir(keystore_dir)) account_utils = AccountUtils(keystore_dir) self.assertTrue(os.path.isdir(keystore_dir)) self.assertEqual(account_utils.get_account_list(), []) shutil.rmtree(keystore_dir, ignore_errors=True)
def __init__(self): keystore_dir = self.get_keystore_path() self.account_utils = AccountUtils(keystore_dir=keystore_dir) self._pyetheroll = None # per address cached merged logs, used to compare with next pulls self.merged_logs = {} self.last_roll_activity = None
def __init__(self, keystore_dir=None, chain_id=ChainID.MAINNET): if keystore_dir is None: keystore_dir = PyWalib.get_default_keystore_path() self.keystore_dir = keystore_dir self.account_utils = AccountUtils(keystore_dir=self.keystore_dir) self.chain_id = chain_id self.provider = HTTPProviderFactory.create(self.chain_id) self.web3 = Web3(self.provider)
def account_utils(self): """ Gets or creates the AccountUtils object so it loads lazily. """ from ethereum_utils import AccountUtils if self._account_utils is None: keystore_dir = self.get_keystore_path() self._account_utils = AccountUtils(keystore_dir=keystore_dir) return self._account_utils
def test_delete_account(self): """ Creates a new account and delete it. Then verify we can load the account from the backup/trash location. """ password = PASSWORD account = self.account_utils.new_account(password, iterations=1) address = account.address self.assertEqual(len(self.account_utils.get_account_list()), 1) # deletes the account and verifies it's not loaded anymore self.account_utils.delete_account(account) self.assertEqual(len(self.account_utils.get_account_list()), 0) # even recreating the AccountUtils object self.account_utils = AccountUtils(self.keystore_dir) self.assertEqual(len(self.account_utils.get_account_list()), 0) # tries to reload it from the backup/trash location deleted_keystore_dir = AccountUtils.deleted_account_dir( self.keystore_dir) self.account_utils = AccountUtils(deleted_keystore_dir) self.assertEqual(len(self.account_utils.get_account_list()), 1) self.assertEqual(self.account_utils.get_account_list()[0].address, address)
def __init__(self, osc_server_port=None): """ Set `osc_server_port` to enable UI synchronization with service. """ keystore_dir = self.get_keystore_path() self.account_utils = AccountUtils(keystore_dir=keystore_dir) self._pyetheroll = None # per address cached merged logs, used to compare with next pulls self.merged_logs = {} self.last_roll_activity = None self.osc_app_client = None if osc_server_port is not None: self.osc_app_client = OscAppClient('localhost', osc_server_port)
def setUp(self): self.keystore_dir = mkdtemp() self.account_utils = AccountUtils(self.keystore_dir)