Skip to content

Commit ef4cf9e

Browse files
committed
fix(test-suite): use manual mining for HCU whitelist removal test
The automine=true + intervalMining=0 combo is unreliable in CI — Anvil hangs for ~5min before mining the mint tx, causing Mocha timeout. Switch to automine=false + explicit evm_mine after each tx, matching the proven pattern used by the "with lowered limits" tests that pass consistently. Also add gasLimit overrides to bypass estimateGas against pending state.
1 parent c4e5e78 commit ef4cf9e

File tree

1 file changed

+23
-8
lines changed

1 file changed

+23
-8
lines changed

test-suite/e2e/test/encryptedERC20/EncryptedERC20.HCU.ts

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -261,29 +261,44 @@ describe('EncryptedERC20:HCU', function () {
261261

262262
it('should count HCU after whitelist removal', async function () {
263263
const ownerHcuLimit = this.hcuLimit.connect(this.deployer);
264-
await ethers.provider.send('evm_setAutomine', [true]);
264+
265+
// Use manual mining (automine=false + explicit evm_mine) to avoid
266+
// the unreliable automine+intervalMining(0) combo that hangs in CI.
265267
await ethers.provider.send('evm_setIntervalMining', [0]);
268+
await ethers.provider.send('evm_setAutomine', [false]);
266269

267270
const mintTx = await this.erc20.mint(10000);
268-
await waitForConfirmedTx(mintTx, 'mint');
271+
await ethers.provider.send('evm_mine');
272+
const mintReceipt = await waitForTransactionReceipt(mintTx.hash);
273+
expect(mintReceipt.status).to.eq(1, 'Mint should succeed');
269274

270275
const whitelistTx = await ownerHcuLimit.addToBlockHCUWhitelist(this.contractAddress);
271-
await waitForConfirmedTx(whitelistTx, 'whitelist');
276+
await ethers.provider.send('evm_mine');
277+
await waitForTransactionReceipt(whitelistTx.hash);
278+
279+
// Advance to a fresh block so the transfer starts with a clean meter
272280
await mineNBlocks(1);
273281

274282
// Transfer while whitelisted — meter stays at 0
275-
const tx1 = await sendEncryptedTransfer(this, 'alice', this.signers.bob.address, 100);
276-
await waitForConfirmedTx(tx1, 'whitelisted-transfer');
283+
const tx1 = await sendEncryptedTransfer(this, 'alice', this.signers.bob.address, 100, {
284+
gasLimit: BATCHED_TRANSFER_GAS_LIMIT,
285+
});
286+
await ethers.provider.send('evm_mine');
287+
await waitForTransactionReceipt(tx1.hash);
277288

278289
const [, usedHCUWhitelisted] = await this.hcuLimit.getBlockMeter();
279290
expect(usedHCUWhitelisted).to.eq(0n, 'Whitelisted contract should not count HCU');
280291

281292
const unwhitelistTx = await ownerHcuLimit.removeFromBlockHCUWhitelist(this.contractAddress);
282-
await waitForConfirmedTx(unwhitelistTx, 'unwhitelist');
293+
await ethers.provider.send('evm_mine');
294+
await waitForTransactionReceipt(unwhitelistTx.hash);
283295

284296
// Transfer after removal — meter should count HCU
285-
const tx2 = await sendEncryptedTransfer(this, 'alice', this.signers.bob.address, 100);
286-
await waitForConfirmedTx(tx2, 'post-whitelist-transfer');
297+
const tx2 = await sendEncryptedTransfer(this, 'alice', this.signers.bob.address, 100, {
298+
gasLimit: BATCHED_TRANSFER_GAS_LIMIT,
299+
});
300+
await ethers.provider.send('evm_mine');
301+
await waitForTransactionReceipt(tx2.hash);
287302

288303
const [, usedHCUAfterRemoval] = await this.hcuLimit.getBlockMeter();
289304
expect(usedHCUAfterRemoval).to.be.greaterThan(0n, 'Should count HCU after whitelist removal');

0 commit comments

Comments
 (0)