Skip to content

Commit

Permalink
Add transaction fee tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gztensor committed Sep 24, 2024
1 parent f531c8e commit 05df58b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
10 changes: 10 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,12 @@ 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")

0 comments on commit 05df58b

Please sign in to comment.