diff --git a/basicswap/js_server.py b/basicswap/js_server.py index 0e06431..16ca1c3 100644 --- a/basicswap/js_server.py +++ b/basicswap/js_server.py @@ -707,7 +707,10 @@ def js_identities(self, url_split, post_string: str, is_json: bool) -> bytes: ensure("address" in filters, "Must provide an address to modify data") swap_client.setIdentityData(filters, set_data) - return bytes(json.dumps(swap_client.listIdentities(filters)), "UTF-8") + rv = swap_client.listIdentities(filters) + if "address" in filters: + rv = {} if len(rv) < 1 else rv[0] + return bytes(json.dumps(rv), "UTF-8") def js_automationstrategies(self, url_split, post_string: str, is_json: bool) -> bytes: diff --git a/tests/basicswap/test_run.py b/tests/basicswap/test_run.py index c09f2b5..ae2ecd3 100644 --- a/tests/basicswap/test_run.py +++ b/tests/basicswap/test_run.py @@ -186,17 +186,17 @@ class Test(BaseTest): "identities/ppCsRro5po7Yu6kyu5XjSyr3A1PPdk9j1F", {"set_label": "test 1"}, ) - assert len(rv) == 1 - assert rv[0]["address"] == "ppCsRro5po7Yu6kyu5XjSyr3A1PPdk9j1F" - assert rv[0]["label"] == "test 1" + assert isinstance(rv, dict) + assert rv["address"] == "ppCsRro5po7Yu6kyu5XjSyr3A1PPdk9j1F" + assert rv["label"] == "test 1" rv = read_json_api( 1800, "identities/ppCsRro5po7Yu6kyu5XjSyr3A1PPdk9j1F", {"set_label": "test 2"}, ) - assert len(rv) == 1 - assert rv[0]["address"] == "ppCsRro5po7Yu6kyu5XjSyr3A1PPdk9j1F" - assert rv[0]["label"] == "test 2" + assert isinstance(rv, dict) + assert rv["address"] == "ppCsRro5po7Yu6kyu5XjSyr3A1PPdk9j1F" + assert rv["label"] == "test 2" rv = read_json_api( 1800, @@ -210,26 +210,26 @@ class Test(BaseTest): "identities/ppCsRro5po7Yu6kyu5XjSyr3A1PPdk9j1F", {"set_note": "note 1"}, ) - assert len(rv) == 1 - assert rv[0]["address"] == "ppCsRro5po7Yu6kyu5XjSyr3A1PPdk9j1F" - assert rv[0]["label"] == "test 2" - assert rv[0]["note"] == "note 1" + assert isinstance(rv, dict) + assert rv["address"] == "ppCsRro5po7Yu6kyu5XjSyr3A1PPdk9j1F" + assert rv["label"] == "test 2" + assert rv["note"] == "note 1" rv = read_json_api( 1800, "identities/ppCsRro5po7Yu6kyu5XjSyr3A1PPdk9j1F", {"set_automation_override": 1}, ) - assert len(rv) == 1 - assert rv[0]["automation_override"] == 1 + assert isinstance(rv, dict) + assert rv["automation_override"] == 1 rv = read_json_api( 1800, "identities/ppCsRro5po7Yu6kyu5XjSyr3A1PPdk9j1F", {"set_visibility_override": "hide"}, ) - assert len(rv) == 1 - assert rv[0]["visibility_override"] == 1 + assert isinstance(rv, dict) + assert rv["visibility_override"] == 1 rv = read_json_api(1800, "automationstrategies") assert len(rv) == 2