From 42fc6cbfddbe4ee8a5ba565f88104f6b78c5a8f5 Mon Sep 17 00:00:00 2001 From: Alain Olivier Date: Tue, 27 Feb 2024 09:29:46 +0100 Subject: [PATCH] test(fork): move Polygon forwarder test into dao.test.js --- test/fork/dao.test.js | 40 +++++++++++++++++++++++++++++++++++- test/fork/forwarders.test.js | 39 +---------------------------------- 2 files changed, 40 insertions(+), 39 deletions(-) diff --git a/test/fork/dao.test.js b/test/fork/dao.test.js index a1ed1d6..6c1b521 100644 --- a/test/fork/dao.test.js +++ b/test/fork/dao.test.js @@ -8,6 +8,7 @@ const DaoPntAbi = require('../../lib/abi/daoPNT.json') const ERC20VaultAbi = require('../../lib/abi/ERC20Vault.json') const EthPntAbi = require('../../lib/abi/ethPNT.json') const FinanceAbi = require('../../lib/abi/Finance.json') +const pntOnPolygonAbi = require('../../lib/abi/PNTonPolygon.json') const VaultAbi = require('../../lib/abi/Vault.json') const { ADDRESSES: { @@ -26,7 +27,8 @@ const { FINANCE_VAULT, FINANCE, DAOPNT_ON_GNOSIS_ADDRESS, - PNT_ON_GNOSIS_MINTER + PNT_ON_GNOSIS_MINTER, + FORWARDER_ON_GNOSIS }, MAINNET: { ERC20_VAULT, @@ -36,6 +38,7 @@ const { PNETWORK_ADDRESS, ASSOCIATION_ON_ETH_ADDRESS }, + POLYGON: { PNT_ON_POLYGON_ADDRESS, FORWARDER_ON_POLYGON }, ZERO_ADDRESS }, MISC: { ONE_DAY }, @@ -688,3 +691,38 @@ describe('Integration tests on Ethereum deployment', () => { .withArgs(attacker.address) }) }) + +describe('Integration tests on Polygon deployment', () => { + beforeEach(async () => { + const rpc = config.networks.polygon.url + await hardhatReset(network.provider, rpc) + }) + + it('should call forwarder for staking', async () => { + const [owner] = await ethers.getSigners() + const daoRoot = await ethers.getImpersonatedSigner('0xdDb5f4535123DAa5aE343c24006F4075aBAF5F7B') + await sendEth(ethers, owner, daoRoot.address, '100') + await ethers.provider.getBalance('0xdDb5f4535123DAa5aE343c24006F4075aBAF5F7B') + const forwarder = await ethers.getContractAt('IForwarder', FORWARDER_ON_POLYGON) + const pToken = await ethers.getContractAt(pntOnPolygonAbi, PNT_ON_POLYGON_ADDRESS) + await expect( + forwarder.connect(daoRoot).call( + '100000000000000000', + FORWARDER_ON_GNOSIS, + // secretlint-disable-next-line + '0x000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000259461eed4d76d4f0f900f9035f6c4dfb39159a000000000000000000000000dee8ebe2b7152eccd935fd67134bf1bad55302bc0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000044095ea7b3000000000000000000000000dee8ebe2b7152eccd935fd67134bf1bad55302bc0000000000000000000000000000000000000000000000000162ea854d0fc0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000642b54f551000000000000000000000000ddb5f4535123daa5ae343c24006f4075abaf5f7b0000000000000000000000000000000000000000000000000162ea854d0fc0000000000000000000000000000000000000000000000000000000000000093a8000000000000000000000000000000000000000000000000000000000', + PNETWORK_NETWORK_IDS.GNOSIS + ) + ) + .to.emit(pToken, 'Redeem') + .withArgs( + forwarder.target, + 100000000000000000n, + FORWARDER_ON_GNOSIS.toLowerCase().slice(2), + // secretlint-disable-next-line + '0x0000000000000000000000000000000000000000000000000000000000000040000000000000000000000000ddb5f4535123daa5ae343c24006f4075abaf5f7b0000000000000000000000000000000000000000000000000000000000000220000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000259461eed4d76d4f0f900f9035f6c4dfb39159a000000000000000000000000dee8ebe2b7152eccd935fd67134bf1bad55302bc0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000044095ea7b3000000000000000000000000dee8ebe2b7152eccd935fd67134bf1bad55302bc0000000000000000000000000000000000000000000000000162ea854d0fc0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000642b54f551000000000000000000000000ddb5f4535123daa5ae343c24006f4075abaf5f7b0000000000000000000000000000000000000000000000000162ea854d0fc0000000000000000000000000000000000000000000000000000000000000093a8000000000000000000000000000000000000000000000000000000000', + '0x00000000', + PNETWORK_NETWORK_IDS.GNOSIS + ) + }) +}) diff --git a/test/fork/forwarders.test.js b/test/fork/forwarders.test.js index a6a7a77..5e6c5b6 100644 --- a/test/fork/forwarders.test.js +++ b/test/fork/forwarders.test.js @@ -2,7 +2,6 @@ const { expect } = require('chai') const { config, ethers, network } = require('hardhat') const pntOnGnosisAbi = require('../../lib/abi/PNTonGnosis.json') -const pntOnPolygonAbi = require('../../lib/abi/PNTonPolygon.json') const { ADDRESSES: { GNOSIS: { @@ -12,49 +11,13 @@ const { DAOPNT_ON_GNOSIS_ADDRESS, PNT_ON_GNOSIS_MINTER }, - POLYGON: { PNT_ON_POLYGON_ADDRESS, FORWARDER_ON_POLYGON } + POLYGON: { FORWARDER_ON_POLYGON } }, PNETWORK_NETWORK_IDS } = require('../../lib/constants') const { encodeMetadata } = require('../../lib/metadata') const { hardhatReset } = require('../utils/hardhat-reset') const { mintPToken } = require('../utils/pnetwork') -const { sendEth } = require('../utils/send-eth') - -describe('Polygon Forwarder', () => { - beforeEach(async () => { - const rpc = config.networks.polygon.url - await hardhatReset(network.provider, rpc) - }) - - it('should call forwarder for staking', async () => { - const [owner] = await ethers.getSigners() - const daoRoot = await ethers.getImpersonatedSigner('0xdDb5f4535123DAa5aE343c24006F4075aBAF5F7B') - await sendEth(ethers, owner, daoRoot.address, '100') - await ethers.provider.getBalance('0xdDb5f4535123DAa5aE343c24006F4075aBAF5F7B') - const forwarder = await ethers.getContractAt('IForwarder', FORWARDER_ON_POLYGON) - const pToken = await ethers.getContractAt(pntOnPolygonAbi, PNT_ON_POLYGON_ADDRESS) - await expect( - forwarder.connect(daoRoot).call( - '100000000000000000', - FORWARDER_ON_GNOSIS, - // secretlint-disable-next-line - '0x000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000259461eed4d76d4f0f900f9035f6c4dfb39159a000000000000000000000000dee8ebe2b7152eccd935fd67134bf1bad55302bc0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000044095ea7b3000000000000000000000000dee8ebe2b7152eccd935fd67134bf1bad55302bc0000000000000000000000000000000000000000000000000162ea854d0fc0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000642b54f551000000000000000000000000ddb5f4535123daa5ae343c24006f4075abaf5f7b0000000000000000000000000000000000000000000000000162ea854d0fc0000000000000000000000000000000000000000000000000000000000000093a8000000000000000000000000000000000000000000000000000000000', - PNETWORK_NETWORK_IDS.GNOSIS - ) - ) - .to.emit(pToken, 'Redeem') - .withArgs( - forwarder.target, - 100000000000000000n, - FORWARDER_ON_GNOSIS.toLowerCase().slice(2), - // secretlint-disable-next-line - '0x0000000000000000000000000000000000000000000000000000000000000040000000000000000000000000ddb5f4535123daa5ae343c24006f4075abaf5f7b0000000000000000000000000000000000000000000000000000000000000220000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000020000000000000000000000000259461eed4d76d4f0f900f9035f6c4dfb39159a000000000000000000000000dee8ebe2b7152eccd935fd67134bf1bad55302bc0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000044095ea7b3000000000000000000000000dee8ebe2b7152eccd935fd67134bf1bad55302bc0000000000000000000000000000000000000000000000000162ea854d0fc0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000642b54f551000000000000000000000000ddb5f4535123daa5ae343c24006f4075abaf5f7b0000000000000000000000000000000000000000000000000162ea854d0fc0000000000000000000000000000000000000000000000000000000000000093a8000000000000000000000000000000000000000000000000000000000', - '0x00000000', - PNETWORK_NETWORK_IDS.GNOSIS - ) - }) -}) describe('Gnosis Forwarder', () => { let pToken, daoPNT, minter