Exemplo n.º 1
0
    async def test_get_transactions(self):
        """
        Test whether transactions in bitcoinlib are correctly returned
        """
        mock_wallet = MockObject()
        mock_wallet.transactions_update = lambda **_: None
        mock_wallet._session = MockObject()

        mock_all = MockObject()
        mock_all.all = lambda *_: [(self.raw_tx, 3, datetime.datetime(2012, 9, 16, 0, 0), 12345)]
        mock_filter = MockObject()
        mock_filter.filter = lambda *_: mock_all
        mock_wallet._session.query = lambda *_: mock_filter
        self.wallet.wallet = mock_wallet
        self.wallet.wallet.wallet_id = 3

        mock_key = MockObject()
        mock_key.address = self.address
        self.wallet.wallet.keys = lambda **_: [mock_key]
        self.wallet.created = True

        transactions = await self.wallet.get_transactions()
        self.assertTrue(transactions)
        self.assertEqual(transactions[0]["fee_amount"], 12345)
        self.assertEqual(transactions[0]["amount"], self.amount)
Exemplo n.º 2
0
async def test_get_transactions(wallet):
    """
    Test whether transactions in bitcoinlib are correctly returned
    """
    raw_tx = '02000000014bca66ebc0e3ab0c5c3aec6d0b3895b968497397752977dfd4a2f0bc67db6810000000006b483045022100fc' \
             '93a034db310fbfead113283da95e980ac7d867c7aa4e6ef0aba80ef321639e02202bc7bd7b821413d814d9f7d6fc76ff46' \
             'b9cd3493173ef8d5fac40bce77a7016d01210309702ce2d5258eacc958e5a925b14de912a23c6478b8e2fb82af43d20212' \
             '14f3feffffff029c4e7020000000001976a914d0115029aa5b2d2db7afb54a6c773ad536d0916c88ac90f4f70000000000' \
             '1976a914f0eabff37e597b930647a3ec5e9df2e0fed0ae9888ac108b1500'

    mock_wallet = MockObject()
    mock_wallet.transactions_update = lambda **_: None
    mock_wallet._session = MockObject()

    mock_all = MockObject()
    mock_all.all = lambda *_: [(raw_tx, 3, datetime.datetime(
        2012, 9, 16, 0, 0), 12345)]
    mock_filter = MockObject()
    mock_filter.filter = lambda *_: mock_all
    mock_wallet._session.query = lambda *_: mock_filter
    wallet.wallet = mock_wallet
    wallet.wallet.wallet_id = 3

    mock_key = MockObject()
    mock_key.address = 'n3Uogo82Tyy76ZNuxmFfhJiFqAUbJ5BPho'
    wallet.wallet.keys = lambda **_: [mock_key]
    wallet.created = True

    transactions = await wallet.get_transactions()
    assert transactions
    assert transactions[0]["fee_amount"] == 12345
    assert transactions[0]["amount"] == 16250000
Exemplo n.º 3
0
 def test_get_address_wallet(self):
     """
     Get Monero wallet address with wallet initialized.
     """
     w = self.new_wallet()
     mock_wallet = MockObject()
     mock_wallet.refresh = lambda: None
     mock_wallet.address = lambda: TEST_ADDRESS
     w.wallet = mock_wallet
     addr = w.get_address().result()
     self.assertEqual(TEST_ADDRESS, addr)
     w.cancel_all_pending_tasks()