Skip to content

Commit

Permalink
test(fork): move Polygon forwarder test into dao.test.js
Browse files Browse the repository at this point in the history
  • Loading branch information
oliviera9 committed Feb 27, 2024
1 parent c40b1af commit 42fc6cb
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 39 deletions.
40 changes: 39 additions & 1 deletion test/fork/dao.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand All @@ -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,
Expand All @@ -36,6 +38,7 @@ const {
PNETWORK_ADDRESS,
ASSOCIATION_ON_ETH_ADDRESS
},
POLYGON: { PNT_ON_POLYGON_ADDRESS, FORWARDER_ON_POLYGON },
ZERO_ADDRESS
},
MISC: { ONE_DAY },
Expand Down Expand Up @@ -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
)
})
})
39 changes: 1 addition & 38 deletions test/fork/forwarders.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand All @@ -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
Expand Down

0 comments on commit 42fc6cb

Please sign in to comment.