@@ -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