def test_normalize_transaction_outgoing_payment(self): """ Verify monero.transaction.Transaction instances are correctly formatted. """ w = self.new_wallet() payment = OutgoingPayment() payment.local_address = TEST_ADDRESS payment.amount = 11.8 timestamp = datetime.now() mock_transaction = MockObject() mock_transaction.hash = TEST_HASH mock_transaction.fee = 0.3 ts = mktime(timestamp.timetuple()) mock_transaction.timestamp = timestamp mock_transaction.confirmations = 23 payment.transaction = mock_transaction self.assertDictEqual({ 'id': TEST_HASH, 'outgoing': True, 'from': TEST_ADDRESS, 'to': '', 'amount': 11.8, 'fee_amount': 0.3, 'currency': self.identifier, 'timestamp': ts, 'description': 'Confirmations: 23' }, w._normalize_transaction(payment)) w.cancel_all_pending_tasks()
async def test_get_confirmations_wallet(self): """ Verify number of confirmations returned in case wallet does exist. """ w = self.new_wallet() self.assertIsNone(w.wallet) succeed_backend() await w.create_wallet() self.assertIsNotNone(w.wallet) mock_wallet = MockObject() mock_wallet.refresh = lambda *_: None mock_wallet.confirmations = lambda *_: 4 w.wallet = mock_wallet p = Payment() self.assertEqual(4, await w.get_confirmations(p)) w.cancel_all_pending_tasks()