def test_relaySlaveTxn(self): with set_qrl_dir("wallet_ver1"): walletd = WalletD() service = WalletAPIService(walletd) resp = service.AddNewAddress(qrlwallet_pb2.AddNewAddressReq(), context=None) qaddress = resp.address addr_state = AddressState.get_default(walletd.qaddress_to_address(qaddress)) walletd._public_stub.GetAddressState = Mock( return_value=qrl_pb2.GetAddressStateResp(state=addr_state.pbdata)) walletd._public_stub.IsSlave = Mock( return_value=qrl_pb2.IsSlaveResp(result=True)) walletd._public_stub.GetOTS = Mock( return_value=qrl_pb2.GetOTSResp(next_unused_ots_index=0, unused_ots_index_found=True)) alice_xmss = get_alice_xmss(4) slave_pks = [alice_xmss.pk] access_types = [0] walletd._public_stub.PushTransaction = Mock( return_value=qrl_pb2.PushTransactionResp(error_code=qrl_pb2.PushTransactionResp.SUBMITTED)) resp = service.RelaySlaveTxn(qrlwallet_pb2.RelaySlaveTxnReq(slave_pks=slave_pks, access_types=access_types, fee=100000000, master_address=None, signer_address=qaddress, ots_index=0), context=None) self.assertEqual(resp.code, 0) self.assertIsNotNone(resp.tx)
def test_relayTokenTxn(self): with set_qrl_dir("wallet_ver1"): walletd = WalletD() service = WalletAPIService(walletd) resp = service.AddNewAddress(qrlwallet_pb2.AddNewAddressReq(), context=None) qaddress = resp.address addr_state = AddressState.get_default(walletd.qaddress_to_address(qaddress)) walletd._public_stub.GetAddressState = Mock( return_value=qrl_pb2.GetAddressStateResp(state=addr_state.pbdata)) walletd._public_stub.IsSlave = Mock( return_value=qrl_pb2.IsSlaveResp(result=True)) walletd._public_stub.GetOTS = Mock( return_value=qrl_pb2.GetOTSResp(next_unused_ots_index=0, unused_ots_index_found=True)) alice_xmss = get_alice_xmss(4) bob_xmss = get_bob_xmss(4) qaddresses = [alice_xmss.qaddress, bob_xmss.qaddress] amounts = [1000000000, 1000000000] walletd._public_stub.PushTransaction = Mock( return_value=qrl_pb2.PushTransactionResp(error_code=qrl_pb2.PushTransactionResp.SUBMITTED)) resp = service.RelayTokenTxn(qrlwallet_pb2.RelayTokenTxnReq(symbol=b'QRL', name=b'Quantum Resistant Ledger', owner=alice_xmss.qaddress, decimals=5, addresses=qaddresses, amounts=amounts, fee=100000000, master_address=None, signer_address=qaddress, ots_index=0), context=None) self.assertEqual(resp.code, 0) self.assertIsNotNone(resp.tx)
def IsSlave(self, request: qrl_pb2.IsSlaveReq, context) -> qrl_pb2.IsSlaveResp: return qrl_pb2.IsSlaveResp(result=self.qrlnode.is_slave( request.master_address, request.slave_pk))