def test_unlockWallet(self): with set_qrl_dir("wallet_ver1"): walletd = WalletD() service = WalletAPIService(walletd) service.AddNewAddress(qrlwallet_pb2.AddNewAddressReq(), context=None) resp = service.ListAddresses(qrlwallet_pb2.ListAddressesReq(), context=None) self.assertEqual(resp.code, 0) self.assertEqual(len(resp.addresses), 1) resp = service.EncryptWallet(qrlwallet_pb2.EncryptWalletReq(passphrase=self.passphrase), context=None) self.assertEqual(resp.code, 0) resp = service.ListAddresses(qrlwallet_pb2.ListAddressesReq(), context=None) self.assertEqual(resp.code, 1) resp = service.UnlockWallet(qrlwallet_pb2.UnlockWalletReq(passphrase=self.passphrase), context=None) self.assertEqual(resp.code, 0) resp = service.ListAddresses(qrlwallet_pb2.ListAddressesReq(), context=None) self.assertEqual(resp.code, 0) resp = service.LockWallet(qrlwallet_pb2.LockWalletReq(), context=None) self.assertEqual(resp.code, 0) resp = service.ListAddresses(qrlwallet_pb2.ListAddressesReq(), context=None) self.assertEqual(resp.code, 1) resp = service.UnlockWallet(qrlwallet_pb2.UnlockWalletReq(), context=None) self.assertEqual(resp.code, 1) resp = service.UnlockWallet(qrlwallet_pb2.UnlockWalletReq(passphrase="wrong"), context=None) self.assertEqual(resp.code, 1)
def test_changePassphrase(self): with set_qrl_dir("wallet_ver1"): walletd = WalletD() service = WalletAPIService(walletd) service.AddNewAddress(qrlwallet_pb2.AddNewAddressReq(), context=None) resp = service.ListAddresses(qrlwallet_pb2.ListAddressesReq(), context=None) self.assertEqual(resp.code, 0) self.assertEqual(len(resp.addresses), 1) resp = service.EncryptWallet( qrlwallet_pb2.EncryptWalletReq(passphrase=self.passphrase), context=None) self.assertEqual(resp.code, 0) resp = service.ListAddresses(qrlwallet_pb2.ListAddressesReq(), context=None) self.assertEqual(resp.code, 1) resp = service.UnlockWallet( qrlwallet_pb2.UnlockWalletReq(passphrase=self.passphrase), context=None) self.assertEqual(resp.code, 0) resp = service.ListAddresses(qrlwallet_pb2.ListAddressesReq(), context=None) self.assertEqual(resp.code, 0) resp = service.LockWallet(qrlwallet_pb2.LockWalletReq(), context=None) self.assertEqual(resp.code, 0) new_passphrase = "Hello World" resp = service.ChangePassphrase(qrlwallet_pb2.ChangePassphraseReq( oldPassphrase=self.passphrase, newPassphrase=new_passphrase), context=None) self.assertEqual(resp.code, 0) resp = service.UnlockWallet( qrlwallet_pb2.UnlockWalletReq(passphrase=self.passphrase), context=None) self.assertEqual(resp.code, 1) resp = service.UnlockWallet( qrlwallet_pb2.UnlockWalletReq(passphrase=new_passphrase), context=None) self.assertEqual(resp.code, 0)
def test_removeAddress(self): with set_qrl_dir("wallet_ver1"): walletd = WalletD() service = WalletAPIService(walletd) resp = service.AddNewAddress(qrlwallet_pb2.AddNewAddressReq(), context=None) address = resp.address resp = service.ListAddresses(qrlwallet_pb2.ListAddressesReq(), context=None) self.assertEqual(len(resp.addresses), 1) resp = service.RemoveAddress(qrlwallet_pb2.RemoveAddressReq(address=address), context=None) self.assertEqual(resp.code, 0) resp = service.ListAddresses(qrlwallet_pb2.ListAddressesReq(), context=None) self.assertEqual(len(resp.addresses), 0)
def test_listAddresses(self): with set_qrl_dir("wallet_ver1"): walletd = WalletD() service = WalletAPIService(walletd) resp = service.AddNewAddress(qrlwallet_pb2.AddNewAddressReq(), context=None) address = resp.address resp = service.ListAddresses(qrlwallet_pb2.ListAddressesReq(), context=None) self.assertEqual(resp.addresses[0], address)