Add bad location tests

This commit is contained in:
Reckless_Satoshi
2024-04-29 23:35:52 +01:00
committed by Reckless_Satoshi
parent eec1bcb2b8
commit 33a01d2bff
4 changed files with 36 additions and 4 deletions

View File

@ -60,8 +60,9 @@ ONION_LOCATION = ''
# Geoblocked countries (will reject F2F trades).
# List of A3 country codes (see fhttps://en.wikipedia.org/wiki/ISO_3166-1_alpha-3)
# Example 'NOR,USA,CZE'
GEOBLOCKED_COUNTRIES = 'NOR,USA,CZE'
# Leave empty '' to allow all countries.
# Example 'NOR,USA,CZE'.
GEOBLOCKED_COUNTRIES = 'ABW,AFG,AGO'
# Link to robosats alternative site (shown in frontend in statsfornerds so users can switch mainnet/testnet)
ALTERNATIVE_SITE = 'RoboSats6tkf3eva7x2voqso3a5wcorsnw34jveyxfqi2fu7oyheasid.onion'

View File

@ -145,7 +145,6 @@ class Logics:
return True, None
country = location_country(order.longitude, order.latitude)
print(country, "COUNTRYYY")
if country in GEOBLOCKED_COUNTRIES:
return False, {
"bad_request": f"The coordinator does not support orders in {country}"

View File

@ -239,6 +239,38 @@ class TradeTest(BaseAPITestCase):
self.assertIsNone(data["taker"], "New order's taker is not null")
self.assert_order_logs(data["id"])
def test_make_order_on_blocked_country(self):
"""
Test the creation of an F2F order on a geoblocked location
"""
trade = Trade(
self.client,
# latitude and longitud in Aruba. One of the countries blocked in the example conf.
maker_form={
"type": 0,
"currency": 1,
"has_range": True,
"min_amount": 21,
"max_amount": 101.7,
"payment_method": "Advcash Cash F2F",
"is_explicit": False,
"premium": 3.34,
"public_duration": 69360,
"escrow_duration": 8700,
"bond_size": 3.5,
"latitude": -11.8014, # Angola AGO
"longitude": 17.3575,
},
) # init of Trade calls make_order() with the default maker form.
data = trade.response.json()
self.assertEqual(trade.response.status_code, 400)
self.assertResponse(trade.response)
self.assertEqual(
data["bad_request"], "The coordinator does not support orders in AGO"
)
def test_get_order_created(self):
"""
Tests the creation of an order and the first request to see details,

View File

@ -98,8 +98,8 @@ class Trade:
response = self.client.post(path, maker_form, **headers)
self.response = response
if response.status_code == 201:
self.response = response
self.order_id = response.json()["id"]
def get_order(self, robot_index=1, first_encounter=False):