Skip to content

Commit c876e11

Browse files
committed
- more tests
1 parent a6c96bb commit c876e11

1 file changed

Lines changed: 37 additions & 0 deletions

File tree

ts-tests/suites/dev/subtensor/transaction-payment-wrapper/00-transaction-payment-wrapper.test.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,5 +53,42 @@ describeSuite({
5353
expect(hotkeyBalance).toEqual(existentialDeposit);
5454
},
5555
});
56+
57+
it({
58+
id: "T02",
59+
title: "Fees for set_weights charged from hotkey if no association",
60+
test: async () => {
61+
const coldkey = generateKeyringPair("sr25519");
62+
const hotkey = generateKeyringPair("sr25519");
63+
64+
log(`coldkey: ${coldkey.address}`);
65+
log(`hotkey: ${hotkey.address}`);
66+
67+
const initialBalance = tao(1e10);
68+
69+
log("Set Up");
70+
const existentialDeposit = await api.consts.balances.existentialDeposit.toBigInt();
71+
// Hotkey should "exist", even if coldkey is paying for tx
72+
await devForceSetBalance(api, context, hotkey.address, initialBalance);
73+
74+
const hotkeyBalanceBefore = (await api.query.system.account(hotkey.address)).data.free.toBigInt();
75+
76+
log("Execute the tx from hotkey, no association, hotkey will pay");
77+
await devSetWeightsTx(api, context, hotkey, 0, [], [], 0n);
78+
79+
const events = await api.query.system.events();
80+
const feeEvent = events.filter((a) => {
81+
return a.event.method.toString() === "TransactionFeePaid";
82+
});
83+
84+
const hotkeyBalanceAfter = (await api.query.system.account(hotkey.address)).data.free.toBigInt();
85+
const coldkeyBalanceAfter = (await api.query.system.account(coldkey.address)).data.free.toBigInt();
86+
// Fees paid by the hotkey
87+
const txFee = feeEvent[0].event.data.actualFee.toBigInt();
88+
expect(txFee).toBeGreaterThan(0n);
89+
expect(coldkeyBalanceAfter).toEqual(0n);
90+
expect(hotkeyBalanceBefore - txFee).toEqual(hotkeyBalanceAfter);
91+
},
92+
});
5693
},
5794
});

0 commit comments

Comments
 (0)