Skip to content

Commit 8089518

Browse files
committed
Update EVM tests
1 parent 125a65a commit 8089518

File tree

3 files changed

+47
-5
lines changed

3 files changed

+47
-5
lines changed

evm-tests/test/neuron.precompile.reveal-weights.test.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as assert from "assert";
2-
import { getAliceSigner, getDevnetApi, getRandomSubstrateKeypair } from "../src/substrate"
2+
import { getAliceSigner, getDevnetApi, getRandomSubstrateKeypair, waitForTransactionWithRetry } from "../src/substrate"
33
import { devnet } from "@polkadot-api/descriptors"
44
import { PolkadotSigner, TypedApi } from "polkadot-api";
55
import { convertPublicKeyToSs58, convertH160ToSS58 } from "../src/address-utils"
@@ -70,6 +70,20 @@ describe("Test neuron precompile reveal weights", () => {
7070
await startCall(api, netuid, coldkey)
7171

7272
console.log("test the case on subnet ", netuid)
73+
// Disable admin freeze window and owner hyperparam rate limiting for tests
74+
{
75+
const alice = getAliceSigner()
76+
77+
// Set AdminFreezeWindow to 0
78+
const setFreezeWindow = api.tx.AdminUtils.sudo_set_admin_freeze_window({ window: 0 })
79+
const sudoFreezeTx = api.tx.Sudo.sudo({ call: setFreezeWindow.decodedCall })
80+
await waitForTransactionWithRetry(api, sudoFreezeTx, alice)
81+
82+
// Set OwnerHyperparamRateLimit to 0
83+
const setOwnerRateLimit = api.tx.AdminUtils.sudo_set_owner_hparam_rate_limit({ limit: BigInt(0) })
84+
const sudoOwnerRateTx = api.tx.Sudo.sudo({ call: setOwnerRateLimit.decodedCall })
85+
await waitForTransactionWithRetry(api, sudoOwnerRateTx, alice)
86+
}
7387

7488
await setWeightsSetRateLimit(api, netuid, BigInt(0))
7589

@@ -164,4 +178,4 @@ describe("Test neuron precompile reveal weights", () => {
164178
assert.ok(weight[1] !== undefined)
165179
}
166180
})
167-
});
181+
});

evm-tests/test/neuron.precompile.set-weights.test.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as assert from "assert";
22

3-
import { getDevnetApi, getRandomSubstrateKeypair } from "../src/substrate"
3+
import { getAliceSigner, getDevnetApi, getRandomSubstrateKeypair, waitForTransactionWithRetry } from "../src/substrate"
44
import { devnet } from "@polkadot-api/descriptors"
55
import { TypedApi } from "polkadot-api";
66
import { convertH160ToSS58, convertPublicKeyToSs58, } from "../src/address-utils"
@@ -38,6 +38,20 @@ describe("Test neuron precompile contract, set weights function", () => {
3838
await burnedRegister(api, netuid, convertH160ToSS58(wallet.address), coldkey)
3939
const uid = await api.query.SubtensorModule.Uids.getValue(netuid, convertH160ToSS58(wallet.address))
4040
assert.notEqual(uid, undefined)
41+
// Disable admin freeze window and owner hyperparam rate limiting for tests
42+
{
43+
const alice = getAliceSigner()
44+
45+
// Set AdminFreezeWindow to 0
46+
const setFreezeWindow = api.tx.AdminUtils.sudo_set_admin_freeze_window({ window: 0 })
47+
const sudoFreezeTx = api.tx.Sudo.sudo({ call: setFreezeWindow.decodedCall })
48+
await waitForTransactionWithRetry(api, sudoFreezeTx, alice)
49+
50+
// Set OwnerHyperparamRateLimit to 0
51+
const setOwnerRateLimit = api.tx.AdminUtils.sudo_set_owner_hparam_rate_limit({ limit: BigInt(0) })
52+
const sudoOwnerRateTx = api.tx.Sudo.sudo({ call: setOwnerRateLimit.decodedCall })
53+
await waitForTransactionWithRetry(api, sudoOwnerRateTx, alice)
54+
}
4155
// disable reveal and enable direct set weights
4256
await setCommitRevealWeightsEnabled(api, netuid, false)
4357
await setWeightsSetRateLimit(api, netuid, BigInt(0))
@@ -68,4 +82,4 @@ describe("Test neuron precompile contract, set weights function", () => {
6882
});
6983
}
7084
})
71-
});
85+
});

evm-tests/test/staking.precompile.reward.test.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as assert from "assert";
2-
import { getDevnetApi, getRandomSubstrateKeypair } from "../src/substrate"
2+
import { getAliceSigner, getDevnetApi, getRandomSubstrateKeypair, waitForTransactionWithRetry } from "../src/substrate"
33
import { devnet } from "@polkadot-api/descriptors"
44
import { TypedApi } from "polkadot-api";
55
import { convertPublicKeyToSs58 } from "../src/address-utils"
@@ -39,6 +39,20 @@ describe("Test neuron precompile reward", () => {
3939
await startCall(api, netuid, coldkey)
4040

4141
console.log("test the case on subnet ", netuid)
42+
// Disable admin freeze window and owner hyperparam rate limiting for tests
43+
{
44+
const alice = getAliceSigner()
45+
46+
// Set AdminFreezeWindow to 0
47+
const setFreezeWindow = api.tx.AdminUtils.sudo_set_admin_freeze_window({ window: 0 })
48+
const sudoFreezeTx = api.tx.Sudo.sudo({ call: setFreezeWindow.decodedCall })
49+
await waitForTransactionWithRetry(api, sudoFreezeTx, alice)
50+
51+
// Set OwnerHyperparamRateLimit to 0
52+
const setOwnerRateLimit = api.tx.AdminUtils.sudo_set_owner_hparam_rate_limit({ limit: BigInt(0) })
53+
const sudoOwnerRateTx = api.tx.Sudo.sudo({ call: setOwnerRateLimit.decodedCall })
54+
await waitForTransactionWithRetry(api, sudoOwnerRateTx, alice)
55+
}
4256

4357
await setTxRateLimit(api, BigInt(0))
4458
await setTempo(api, root_netuid, root_tempo)

0 commit comments

Comments
 (0)