|
|
|
@ -1,6 +1,7 @@
|
|
|
|
|
from datetime import datetime
|
|
|
|
|
from decimal import Decimal
|
|
|
|
|
import responses
|
|
|
|
|
import requests
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
from unittest.mock import patch, Mock
|
|
|
|
@ -50,7 +51,7 @@ class JSONRPCWalletTestCase(JSONTestCase):
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@patch("monero.backends.jsonrpc.wallet.requests.post")
|
|
|
|
|
@patch.object(requests.Session, "post")
|
|
|
|
|
def test_seed(self, mock_post):
|
|
|
|
|
mock_post.return_value.status_code = 200
|
|
|
|
|
mock_post.return_value.json.return_value = self.accounts_result
|
|
|
|
@ -70,7 +71,7 @@ class JSONRPCWalletTestCase(JSONTestCase):
|
|
|
|
|
self.assertIsInstance(seed, Seed)
|
|
|
|
|
self.assertEqual(seed.phrase, phrase)
|
|
|
|
|
|
|
|
|
|
@patch("monero.backends.jsonrpc.wallet.requests.post")
|
|
|
|
|
@patch.object(requests.Session, "post")
|
|
|
|
|
def test_balance(self, mock_post):
|
|
|
|
|
mock_post.return_value.status_code = 200
|
|
|
|
|
mock_post.return_value.json.return_value = self.accounts_result
|
|
|
|
@ -219,7 +220,7 @@ class JSONRPCWalletTestCase(JSONTestCase):
|
|
|
|
|
self.assertIsInstance(subaddr, SubAddress)
|
|
|
|
|
self.assertIsInstance(index, int)
|
|
|
|
|
|
|
|
|
|
@patch("monero.backends.jsonrpc.wallet.requests.post")
|
|
|
|
|
@patch.object(requests.Session, "post")
|
|
|
|
|
def test_incoming_confirmed(self, mock_post):
|
|
|
|
|
mock_post.return_value.status_code = 200
|
|
|
|
|
mock_post.return_value.json.return_value = self.accounts_result
|
|
|
|
@ -369,7 +370,7 @@ class JSONRPCWalletTestCase(JSONTestCase):
|
|
|
|
|
self.assertIsInstance(pmt.transaction.fee, Decimal)
|
|
|
|
|
self.assertIsInstance(pmt.transaction.height, int)
|
|
|
|
|
|
|
|
|
|
@patch("monero.backends.jsonrpc.wallet.requests.post")
|
|
|
|
|
@patch.object(requests.Session, "post")
|
|
|
|
|
def test_incoming_confirmed_and_unconfirmed(self, mock_post):
|
|
|
|
|
mock_post.return_value.status_code = 200
|
|
|
|
|
mock_post.return_value.json.return_value = self.accounts_result
|
|
|
|
@ -549,7 +550,7 @@ class JSONRPCWalletTestCase(JSONTestCase):
|
|
|
|
|
self.assertIsInstance(pmt.transaction.fee, Decimal)
|
|
|
|
|
self.assertIsInstance(pmt.transaction.height, (int, type(None)))
|
|
|
|
|
|
|
|
|
|
@patch("monero.backends.jsonrpc.wallet.requests.post")
|
|
|
|
|
@patch.object(requests.Session, "post")
|
|
|
|
|
def test_incoming_unconfirmed(self, mock_post):
|
|
|
|
|
mock_post.return_value.status_code = 200
|
|
|
|
|
mock_post.return_value.json.return_value = self.accounts_result
|
|
|
|
@ -851,7 +852,7 @@ class JSONRPCWalletTestCase(JSONTestCase):
|
|
|
|
|
self.assertEqual(pmts[0].amount, Decimal("0.52"))
|
|
|
|
|
self.assertEqual(pmts[1].amount, Decimal("0.0212"))
|
|
|
|
|
|
|
|
|
|
@patch("monero.backends.jsonrpc.wallet.requests.post")
|
|
|
|
|
@patch.object(requests.Session, "post")
|
|
|
|
|
def test_incoming_by_payment_ids(self, mock_post):
|
|
|
|
|
# These queries will use get_bulk_payments RPC method instead of get_transfers
|
|
|
|
|
mock_post.return_value.status_code = 200
|
|
|
|
@ -962,7 +963,7 @@ class JSONRPCWalletTestCase(JSONTestCase):
|
|
|
|
|
self.assertIsInstance(pmt.transaction.height, int)
|
|
|
|
|
self.assertIn(pmt.payment_id, ids)
|
|
|
|
|
|
|
|
|
|
@patch("monero.backends.jsonrpc.wallet.requests.post")
|
|
|
|
|
@patch.object(requests.Session, "post")
|
|
|
|
|
def test_outgoing(self, mock_post):
|
|
|
|
|
mock_post.return_value.status_code = 200
|
|
|
|
|
mock_post.return_value.json.return_value = self.accounts_result
|
|
|
|
@ -1189,7 +1190,7 @@ class JSONRPCWalletTestCase(JSONTestCase):
|
|
|
|
|
self.assertIsInstance(pmt.transaction.fee, Decimal)
|
|
|
|
|
self.assertIsInstance(pmt.transaction.height, int)
|
|
|
|
|
|
|
|
|
|
@patch("monero.backends.jsonrpc.wallet.requests.post")
|
|
|
|
|
@patch.object(requests.Session, "post")
|
|
|
|
|
def test_outgoing_confirmed_and_unconfirmed(self, mock_post):
|
|
|
|
|
mock_post.return_value.status_code = 200
|
|
|
|
|
mock_post.return_value.json.return_value = self.accounts_result
|
|
|
|
@ -1432,7 +1433,7 @@ class JSONRPCWalletTestCase(JSONTestCase):
|
|
|
|
|
self.assertIsInstance(pmt.transaction.fee, Decimal)
|
|
|
|
|
self.assertIsInstance(pmt.transaction.height, (int, type(None)))
|
|
|
|
|
|
|
|
|
|
@patch("monero.backends.jsonrpc.wallet.requests.post")
|
|
|
|
|
@patch.object(requests.Session, "post")
|
|
|
|
|
def test_outgoing_unconfirmed_only(self, mock_post):
|
|
|
|
|
mock_post.return_value.status_code = 200
|
|
|
|
|
mock_post.return_value.json.return_value = self.accounts_result
|
|
|
|
@ -1493,7 +1494,7 @@ class JSONRPCWalletTestCase(JSONTestCase):
|
|
|
|
|
self.assertEqual(len(pmt.destinations), 2)
|
|
|
|
|
self.assertEqual(pmt.destinations[0][1] + pmt.destinations[1][1], pmt.amount)
|
|
|
|
|
|
|
|
|
|
@patch("monero.backends.jsonrpc.wallet.requests.post")
|
|
|
|
|
@patch.object(requests.Session, "post")
|
|
|
|
|
def test_send_transfer(self, mock_post):
|
|
|
|
|
mock_post.return_value.status_code = 200
|
|
|
|
|
mock_post.return_value.json.return_value = self.accounts_result
|
|
|
|
@ -1562,7 +1563,7 @@ class JSONRPCWalletTestCase(JSONTestCase):
|
|
|
|
|
self.assertIsInstance(result[0], Transaction)
|
|
|
|
|
self.assertEqual(Decimal("111.086545699972"), result[1])
|
|
|
|
|
|
|
|
|
|
@patch("monero.backends.jsonrpc.wallet.requests.post")
|
|
|
|
|
@patch.object(requests.Session, "post")
|
|
|
|
|
def test_dynamic_ring_size_deprecation(self, mock_post):
|
|
|
|
|
mock_post.return_value.status_code = 200
|
|
|
|
|
mock_post.return_value.json.return_value = self.accounts_result
|
|
|
|
@ -1587,7 +1588,7 @@ class JSONRPCWalletTestCase(JSONTestCase):
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@patch("monero.backends.jsonrpc.wallet.requests.post")
|
|
|
|
|
@patch.object(requests.Session, "post")
|
|
|
|
|
def test_export_import_outputs(self, mock_post):
|
|
|
|
|
mock_post.return_value.status_code = 200
|
|
|
|
|
mock_post.return_value.json.return_value = self.accounts_result
|
|
|
|
@ -1608,7 +1609,7 @@ class JSONRPCWalletTestCase(JSONTestCase):
|
|
|
|
|
}
|
|
|
|
|
self.assertEqual(self.wallet.import_outputs(outs_hex), 9)
|
|
|
|
|
|
|
|
|
|
@patch("monero.backends.jsonrpc.wallet.requests.post")
|
|
|
|
|
@patch.object(requests.Session, "post")
|
|
|
|
|
def test_export_import_key_images(self, mock_post):
|
|
|
|
|
mock_post.return_value.status_code = 200
|
|
|
|
|
mock_post.return_value.json.return_value = self.accounts_result
|
|
|
|
|