コード例 #1
0
ファイル: test_WalletAPIService.py プロジェクト: zeta1999/QRL
    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)
コード例 #2
0
ファイル: test_WalletAPIService.py プロジェクト: zeta1999/QRL
    def test_relayMessageTxn(self):
        with set_qrl_dir("wallet_ver1"):
            walletd = WalletD()
            walletd._public_stub.PushTransaction = Mock(
                return_value=qrl_pb2.PushTransactionResp(error_code=qrl_pb2.PushTransactionResp.SUBMITTED))

            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.GetOTS = Mock(
                return_value=qrl_pb2.GetOTSResp(next_unused_ots_index=0,
                                                unused_ots_index_found=True))

            resp = service.RelayMessageTxn(qrlwallet_pb2.RelayMessageTxnReq(message=b'Hello QRL!',
                                                                            fee=100000000,
                                                                            master_address=None,
                                                                            signer_address=qaddress,
                                                                            ots_index=0), context=None)

            self.assertEqual(0, resp.code)
            self.assertIsNotNone(resp.tx)
コード例 #3
0
 def GetOTS(self, request: qrl_pb2.GetOTSReq,
            context) -> qrl_pb2.GetOTSResp:
     logger.debug("[PublicAPI] GetOTS")
     address_state = self.qrlnode.get_address_state(request.address)
     response = qrl_pb2.GetOTSResp(
         ots_bitfield=address_state.ots_bitfield,
         next_unused_ots_index=address_state.get_unused_ots_index())
     return response
コード例 #4
0
    def test_get_ots(self):
        with set_qrl_dir("wallet_ver1"):
            walletd = WalletD()
            walletd._public_stub.GetOTS = Mock(return_value=qrl_pb2.GetOTSResp(
                ots_bitfield=[b'\x00'] * 10, next_unused_ots_index=1))

            ots_bitfield, next_unused_ots_index = walletd.get_ots(
                self.qaddress)
            self.assertEqual(ots_bitfield, [b'\x00'] * 10)
            self.assertEqual(next_unused_ots_index, 1)
コード例 #5
0
    def test_getOTS(self):
        with set_qrl_dir("wallet_ver1"):
            walletd = WalletD()
            service = WalletAPIService(walletd)

            walletd._public_stub.GetOTS = Mock(
                return_value=qrl_pb2.GetOTSResp(ots_bitfield=[b'\x00'] * 10, next_unused_ots_index=1))

            resp = service.GetOTS(qrlwallet_pb2.OTSReq(address=self.qaddress), context=None)

            self.assertEqual(resp.code, 0)
            self.assertEqual(resp.ots_bitfield, [b'\x00'] * 10)
            self.assertEqual(resp.next_unused_ots_index, 1)
コード例 #6
0
ファイル: PublicAPIService.py プロジェクト: theQRL/QRL
 def GetOTS(self, request: qrl_pb2.GetOTSReq,
            context) -> qrl_pb2.GetOTSResp:
     logger.debug("[PublicAPI] GetOTS")
     ots_bitfield_by_page, next_unused_ots_index, unused_ots_index_found = \
         self.qrlnode.get_ots(request.address,
                              request.page_from,
                              request.page_count,
                              request.unused_ots_index_from)
     response = qrl_pb2.GetOTSResp(
         ots_bitfield_by_page=ots_bitfield_by_page,
         next_unused_ots_index=next_unused_ots_index,
         unused_ots_index_found=unused_ots_index_found)
     return response
コード例 #7
0
ファイル: test_WalletAPIService.py プロジェクト: zeta1999/QRL
    def test_getOTS(self):
        with set_qrl_dir("wallet_ver1"):
            walletd = WalletD()
            service = WalletAPIService(walletd)

            ots_bitfield_by_page = qrl_pb2.OTSBitfieldByPage(ots_bitfield=[b'\x00'] * 10,
                                                             page_number=1)
            walletd._public_stub.GetOTS = Mock(
                return_value=qrl_pb2.GetOTSResp(ots_bitfield_by_page=[ots_bitfield_by_page],
                                                next_unused_ots_index=1,
                                                unused_ots_index_found=True))

            resp = service.GetOTS(qrlwallet_pb2.OTSReq(address=self.qaddress), context=None)
            self.assertEqual(resp.code, 0)
            self.assertEqual(len(resp.ots_bitfield_by_page), 1)
            self.assertEqual(resp.ots_bitfield_by_page[0], ots_bitfield_by_page)
            self.assertEqual(resp.next_unused_ots_index, 1)
コード例 #8
0
ファイル: test_WalletAPIService.py プロジェクト: zeta1999/QRL
    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)