diff --git a/Makefile b/Makefile index 9c9ddc36..6e5d0b47 100644 --- a/Makefile +++ b/Makefile @@ -11,10 +11,10 @@ black-check: poetry run black . --exclude cashu/nostr --check mypy: - poetry run mypy cashu --ignore-missing + poetry run mypy cashu tests --ignore-missing flake8: - poetry run flake8 cashu + poetry run flake8 cashu tests format: isort black diff --git a/tests/test_core.py b/tests/test_core.py index 103dd2da..89fbd866 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -32,7 +32,18 @@ def test_tokenv3_get_proofs(): def test_tokenv3_deserialize_serialize_with_dleq(): - token_str = "cashuAeyJ0b2tlbiI6IFt7InByb29mcyI6IFt7ImlkIjogIjI4ajhueVNMMU5kZCIsICJhbW91bnQiOiAyLCAic2VjcmV0IjogInFvS01lMGk1LVgyQy0zc29mVUZUb0EiLCAiQyI6ICIwMmIzYWVlMjAxZDRmYzlhODJkYTJiZTVmOTQzODlmOWIxMzg4YzBkMDA3N2M2ODg1MDhjODIzZmU4OTMwY2YwYzYiLCAiZGxlcSI6IHsiZSI6ICJjMmJkNTMzMTkyZDI2MzExMzM2MjU1OTUxZmQyZTI2OWEwY2E2ODViMzgxMDcwYTFhMzRiMDViYjVlYTBkNTAzIiwgInMiOiAiNzUxOTc5MDczZjk3YjcyMmYzNzJkMzRjZDhlNmY5MWRlYzA0ODE4MTg5NjI3YjYwZWFmYjZjMTY3MjFiZjVmOCIsICJCXyI6ICIwMjVhZjliM2ViNmFkZjgxN2M0YzBjMzhhYWYwZjNhYmJjY2MxODFhY2VmMmNjZTQ4Mzg3MWIwYzEyM2UwOTI1NDgiLCAiQ18iOiAiMDNlMDA2YTRiNGI1ODNlMzI5NTNmYzFmMWI4MmQyZTE1MmQyMjdlYTFhZTgyZTEyOWNiYzc3OWQ5NzYwMTc1Mzg4In19LCB7ImlkIjogIjI4ajhueVNMMU5kZCIsICJhbW91bnQiOiA4LCAic2VjcmV0IjogIk1TcEdMMG9Qc3cyU2dFOTdvNmh3emciLCAiQyI6ICIwM2Ey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ZjNhYmJjY2MxODFhY2VmMmNjZTQ4Mzg3MWIwYzE" + "yM2UwOTI1NDgiLCAiQ18iOiAiMDNlMDA2YTRiNGI1ODNlMzI5NTNmYzFmMWI4MmQyZTE1MmQyMjdlYTFhZTgyZTEyOWNiYzc3OWQ5NzYwMTc1Mzg4In19LCB7ImlkIjogIjI4" + "ajhueVNMMU5kZCIsICJhbW91bnQiOiA4LCAic2VjcmV0IjogIk1TcEdMMG9Qc3cyU2dFOTdvNmh3emciLCAiQyI6ICIwM2EyYjJmMTBjOGI2MjQ0ODRhYmNmYTc3MzUwYjhiN" + "WU1NDAwZWFhYmQxNjA0ZTRjYjliYWQyNjJkZmFhOThmYTgiLCAiZGxlcSI6IHsiZSI6ICJkODI0YzRjNGExNTBmZTQxM2JjM2YzOGNkMGE2NjAxZDU1NWVhYzhjOTNmNDMyOT" + "c0NzQxMGEwOGMzZmYyNTg4IiwgInMiOiAiMjZkZjdhZTk4NzdjN2YyZTE2N2FkZGI4MWRkYjFlNjg1NTE5NmY1NDE3ZDI3MDFiYTdkZmM0NDlkNjYwNTQyZiIsICJCXyI6ICI" + "wMmJlNzQ0NzllOTM0NWU3NWRhNWUzYzliYzcxYjBhMTZlNzZhNDJkMDVjMDA3M2ZjYjgzZmNlYTg3YWJmZGFhYTciLCAiQ18iOiAiMDNkYjA3MjdjYWNjMTQwYTljMzg0YjQx" + "ZjJhMjUyYTg3ODI5YWZhMWU4OWJjZTFlMGY4YWQyMGJkNGQ5Zjc4YjgyIn19XSwgIm1pbnQiOiAiaHR0cDovL2xvY2FsaG9zdDozMzM4In1dfQ==" + ) token = TokenV3.deserialize(token_str) assert token.serialize(include_dleq=True) == token_str @@ -49,8 +60,26 @@ def test_tokenv3_deserialize_serialize(): def test_tokenv3_deserialize_serialize_no_dleq(): - token_str = "cashuAeyJ0b2tlbiI6IFt7InByb29mcyI6IFt7ImlkIjogIjI4ajhueVNMMU5kZCIsICJhbW91bnQiOiAyLCAic2VjcmV0IjogInFvS01lM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29mVUZUb0EiLCAiQyI6ICIwMmIzYWVlMjAxZDRmYzlhODJkYTJiZTVmOTQzODlmOWIxMzg4YzBkMDA3N2M2ODg1MDhjODIzZmU" + "4OTMwY2YwYzYifSwgeyJpZCI6ICIyOGo4bnlTTDFOZGQiLCAiYW1vdW50IjogOCwgInNlY3JldCI6ICJNU3BHTDBvUHN3MlNnRTk3bzZod3pn" + "IiwgIkMiOiAiMDNhMmIyZjEwYzhiNjI0NDg0YWJjZmE3NzM1MGI4YjVlNTQwMGVhYWJkMTYwNGU0Y2I5YmFkMjYyZGZhYTk4ZmE4In1dLCAib" + "WludCI6ICJodHRwOi8vbG9jYWxob3N0OjMzMzgifV19" + ) token = TokenV3.deserialize(token_str) assert token.serialize(include_dleq=False) == token_str_no_dleq