1- const { ether } = require ( '@1inch/solidity-utils' ) ;
1+ const { expect , ether } = require ( '@1inch/solidity-utils' ) ;
22const { ethers } = require ( 'hardhat' ) ;
3+ const { loadFixture } = require ( '@nomicfoundation/hardhat-network-helpers' ) ;
34const { shouldBehaveLikeERC20Pods } = require ( './behaviors/ERC20Pods.behavior' ) ;
45
56const POD_LIMITS = 10 ;
67
78describe ( 'ERC20Pods' , function ( ) {
9+ let wallet1 ;
10+
11+ before ( async function ( ) {
12+ [ wallet1 ] = await ethers . getSigners ( ) ;
13+ } ) ;
14+
815 async function initContracts ( ) {
916 const ERC20PodsMock = await ethers . getContractFactory ( 'ERC20PodsMock' ) ;
1017 const erc20Pods = await ERC20PodsMock . deploy ( 'ERC20PodsMock' , 'EPM' , POD_LIMITS ) ;
@@ -20,5 +27,23 @@ describe('ERC20Pods', function () {
2027 return { erc20Pods, pods, amount } ;
2128 } ;
2229
30+ async function initWrongPodAndMint ( ) {
31+ const { erc20Pods, amount } = await initContracts ( ) ;
32+ await erc20Pods . mint ( wallet1 . address , amount ) ;
33+ const WrongPodMock = await ethers . getContractFactory ( 'WrongPodMock' ) ;
34+ const wrongPod = await WrongPodMock . deploy ( 'WrongPodMock' , 'WPM' , erc20Pods . address ) ;
35+ await wrongPod . deployed ( ) ;
36+ return { erc20Pods, wrongPod, amount } ;
37+ } ;
38+
2339 shouldBehaveLikeERC20Pods ( initContracts ) ;
40+
41+ it ( 'should not fail when updateBalance returns gas bomb @skip-on-coverage' , async function ( ) {
42+ const { erc20Pods, wrongPod } = await loadFixture ( initWrongPodAndMint ) ;
43+ await wrongPod . setReturnGasBomb ( true ) ;
44+ const tx = await erc20Pods . addPod ( wrongPod . address ) ;
45+ const receipt = await tx . wait ( ) ;
46+ expect ( receipt . gasUsed ) . to . be . lt ( 274168 ) ;
47+ expect ( await erc20Pods . pods ( wallet1 . address ) ) . to . have . deep . equals ( [ wrongPod . address ] ) ;
48+ } ) ;
2449} ) ;
0 commit comments