Skip to content

Commit a382cc8

Browse files
committed
fix flaky test due to lock cost increase
1 parent 3420f1f commit a382cc8

File tree

1 file changed

+23
-17
lines changed

1 file changed

+23
-17
lines changed

evm-tests/test/leasing.precompile.test.ts

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,34 +18,41 @@ describe("Test Leasing precompile", () => {
1818
let publicClient: PublicClient;
1919
let api: TypedApi<typeof devnet>;
2020

21+
let wallet1: ethers.Wallet;
22+
let wallet2: ethers.Wallet;
23+
let wallet3: ethers.Wallet;
24+
let leaseContract: ethers.Contract;
25+
let crowdloanContract: ethers.Contract;
26+
let neuronContract: ethers.Contract;
27+
2128
const alice = getAliceSigner();
2229
const bob = getBobSigner();
23-
const wallet1 = generateRandomEthersWallet();
24-
const wallet2 = generateRandomEthersWallet();
25-
const wallet3 = generateRandomEthersWallet();
26-
27-
const crowdloanContract = new ethers.Contract(ICROWDLOAN_ADDRESS, ICrowdloanABI, wallet1);
28-
const leaseContract = new ethers.Contract(ILEASING_ADDRESS, ILeasingABI, wallet1);
29-
const neuronContract = new ethers.Contract(INEURON_ADDRESS, INeuronABI, wallet1);
3030

31-
before(async () => {
31+
beforeEach(async () => {
3232
publicClient = await getPublicClient(ETH_LOCAL_URL);
3333
api = await getDevnetApi();
3434

35+
wallet1 = generateRandomEthersWallet();
36+
wallet2 = generateRandomEthersWallet();
37+
wallet3 = generateRandomEthersWallet();
38+
leaseContract = new ethers.Contract(ILEASING_ADDRESS, ILeasingABI, wallet1);
39+
crowdloanContract = new ethers.Contract(ICROWDLOAN_ADDRESS, ICrowdloanABI, wallet1);
40+
neuronContract = new ethers.Contract(INEURON_ADDRESS, INeuronABI, wallet1);
41+
3542
await forceSetBalanceToEthAddress(api, wallet1.address);
3643
await forceSetBalanceToEthAddress(api, wallet2.address);
37-
44+
await forceSetBalanceToEthAddress(api, wallet3.address);
3845
await neuronContract.burnedRegister(1, convertH160ToPublicKey(wallet3.address));
3946
await forceSetBalanceToEthAddress(api, wallet1.address);
4047
});
4148

4249
it("gets an existing lease created on substrate side, its subnet id and its contributor shares", async () => {
4350
const nextCrowdloanId = await api.query.Crowdloan.NextCrowdloanId.getValue();
4451
const crowdloanDeposit = BigInt(100_000_000_000); // 100 TAO
45-
const crowdloanCap = BigInt(2_000_000_000_000); // 2000 TAO
52+
const crowdloanCap = BigInt(10_000_000_000_000); // 10000 TAO
4653
const crowdloanEnd = await api.query.System.Number.getValue() + 100;
4754
const leaseEmissionsShare = 15;
48-
const leaseEnd = await api.query.System.Number.getValue() + 5000;
55+
const leaseEnd = await api.query.System.Number.getValue() + 300;
4956

5057
await api.tx.Crowdloan.create({
5158
deposit: crowdloanDeposit,
@@ -91,16 +98,16 @@ describe("Test Leasing precompile", () => {
9198
assert.deepEqual(aliceShare, [BigInt(0), BigInt(0)]);
9299
const bobShare = await leaseContract.getContributorShare(nextLeaseId, bob.publicKey)
93100
assert.notDeepEqual(bobShare, [BigInt(0), BigInt(0)]);
94-
})
101+
});
95102

96103
it("registers a new leased network through a crowdloan and retrieves the lease", async () => {
97104
const nextCrowdloanId = await api.query.Crowdloan.NextCrowdloanId.getValue();
98105
const crowdloanDeposit = BigInt(100_000_000_000); // 100 TAO
99106
const crowdloanMinContribution = BigInt(1_000_000_000); // 1 TAO
100-
const crowdloanCap = BigInt(2_000_000_000_000); // 2000 TAO
107+
const crowdloanCap = BigInt(10_000_000_000_000); // 10000 TAO
101108
const crowdloanEnd = await api.query.System.Number.getValue() + 100;
102109
const leasingEmissionsShare = 15;
103-
const leasingEndBlock = await api.query.System.Number.getValue() + 5000;
110+
const leasingEndBlock = await api.query.System.Number.getValue() + 300;
104111

105112
let tx = await leaseContract.createLeaseCrowdloan(
106113
crowdloanDeposit,
@@ -154,7 +161,7 @@ describe("Test Leasing precompile", () => {
154161
const nextCrowdloanId = await api.query.Crowdloan.NextCrowdloanId.getValue();
155162
const crowdloanDeposit = BigInt(100_000_000_000); // 100 TAO
156163
const crowdloanMinContribution = BigInt(1_000_000_000); // 1 TAO
157-
const crowdloanCap = BigInt(2_000_000_000_000); // 2000 TAO
164+
const crowdloanCap = BigInt(10_000_000_000_000); // 10000 TAO
158165
const crowdloanEnd = await api.query.System.Number.getValue() + 100;
159166
const leasingEmissionsShare = 15;
160167
const leasingEndBlock = await api.query.System.Number.getValue() + 200;
@@ -186,8 +193,7 @@ describe("Test Leasing precompile", () => {
186193
assert.isDefined(lease);
187194
const netuid = lease.netuid;
188195

189-
const hotkey = convertH160ToPublicKey(wallet3.address);
190-
tx = await leaseContract.terminateLease(nextLeaseId, hotkey);
196+
tx = await leaseContract.terminateLease(nextLeaseId, convertH160ToPublicKey(wallet3.address));
191197
await tx.wait();
192198

193199
lease = await api.query.SubtensorModule.SubnetLeases.getValue(nextLeaseId);

0 commit comments

Comments
 (0)