From 5f6edabf42373d4c3664399f5dcd9b6c4122e355 Mon Sep 17 00:00:00 2001 From: ArtObr Date: Wed, 10 Jul 2019 12:24:03 +0300 Subject: [PATCH] Review fixes Signed-off-by: ArtObr --- .../sovtokenfees/test/transactions/helper.py | 5 ++++ .../transactions/test_attrib_with_fees.py | 10 ++++++- .../transactions/test_claim_def_with_fees.py | 13 ++++++++-- .../test/transactions/test_nym_with_fees.py | 10 ++++++- .../test_revoc_reg_def_with_fees.py | 26 +++++++++++++------ .../test_revoc_reg_entry_with_fees.py | 11 +++++++- .../transactions/test_schema_with_fees.py | 10 ++++++- 7 files changed, 71 insertions(+), 14 deletions(-) create mode 100644 sovtokenfees/sovtokenfees/test/transactions/helper.py diff --git a/sovtokenfees/sovtokenfees/test/transactions/helper.py b/sovtokenfees/sovtokenfees/test/transactions/helper.py new file mode 100644 index 00000000..32cbc7a1 --- /dev/null +++ b/sovtokenfees/sovtokenfees/test/transactions/helper.py @@ -0,0 +1,5 @@ +from collections import deque + + +def get_last_token_txn(nodeSet): + return deque(nodeSet[0].ledgers[-1].getAllTxn()).pop() diff --git a/sovtokenfees/sovtokenfees/test/transactions/test_attrib_with_fees.py b/sovtokenfees/sovtokenfees/test/transactions/test_attrib_with_fees.py index 11fd367c..94a18387 100644 --- a/sovtokenfees/sovtokenfees/test/transactions/test_attrib_with_fees.py +++ b/sovtokenfees/sovtokenfees/test/transactions/test_attrib_with_fees.py @@ -7,15 +7,18 @@ from sovtoken.test.helpers.helper_general import utxo_from_addr_and_seq_no from sovtokenfees.test.constants import ATTRIB_FEES_ALIAS from sovtokenfees.test.helper import get_amount_from_token_txn, add_fees_request_with_address +from sovtokenfees.test.transactions.helper import get_last_token_txn from plenum.common.constants import DATA from plenum.test.helper import sdk_sign_and_submit_req, \ sdk_get_and_check_replies +ATTRIB_FEE = 2 + @pytest.fixture() def fees(): - return {ATTRIB_FEES_ALIAS: 5} + return {ATTRIB_FEES_ALIAS: ATTRIB_FEE} def test_send_attrib_with_fees(helpers, @@ -38,7 +41,12 @@ def test_send_attrib_with_fees(helpers, address_main, utxos=utxos ) + + token_len = len(nodeSetWithIntegratedTokenPlugin[0].ledgers[-1]) helpers.sdk.send_and_check_request_objects([req], wallet=sdk_wallet_trustee) + assert token_len == len(nodeSetWithIntegratedTokenPlugin[0].ledgers[-1]) - 1 + assert get_last_token_txn(nodeSetWithIntegratedTokenPlugin)[1]['txn']['data']['fees'] == ATTRIB_FEE + request = looper.loop.run_until_complete( build_get_attrib_request(sdk_wallet_trustee[1], sdk_wallet_trustee[1], 'answer', None, None)) diff --git a/sovtokenfees/sovtokenfees/test/transactions/test_claim_def_with_fees.py b/sovtokenfees/sovtokenfees/test/transactions/test_claim_def_with_fees.py index fd2384b6..e434d2ad 100644 --- a/sovtokenfees/sovtokenfees/test/transactions/test_claim_def_with_fees.py +++ b/sovtokenfees/sovtokenfees/test/transactions/test_claim_def_with_fees.py @@ -8,15 +8,18 @@ from sovtokenfees.test.helper import get_amount_from_token_txn, add_fees_request_with_address from indy_common.types import Request +from sovtokenfees.test.transactions.helper import get_last_token_txn from plenum.common.constants import TXN_METADATA, TXN_METADATA_ID, DATA from plenum.test.helper import sdk_sign_and_submit_req, \ sdk_get_and_check_replies +CLAIM_DEF_FEE = 4 + @pytest.fixture() def fees(): - return {CLAIM_DEF_FEES_ALIAS: 5} + return {CLAIM_DEF_FEES_ALIAS: CLAIM_DEF_FEE} def test_send_claim_def_with_fees(helpers, @@ -39,8 +42,14 @@ def test_send_claim_def_with_fees(helpers, address_main, utxos=utxos ) + + token_len = len(nodeSetWithIntegratedTokenPlugin[0].ledgers[-1]) write_rep = helpers.sdk.send_and_check_request_objects([req], wallet=sdk_wallet_trustee) + assert token_len == len(nodeSetWithIntegratedTokenPlugin[0].ledgers[-1]) - 1 + assert get_last_token_txn(nodeSetWithIntegratedTokenPlugin)[1]['txn']['data']['fees'] == CLAIM_DEF_FEE + added_claim_def_id = write_rep[0][1]['result'][TXN_METADATA][TXN_METADATA_ID] request = looper.loop.run_until_complete(build_get_cred_def_request(sdk_wallet_trustee[1], added_claim_def_id)) - read_rep = sdk_get_and_check_replies(looper, [sdk_sign_and_submit_req(sdk_pool_handle, sdk_wallet_trustee, request)]) + read_rep = sdk_get_and_check_replies(looper, + [sdk_sign_and_submit_req(sdk_pool_handle, sdk_wallet_trustee, request)]) assert req.operation[DATA] == read_rep[0][1]['result'][DATA] diff --git a/sovtokenfees/sovtokenfees/test/transactions/test_nym_with_fees.py b/sovtokenfees/sovtokenfees/test/transactions/test_nym_with_fees.py index a8812017..7076eaf9 100644 --- a/sovtokenfees/sovtokenfees/test/transactions/test_nym_with_fees.py +++ b/sovtokenfees/sovtokenfees/test/transactions/test_nym_with_fees.py @@ -7,15 +7,18 @@ from sovtoken.test.helpers.helper_general import utxo_from_addr_and_seq_no from sovtokenfees.test.constants import NYM_FEES_ALIAS from sovtokenfees.test.helper import get_amount_from_token_txn, add_fees_request_with_address +from sovtokenfees.test.transactions.helper import get_last_token_txn from plenum.common.constants import DATA from plenum.test.helper import sdk_sign_and_submit_req, \ sdk_get_and_check_replies +NYM_FEE = 1 + @pytest.fixture() def fees(): - return {NYM_FEES_ALIAS: 5} + return {NYM_FEES_ALIAS: NYM_FEE} def test_send_nym_with_fees(helpers, @@ -38,7 +41,12 @@ def test_send_nym_with_fees(helpers, address_main, utxos=utxos ) + + token_len = len(nodeSetWithIntegratedTokenPlugin[0].ledgers[-1]) helpers.sdk.send_and_check_request_objects([req], wallet=sdk_wallet_trustee) + assert token_len == len(nodeSetWithIntegratedTokenPlugin[0].ledgers[-1]) - 1 + assert get_last_token_txn(nodeSetWithIntegratedTokenPlugin)[1]['txn']['data']['fees'] == NYM_FEE + request = looper.loop.run_until_complete( build_get_nym_request(sdk_wallet_trustee[1], req.operation['dest'])) read_rep = sdk_get_and_check_replies(looper, diff --git a/sovtokenfees/sovtokenfees/test/transactions/test_revoc_reg_def_with_fees.py b/sovtokenfees/sovtokenfees/test/transactions/test_revoc_reg_def_with_fees.py index 687cfb76..8250c754 100644 --- a/sovtokenfees/sovtokenfees/test/transactions/test_revoc_reg_def_with_fees.py +++ b/sovtokenfees/sovtokenfees/test/transactions/test_revoc_reg_def_with_fees.py @@ -8,22 +8,26 @@ from sovtokenfees.test.helper import get_amount_from_token_txn, add_fees_request_with_address from indy_common.types import Request +from sovtokenfees.test.transactions.helper import get_last_token_txn + from plenum.common.constants import TXN_METADATA, TXN_METADATA_ID, DATA, TXN_TYPE from plenum.test.helper import sdk_get_and_check_replies, sdk_sign_and_submit_req +REVOC_REG_DEF_FEE = 5 + @pytest.fixture() def fees(): - return {REVOC_REG_DEF_FEES_ALIAS: 5} + return {REVOC_REG_DEF_FEES_ALIAS: REVOC_REG_DEF_FEE} def test_revoc_reg_def_with_fees(helpers, - looper, - nodeSetWithIntegratedTokenPlugin, - sdk_wallet_trustee, - sdk_pool_handle, - claim_def_id, - fees_set, address_main, mint_tokens): + looper, + nodeSetWithIntegratedTokenPlugin, + sdk_wallet_trustee, + sdk_pool_handle, + claim_def_id, + fees_set, address_main, mint_tokens): req = helpers.request.revoc_reg_def(claim_def_id, sdk_wallet=sdk_wallet_trustee) amount = get_amount_from_token_txn(mint_tokens) init_seq_no = 1 @@ -37,9 +41,15 @@ def test_revoc_reg_def_with_fees(helpers, address_main, utxos=utxos ) + + token_len = len(nodeSetWithIntegratedTokenPlugin[0].ledgers[-1]) write_rep = helpers.sdk.send_and_check_request_objects([req], wallet=sdk_wallet_trustee) + assert token_len == len(nodeSetWithIntegratedTokenPlugin[0].ledgers[-1]) - 1 + assert get_last_token_txn(nodeSetWithIntegratedTokenPlugin)[1]['txn']['data']['fees'] == REVOC_REG_DEF_FEE + added_revoc_reg_def_id = write_rep[0][1]['result'][TXN_METADATA][TXN_METADATA_ID] - request = looper.loop.run_until_complete(build_get_revoc_reg_def_request(sdk_wallet_trustee[1], added_revoc_reg_def_id)) + request = looper.loop.run_until_complete( + build_get_revoc_reg_def_request(sdk_wallet_trustee[1], added_revoc_reg_def_id)) read_rep = sdk_get_and_check_replies(looper, [sdk_sign_and_submit_req(sdk_pool_handle, sdk_wallet_trustee, request)]) read_data = read_rep[0][1]['result'][DATA] diff --git a/sovtokenfees/sovtokenfees/test/transactions/test_revoc_reg_entry_with_fees.py b/sovtokenfees/sovtokenfees/test/transactions/test_revoc_reg_entry_with_fees.py index e309f404..fd33937f 100644 --- a/sovtokenfees/sovtokenfees/test/transactions/test_revoc_reg_entry_with_fees.py +++ b/sovtokenfees/sovtokenfees/test/transactions/test_revoc_reg_entry_with_fees.py @@ -8,13 +8,17 @@ from sovtokenfees.test.helper import get_amount_from_token_txn, add_fees_request_with_address from indy_common.types import Request +from sovtokenfees.test.transactions.helper import get_last_token_txn + from plenum.common.constants import TXN_METADATA, TXN_METADATA_ID, DATA, TXN_TYPE from plenum.test.helper import sdk_get_and_check_replies, sdk_sign_and_submit_req +REVOC_REG_ENTRY_FEE = 6 + @pytest.fixture() def fees(): - return {REVOC_REG_ENTRY_FEES_ALIAS: 5} + return {REVOC_REG_ENTRY_FEES_ALIAS: REVOC_REG_ENTRY_FEE} def test_revoc_reg_entry_with_fees(helpers, @@ -37,5 +41,10 @@ def test_revoc_reg_entry_with_fees(helpers, address_main, utxos=utxos ) + + token_len = len(nodeSetWithIntegratedTokenPlugin[0].ledgers[-1]) write_rep = helpers.sdk.send_and_check_request_objects([req], wallet=sdk_wallet_trustee) + assert token_len == len(nodeSetWithIntegratedTokenPlugin[0].ledgers[-1]) - 1 + assert get_last_token_txn(nodeSetWithIntegratedTokenPlugin)[1]['txn']['data']['fees'] == REVOC_REG_ENTRY_FEE + assert write_rep[0][1]['op'] == "REPLY" diff --git a/sovtokenfees/sovtokenfees/test/transactions/test_schema_with_fees.py b/sovtokenfees/sovtokenfees/test/transactions/test_schema_with_fees.py index f796f0f9..f43a8afa 100644 --- a/sovtokenfees/sovtokenfees/test/transactions/test_schema_with_fees.py +++ b/sovtokenfees/sovtokenfees/test/transactions/test_schema_with_fees.py @@ -8,15 +8,18 @@ from sovtokenfees.test.helper import get_amount_from_token_txn, add_fees_request_with_address from indy_common.types import Request +from sovtokenfees.test.transactions.helper import get_last_token_txn from plenum.common.constants import TXN_METADATA, TXN_METADATA_ID, DATA from plenum.test.helper import sdk_sign_and_submit_req, \ sdk_get_and_check_replies +SCHEMA_FEE = 3 + @pytest.fixture() def fees(): - return {SCHEMA_FEES_ALIAS: 5} + return {SCHEMA_FEES_ALIAS: SCHEMA_FEE} def test_send_schema_with_fees(helpers, @@ -38,7 +41,12 @@ def test_send_schema_with_fees(helpers, address_main, utxos=utxos ) + + token_len = len(nodeSetWithIntegratedTokenPlugin[0].ledgers[-1]) write_rep = helpers.sdk.send_and_check_request_objects([req], wallet=sdk_wallet_trustee) + assert token_len == len(nodeSetWithIntegratedTokenPlugin[0].ledgers[-1]) - 1 + assert get_last_token_txn(nodeSetWithIntegratedTokenPlugin)[1]['txn']['data']['fees'] == SCHEMA_FEE + schema_id = write_rep[0][1]['result'][TXN_METADATA][TXN_METADATA_ID] request = looper.loop.run_until_complete(build_get_schema_request(sdk_wallet_trustee[1], schema_id)) read_rep = sdk_get_and_check_replies(looper,