Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add transaction fee tests #2318

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions tests/e2e_tests/subcommands/stake/test_stake_add_remove.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ def test_stake_add(local_chain):
== 0
), "TotalHotkeyStake is not 0"

# Check coldkey balance before adding stake
acc_before = local_chain.query("System", "Account", [wallet.coldkey.ss58_address])
print("================= Balance before: ", acc_before.value["data"]["free"])

stake_amount = 2
exec_command(StakeCommand, ["stake", "add", "--amount", str(stake_amount)])
exact_stake = local_chain.query(
Expand All @@ -66,6 +70,13 @@ def test_stake_add(local_chain):
stake_amount_in_rao - withdraw_loss < exact_stake <= stake_amount_in_rao
), f"Stake amount mismatch: expected {exact_stake} to be between {stake_amount_in_rao - withdraw_loss} and {stake_amount_in_rao}"

# Ensure fees are not withdrawn for the add_stake extrinsic, i.e. balance is exactly lower by stake amount
acc_after = local_chain.query("System", "Account", [wallet.coldkey.ss58_address])
assert (
acc_before.value["data"]["free"] - acc_after.value["data"]["free"]
== stake_amount * 1_000_000_000
), f"Expected no transaction fees for add_stake"

# we can test remove after set the stake rate limit larger than 1
remove_amount = 1

Expand Down
7 changes: 7 additions & 0 deletions tests/e2e_tests/subcommands/wallet/test_transfer.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,11 @@ def test_transfer(local_chain):
assert (
expected_transfer <= actual_difference <= expected_transfer + tolerance
), f"Expected transfer with tolerance: {expected_transfer} <= {actual_difference} <= {expected_transfer + tolerance}"

# Ensure the transaction fees are withdrawn
fees_lower_boundary = 50_000 # Transfer fees should be at least 50 microTAO
assert (
expected_transfer + fees_lower_boundary <= actual_difference
), f"Expected transfer fees: {expected_transfer + fees_lower_boundary} <= {actual_difference}"

logging.info("Passed test_transfer")