diff --git a/tests/technical/test_documents_service.py b/tests/technical/test_documents_service.py index 4ecdda858d9fc33a48adfc27715d88c72b3ff333..9ec0a14a12ea2cdd22ab9576e5287e6d816a1eb8 100644 --- a/tests/technical/test_documents_service.py +++ b/tests/technical/test_documents_service.py @@ -43,6 +43,7 @@ async def test_send_more_than_40_sources( amount_before_send, 0, "Test comment", + 0, ) assert transactions[0].comment == "[CHAINED]" assert transactions[1].comment == "Test comment" diff --git a/tests/technical/test_sources_service.py b/tests/technical/test_sources_service.py index 2cc8c698fc218beb25d6a17eb98738a252b7f425..9cb1d21c642f6b0c2088e9ac8ceb77db107fc365 100644 --- a/tests/technical/test_sources_service.py +++ b/tests/technical/test_sources_service.py @@ -83,7 +83,7 @@ async def test_send_tx_then_cancel( ) fake_server_with_blockchain.reject_next_post = True await application_with_one_connection.documents_service.send_money( - bob_connection, bob.salt, bob.password, alice.key.pubkey, 10, 0, "Test comment" + bob_connection, bob.salt, bob.password, alice.key.pubkey, 10, 0, None, 0 ) tx_after_send = application_with_one_connection.transactions_service.transfers( bob.key.pubkey diff --git a/tests/technical/test_transactions_service.py b/tests/technical/test_transactions_service.py index b6b073dffe6d5db3a278a15f0352a0ed6acca160..944f3477e136476cd9f26bcda61ba87a42cb426e 100644 --- a/tests/technical/test_transactions_service.py +++ b/tests/technical/test_transactions_service.py @@ -18,7 +18,7 @@ async def test_send_tx_then_validate( pubkey=bob.key.pubkey ) await application_with_one_connection.documents_service.send_money( - bob_connection, bob.salt, bob.password, alice.key.pubkey, 10, 0, "Test comment" + bob_connection, bob.salt, bob.password, alice.key.pubkey, 10, 0, None, 0 ) tx_after_send = application_with_one_connection.transactions_service.transfers( bob.key.pubkey diff --git a/tests/unit/services/test_documents.py b/tests/unit/services/test_documents.py new file mode 100644 index 0000000000000000000000000000000000000000..00084fa94b0ad7d2ce2106ba88303aff979742ec --- /dev/null +++ b/tests/unit/services/test_documents.py @@ -0,0 +1,71 @@ +import pytest + + +@pytest.mark.asyncio +async def test_lock_mode_0(application_with_one_connection, fake_server, bob, alice): + """ + Test the lock mode 0, Receiver signature + + :param application_with_one_connection: + :param fake_server: + :param bob: + :param alice: + :return: + """ + # check money amount in bob account + amount = application_with_one_connection.sources_service.amount(bob.key.pubkey) + assert amount == 1584 + + # create connection to have sources... + bob_connection = application_with_one_connection.db.connections_repo.get_one( + pubkey=bob.key.pubkey + ) + + # send transaction + ( + _, + sakia_tx_list, + ) = await application_with_one_connection.documents_service.send_money( + bob_connection, bob.salt, bob.password, alice.key.pubkey, 100, 0, None, 0 + ) + + assert len(sakia_tx_list) == 1 + assert ( + "Outputs:\n100:0:SIG(F3HWkYnUSbdpEueosKqzYd1m8ftwojwE2uXR7ScoAVKo)\n" + in sakia_tx_list[0].raw + ) + + +@pytest.mark.asyncio +async def test_lock_mode_1(application_with_one_connection, fake_server, bob, alice): + """ + Test the lock mode 0, Receiver signature OR (Sender signature AND CSV(one week delay)) + + :param application_with_one_connection: + :param fake_server: + :param bob: + :param alice: + :return: + """ + # check money amount in bob account + amount = application_with_one_connection.sources_service.amount(bob.key.pubkey) + assert amount == 1584 + + # create connection to have sources... + bob_connection = application_with_one_connection.db.connections_repo.get_one( + pubkey=bob.key.pubkey + ) + + # send transaction + ( + _, + sakia_tx_list, + ) = await application_with_one_connection.documents_service.send_money( + bob_connection, bob.salt, bob.password, alice.key.pubkey, 100, 0, None, 1 + ) + + assert len(sakia_tx_list) == 1 + assert ( + "Outputs:\n100:0:SIG(F3HWkYnUSbdpEueosKqzYd1m8ftwojwE2uXR7ScoAVKo) || (SIG(GfFUvqaVSgCt6nFDQCAuULWk6K16MUDckeyBJQFcaYj7) && CSV(604800))\n" + in sakia_tx_list[0].raw + )