Skip to content

Commit

Permalink
cleaner test
Browse files Browse the repository at this point in the history
  • Loading branch information
callebtc committed Jun 26, 2024
1 parent dea17dd commit 6d823b8
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions tests/test_wallet_subscription.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import pytest
import pytest_asyncio

from cashu.core.base import Method, ProofState
from cashu.core.base import Method, MintQuoteState, ProofState
from cashu.core.json_rpc.base import JSONRPCNotficationParams
from cashu.core.nuts import WEBSOCKETS_NUT
from cashu.core.settings import settings
Expand Down Expand Up @@ -61,10 +61,13 @@ def callback(msg: JSONRPCNotficationParams):
assert len(msg_stack) == 3

assert msg_stack[0].payload["paid"] is False
assert msg_stack[1].payload["state"] == MintQuoteState.unpaid.value

assert msg_stack[1].payload["paid"] is True
assert msg_stack[2].payload["state"] == MintQuoteState.paid.value

assert msg_stack[2].payload["paid"] is True
assert msg_stack[2].payload["state"] == MintQuoteState.issued.value


@pytest.mark.asyncio
Expand Down Expand Up @@ -103,16 +106,16 @@ def callback(msg: JSONRPCNotficationParams):
pending_stack = msg_stack[:n_subscriptions]
for msg in pending_stack:
proof_state = ProofState.parse_obj(msg.payload)
assert proof_state.state.value == "UNSPENT"
assert proof_state.state == ProofState.state.unspent

# the second one is the PENDING state
spent_stack = msg_stack[n_subscriptions : n_subscriptions * 2]
for msg in spent_stack:
proof_state = ProofState.parse_obj(msg.payload)
assert proof_state.state.value == "PENDING"
assert proof_state.state == ProofState.state.pending

# the third one is the SPENT state
spent_stack = msg_stack[n_subscriptions * 2 :]
for msg in spent_stack:
proof_state = ProofState.parse_obj(msg.payload)
assert proof_state.state.value == "SPENT"
assert proof_state.state == ProofState.state.spent

0 comments on commit 6d823b8

Please sign in to comment.