Skip to content

Commit

Permalink
Review fixes
Browse files Browse the repository at this point in the history
Signed-off-by: ArtObr <[email protected]>
  • Loading branch information
ArtObr committed Jul 10, 2019
1 parent b2a1a1d commit 5f6edab
Show file tree
Hide file tree
Showing 7 changed files with 71 additions and 14 deletions.
5 changes: 5 additions & 0 deletions sovtokenfees/sovtokenfees/test/transactions/helper.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from collections import deque


def get_last_token_txn(nodeSet):
return deque(nodeSet[0].ledgers[-1].getAllTxn()).pop()
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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]
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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"
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down

0 comments on commit 5f6edab

Please sign in to comment.