async def asyncSetUp(self): self.manager = WalletManager() config = {'data_path': '/tmp/wallet'} self.main_ledger = self.manager.get_or_create_ledger( Ledger.get_id(), config) self.test_ledger = self.manager.get_or_create_ledger( RegTestLedger.get_id(), config)
def test_read_write(self): manager = WalletManager() config = {'data_path': '/tmp/wallet'} ledger = manager.get_or_create_ledger(Ledger.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)