diff --git a/package.json b/package.json index 503d58b..0bf26b2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@1inch/erc20-pods", - "version": "0.0.8", + "version": "0.0.9", "description": "ERC20 extension enabling external smart contract based Pods to track balances of those users who opted-in to these Pods", "repository": { "type": "git", diff --git a/test/ERC20Pods.js b/test/ERC20Pods.js index eafb5fe..4fcf8aa 100644 --- a/test/ERC20Pods.js +++ b/test/ERC20Pods.js @@ -1,10 +1,17 @@ -const { ether } = require('@1inch/solidity-utils'); +const { expect, ether } = require('@1inch/solidity-utils'); const { ethers } = require('hardhat'); +const { loadFixture } = require('@nomicfoundation/hardhat-network-helpers'); const { shouldBehaveLikeERC20Pods } = require('./behaviors/ERC20Pods.behavior'); const POD_LIMITS = 10; describe('ERC20Pods', function () { + let wallet1; + + before(async function () { + [wallet1] = await ethers.getSigners(); + }); + async function initContracts () { const ERC20PodsMock = await ethers.getContractFactory('ERC20PodsMock'); const erc20Pods = await ERC20PodsMock.deploy('ERC20PodsMock', 'EPM', POD_LIMITS); @@ -22,5 +29,23 @@ describe('ERC20Pods', function () { return { erc20Pods, pods, amount }; }; + async function initWrongPodAndMint () { + const { erc20Pods, amount } = await initContracts(); + await erc20Pods.mint(wallet1.address, amount); + const WrongPodMock = await ethers.getContractFactory('WrongPodMock'); + const wrongPod = await WrongPodMock.deploy('WrongPodMock', 'WPM', erc20Pods.address); + await wrongPod.deployed(); + return { erc20Pods, wrongPod, amount }; + }; + shouldBehaveLikeERC20Pods(initContracts); + + it('should not fail when updateBalance returns gas bomb @skip-on-coverage', async function () { + const { erc20Pods, wrongPod } = await loadFixture(initWrongPodAndMint); + await wrongPod.setReturnGasBomb(true); + const tx = await erc20Pods.addPod(wrongPod.address); + const receipt = await tx.wait(); + expect(receipt.gasUsed).to.be.lt(272123); // 272123 with solidity instead of assembly + expect(await erc20Pods.pods(wallet1.address)).to.have.deep.equals([wrongPod.address]); + }); }); diff --git a/test/behaviors/ERC20Pods.behavior.js b/test/behaviors/ERC20Pods.behavior.js index adda559..977a5db 100644 --- a/test/behaviors/ERC20Pods.behavior.js +++ b/test/behaviors/ERC20Pods.behavior.js @@ -254,15 +254,6 @@ function shouldBehaveLikeERC20Pods (initContracts) { await erc20Pods.addPod(wrongPod.address); expect(await erc20Pods.pods(wallet1.address)).to.have.deep.equals([wrongPod.address]); }); - - it('should not fail when updateBalance returns gas bomb @skip-on-coverage', async function () { - const { erc20Pods, wrongPod } = await loadFixture(initWrongPodAndMint); - await wrongPod.setReturnGasBomb(true); - const tx = await erc20Pods.addPod(wrongPod.address); - const receipt = await tx.wait(); - expect(receipt.gasUsed).to.be.lt(272123); // 272123 with solidity instead of assembly - expect(await erc20Pods.pods(wallet1.address)).to.have.deep.equals([wrongPod.address]); - }); }); describe('_afterTokenTransfer', function () {