[FEAT] Improve tests (#296)

* test cli arent async tests

* unused SERVER_ENDPOINT var

* async test werent marked async

* make test didnt use correct ports

* enable more verbose test logging

* refactor conftest variable

* not needed anymore are set in conftest

* using test_data now for conftest

* formatting

* comment out invalid hex

* remove test dir before creating it to be sure

* keep data from altest testrun and ad test_data to ignore

* ignore error for CI

* add duplicate env var

* fix confest

* Update pyproject.toml

* fix up tests

* short p2pk locktimes for faster tests

---------

Co-authored-by: callebtc <93376500+callebtc@users.noreply.github.com>
This commit is contained in:
dni ⚡
2023-08-06 18:35:34 +02:00
committed by GitHub
parent ca2b8e7bd6
commit 0a5beb75a2
11 changed files with 85 additions and 97 deletions

View File

@@ -16,14 +16,13 @@ def cli_prefix():
async def init_wallet():
wallet = await Wallet.with_db(
url=settings.mint_host,
db="data/test_cli_wallet",
db="test_data/test_cli_wallet",
name="wallet",
)
await wallet.load_proofs()
return wallet
@pytest.mark.asyncio
def test_info(cli_prefix):
runner = CliRunner()
result = runner.invoke(
@@ -37,7 +36,6 @@ def test_info(cli_prefix):
assert result.exit_code == 0
@pytest.mark.asyncio
def test_info_with_mint(cli_prefix):
runner = CliRunner()
result = runner.invoke(
@@ -51,7 +49,6 @@ def test_info_with_mint(cli_prefix):
assert result.exit_code == 0
@pytest.mark.asyncio
def test_info_with_mnemonic(cli_prefix):
runner = CliRunner()
result = runner.invoke(
@@ -65,7 +62,6 @@ def test_info_with_mnemonic(cli_prefix):
assert result.exit_code == 0
@pytest.mark.asyncio
def test_balance(cli_prefix):
runner = CliRunner()
result = runner.invoke(
@@ -80,7 +76,6 @@ def test_balance(cli_prefix):
assert result.exit_code == 0
@pytest.mark.asyncio
def test_invoice(mint, cli_prefix):
runner = CliRunner()
result = runner.invoke(
@@ -96,7 +91,6 @@ def test_invoice(mint, cli_prefix):
assert result.exit_code == 0
@pytest.mark.asyncio
def test_invoice_with_split(mint, cli_prefix):
runner = CliRunner()
result = runner.invoke(
@@ -108,7 +102,6 @@ def test_invoice_with_split(mint, cli_prefix):
# assert wallet.proof_amounts.count(1) >= 10
@pytest.mark.asyncio
def test_wallets(cli_prefix):
runner = CliRunner()
result = runner.invoke(
@@ -123,7 +116,6 @@ def test_wallets(cli_prefix):
assert result.exit_code == 0
@pytest.mark.asyncio
def test_send(mint, cli_prefix):
runner = CliRunner()
result = runner.invoke(
@@ -136,7 +128,6 @@ def test_send(mint, cli_prefix):
assert "cashuA" in result.output, "output does not have a token"
@pytest.mark.asyncio
def test_send_without_split(mint, cli_prefix):
runner = CliRunner()
result = runner.invoke(
@@ -149,7 +140,6 @@ def test_send_without_split(mint, cli_prefix):
assert "cashuA" in result.output, "output does not have a token"
@pytest.mark.asyncio
def test_send_without_split_but_wrong_amount(mint, cli_prefix):
runner = CliRunner()
result = runner.invoke(
@@ -159,7 +149,6 @@ def test_send_without_split_but_wrong_amount(mint, cli_prefix):
assert "No proof with this amount found" in str(result.exception)
@pytest.mark.asyncio
def test_receive_tokenv3(mint, cli_prefix):
runner = CliRunner()
token = (
@@ -181,10 +170,10 @@ def test_receive_tokenv3(mint, cli_prefix):
print(result.output)
@pytest.mark.asyncio
def test_receive_tokenv3_no_mint(mint, cli_prefix):
# this test works only if the previous test succeeds because we simulate the case where the mint URL is not in the token
# therefore, we need to know the mint keyset already and have the mint URL in the db
# this test works only if the previous test succeeds because we simulate the case
# where the mint URL is not in the token therefore, we need to know the mint keyset
# already and have the mint URL in the db
runner = CliRunner()
token = (
"cashuAeyJ0b2tlbiI6IFt7InByb29mcyI6IFt7ImlkIjogIjFjQ05JQVoyWC93MSIsICJhbW91bnQiOiAyLCAic2VjcmV0IjogIi1oM0ZXMFFoX1FYLW9ac1V2c0RuNlEiLC"
@@ -205,7 +194,6 @@ def test_receive_tokenv3_no_mint(mint, cli_prefix):
print(result.output)
@pytest.mark.asyncio
def test_receive_tokenv2(mint, cli_prefix):
runner = CliRunner()
token = (
@@ -223,7 +211,6 @@ def test_receive_tokenv2(mint, cli_prefix):
print(result.output)
@pytest.mark.asyncio
def test_receive_tokenv1(mint, cli_prefix):
runner = CliRunner()
token = (
@@ -240,7 +227,6 @@ def test_receive_tokenv1(mint, cli_prefix):
print(result.output)
@pytest.mark.asyncio()
def test_nostr_send(mint, cli_prefix):
runner = CliRunner()
result = runner.invoke(