tests: Switch CI tests.

This commit is contained in:
tecnovert 2025-01-15 15:06:34 +02:00
parent def7aae1ec
commit 3b60472c04
No known key found for this signature in database
GPG key ID: 8ED6D8750C4E3F93
3 changed files with 112 additions and 111 deletions

View file

@ -59,7 +59,7 @@ jobs:
export PARTICL_BINDIR="$BIN_DIR/particl"; export PARTICL_BINDIR="$BIN_DIR/particl";
export BITCOIN_BINDIR="$BIN_DIR/bitcoin"; export BITCOIN_BINDIR="$BIN_DIR/bitcoin";
export XMR_BINDIR="$BIN_DIR/monero"; export XMR_BINDIR="$BIN_DIR/monero";
pytest tests/basicswap/test_xmr.py::Test -k "test_003_api or test_02_leader_recover_a_lock_tx" pytest tests/basicswap/test_btc_xmr.py::TestBTC -k "test_003_api or test_02_a_leader_recover_a_lock_tx"
- name: Running test_encrypted_xmr_reload - name: Running test_encrypted_xmr_reload
run: | run: |
export PYTHONPATH=$(pwd) export PYTHONPATH=$(pwd)

View file

@ -1849,6 +1849,117 @@ class TestBTC(BasicSwapTest):
start_ltc_nodes = False start_ltc_nodes = False
base_rpc_port = BTC_BASE_RPC_PORT base_rpc_port = BTC_BASE_RPC_PORT
def test_003_api(self):
logging.info("---------- Test API")
help_output = read_json_api(1800, "help")
assert "getcoinseed" in help_output["commands"]
rv = read_json_api(1800, "getcoinseed")
assert rv["error"] == "No post data"
rv = read_json_api(1800, "getcoinseed", {"coin": "PART"})
assert "seed is set from the Basicswap mnemonic" in rv["error"]
rv = read_json_api(1800, "getcoinseed", {"coin": "BTC"})
assert (
rv["seed"]
== "8e54a313e6df8918df6d758fafdbf127a115175fdd2238d0e908dd8093c9ac3b"
)
assert rv["seed_id"] == "3da5c0af91879e8ce97d9a843874601c08688078"
assert rv["seed_id"] == rv["expected_seed_id"]
rv = read_json_api(
1800,
"identities/ppCsRro5po7Yu6kyu5XjSyr3A1PPdk9j1F",
{"set_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 isinstance(rv, dict)
assert rv["address"] == "ppCsRro5po7Yu6kyu5XjSyr3A1PPdk9j1F"
assert rv["label"] == "test 2"
rv = read_json_api(
1800,
"identities/pPCsRro5po7Yu6kyu5XjSyr3A1PPdk9j1F",
{"set_label": "test 3"},
)
assert rv["error"] == "Invalid identity address"
rv = read_json_api(
1800,
"identities/ppCsRro5po7Yu6kyu5XjSyr3A1PPdk9j1F",
{"set_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 isinstance(rv, dict)
assert rv["automation_override"] == 1
rv = read_json_api(
1800,
"identities/ppCsRro5po7Yu6kyu5XjSyr3A1PPdk9j1F",
{"set_visibility_override": "hide"},
)
assert isinstance(rv, dict)
assert rv["visibility_override"] == 1
rv = read_json_api(1800, "automationstrategies")
assert len(rv) == 2
rv = read_json_api(1800, "automationstrategies/1")
assert rv["label"] == "Accept All"
sx_addr = read_json_api(1800, "wallets/part/newstealthaddress")
assert (
callnoderpc(
0,
"getaddressinfo",
[
sx_addr,
],
)["isstealthaddress"]
is True
)
rv = read_json_api(1800, "wallets/part")
assert "locked_utxos" in rv
rv = read_json_api(
1800, "validateamount", {"coin": "part", "amount": 0.000000015}
)
assert "Mantissa too long" in rv["error"]
rv = read_json_api(
1800,
"validateamount",
{"coin": "part", "amount": 0.000000015, "method": "roundoff"},
)
assert rv == "0.00000002"
rv = read_json_api(
1800,
"validateamount",
{"coin": "part", "amount": 0.000000015, "method": "rounddown"},
)
assert rv == "0.00000001"
def test_009_wallet_encryption(self): def test_009_wallet_encryption(self):
for coin in ("btc", "part", "xmr"): for coin in ("btc", "part", "xmr"):

View file

@ -1063,116 +1063,6 @@ class Test(BaseTest):
def notest_00_delay(self): def notest_00_delay(self):
test_delay_event.wait(100000) test_delay_event.wait(100000)
def test_003_api(self):
logging.info("---------- Test API")
help_output = read_json_api(1800, "help")
assert "getcoinseed" in help_output["commands"]
rv = read_json_api(1800, "getcoinseed")
assert rv["error"] == "No post data"
rv = read_json_api(1800, "getcoinseed", {"coin": "PART"})
assert "seed is set from the Basicswap mnemonic" in rv["error"]
rv = read_json_api(1800, "getcoinseed", {"coin": "BTC"})
assert (
rv["seed"]
== "8e54a313e6df8918df6d758fafdbf127a115175fdd2238d0e908dd8093c9ac3b"
)
assert rv["seed_id"] == "3da5c0af91879e8ce97d9a843874601c08688078"
assert rv["seed_id"] == rv["expected_seed_id"]
rv = read_json_api(
1800,
"identities/ppCsRro5po7Yu6kyu5XjSyr3A1PPdk9j1F",
{"set_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 isinstance(rv, dict)
assert rv["address"] == "ppCsRro5po7Yu6kyu5XjSyr3A1PPdk9j1F"
assert rv["label"] == "test 2"
rv = read_json_api(
1800,
"identities/pPCsRro5po7Yu6kyu5XjSyr3A1PPdk9j1F",
{"set_label": "test 3"},
)
assert rv["error"] == "Invalid identity address"
rv = read_json_api(
1800,
"identities/ppCsRro5po7Yu6kyu5XjSyr3A1PPdk9j1F",
{"set_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 isinstance(rv, dict)
assert rv["automation_override"] == 1
rv = read_json_api(
1800,
"identities/ppCsRro5po7Yu6kyu5XjSyr3A1PPdk9j1F",
{"set_visibility_override": "hide"},
)
assert isinstance(rv, dict)
assert rv["visibility_override"] == 1
rv = read_json_api(1800, "automationstrategies")
assert len(rv) == 2
rv = read_json_api(1800, "automationstrategies/1")
assert rv["label"] == "Accept All"
sx_addr = read_json_api(1800, "wallets/part/newstealthaddress")
assert (
callnoderpc(
0,
"getaddressinfo",
[
sx_addr,
],
)["isstealthaddress"]
is True
)
rv = read_json_api(1800, "wallets/part")
assert "locked_utxos" in rv
rv = read_json_api(
1800, "validateamount", {"coin": "part", "amount": 0.000000015}
)
assert "Mantissa too long" in rv["error"]
rv = read_json_api(
1800,
"validateamount",
{"coin": "part", "amount": 0.000000015, "method": "roundoff"},
)
assert rv == "0.00000002"
rv = read_json_api(
1800,
"validateamount",
{"coin": "part", "amount": 0.000000015, "method": "rounddown"},
)
assert rv == "0.00000001"
def test_010_txn_size(self): def test_010_txn_size(self):
logging.info("---------- Test {} txn_size".format(Coins.PART)) logging.info("---------- Test {} txn_size".format(Coins.PART))