Skip to content

Commit

Permalink
1. Addressed issue when deriving account transfers.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark A. Greenslade committed Feb 8, 2021
1 parent 285fa72 commit ea6a08b
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion stests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# ╚═════╝░░░░╚═╝░░░╚══════╝╚═════╝░░░░╚═╝░░░╚═════╝░

__title__ = "stests"
__version__ = "1.2.0"
__version__ = "1.2.1"
__author__ = "Casper Labs AG, Zug, Switzerland"
__license__ = "CasperLabs Open Source License (COSL)"
__copyright__ = "Copyright 2020 Casper Labs"
9 changes: 5 additions & 4 deletions stests/generators/utils/accounts.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ def do_transfer(
# Set amount to transfer (in the case of refunds).
if amount is None:
amount = get_account_balance(network, node, cp1) - chain.DEFAULT_TX_FEE
print(amount)

# Dispatch tx -> chain.
dispatch_info = chain.DeployDispatchInfo(cp1, network, node)
Expand Down Expand Up @@ -195,14 +194,16 @@ def get_account_range(accounts: int, deploys: int) -> int:
return range(1, (deploys if accounts == 0 else accounts) + 1)


def get_account_transfer_count(accounts: int, account_idx: int, deploys: int) -> int:
def get_account_deploy_count(accounts: int, account_idx: int, deploys: int) -> int:
"""Returns account index to use for a particular transfer.
"""
if accounts == 0:
return 1

return 10

q, r = divmod(deploys, accounts)

return q + (1 if account_idx <= r else 0)


def get_faucet_initial_balance(transfers, amount) -> int:
Expand Down
4 changes: 2 additions & 2 deletions stests/generators/wg_100/p2s3_assert_balances.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ def execute(ctx: ExecutionContext):
"""
for account_idx in accounts.get_account_range(ctx.args.accounts, ctx.args.transfers):
transfers = accounts.get_account_transfer_count(ctx.args.accounts, account_idx, ctx.args.transfers)
amount = transfers * (ctx.args.amount + chain.DEFAULT_TX_FEE_NATIVE_TRANSFER)
account_transfers = accounts.get_account_deploy_count(ctx.args.accounts, account_idx, ctx.args.transfers)
amount = account_transfers * (ctx.args.amount + chain.DEFAULT_TX_FEE_NATIVE_TRANSFER)
verification.verify_account_balance(ctx, account_idx, amount)
2 changes: 1 addition & 1 deletion stests/generators/wg_110/p2s3_assert_balances.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ def execute(ctx: ExecutionContext):
"""
for account_idx in accounts.get_account_range(ctx.args.accounts, ctx.args.transfers):
transfers = accounts.get_account_transfer_count(ctx.args.accounts, account_idx, ctx.args.transfers)
transfers = accounts.get_account_deploy_count(ctx.args.accounts, account_idx, ctx.args.transfers)
amount = transfers * (ctx.args.amount + chain.DEFAULT_TX_FEE_NATIVE_TRANSFER)
verification.verify_account_balance(ctx, account_idx, amount)

0 comments on commit ea6a08b

Please sign in to comment.