def setUp(self): self.manager = WalletManager() config = {'wallet_path': '/tmp/wallet'} self.btc_ledger = self.manager.get_or_create_ledger( BTCLedger.get_id(), config) self.bch_ledger = self.manager.get_or_create_ledger( BCHLedger.get_id(), config)
async def asyncSetUp(self): self.manager = BaseWalletManager() config = {'data_path': '/tmp/wallet'} self.btc_ledger = self.manager.get_or_create_ledger( BTCLedger.get_id(), config) self.bch_ledger = self.manager.get_or_create_ledger( BCHLedger.get_id(), config)
def test_read_write(self): manager = BaseWalletManager() config = {'data_path': '/tmp/wallet'} ledger = manager.get_or_create_ledger(BTCLedger.get_id(), config) with tempfile.NamedTemporaryFile(suffix='.json') as wallet_file: wallet_file.write(b'{"version": 1}') wallet_file.seek(0) # create and write wallet to a file wallet = manager.import_wallet(wallet_file.name) account = wallet.generate_account(ledger) wallet.save() # read wallet from file wallet_storage = WalletStorage(wallet_file.name) wallet = Wallet.from_storage(wallet_storage, manager) self.assertEqual(account.public_key.address, wallet.default_account.public_key.address)