Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor fork tests #38

Merged
merged 2 commits into from
Feb 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 40 additions & 8 deletions 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 All @@ -48,7 +51,7 @@ const { hardhatReset } = require('../utils/hardhat-reset')
const { mintPToken, pegoutToken } = require('../utils/pnetwork')
const { sendEth } = require('../utils/send-eth')

const { CHANGE_TOKEN_ROLE, CREATE_VOTES_ROLE, CREATE_PAYMENTS_ROLE } = getAllRoles(ethers)
const { CREATE_VOTES_ROLE, CREATE_PAYMENTS_ROLE } = getAllRoles(ethers)

const USER_ADDRESS = '0xdDb5f4535123DAa5aE343c24006F4075aBAF5F7B'
const ADDRESS_PLACEHOLDER = '0x0123456789012345678901234567890123456789'
Expand Down Expand Up @@ -156,12 +159,6 @@ describe('Integration tests on Gnosis deployment', () => {
const missingSteps = async () => {
const MockPToken = await ethers.getContractFactory('MockPTokenERC20')
pntOnGnosis = await MockPToken.deploy('Host Token (pToken)', 'HTKN', pntMinter.address, PNETWORK_NETWORK_IDS.GNOSIS)
await stakingManager.connect(daoOwner).grantRole(CHANGE_TOKEN_ROLE, SAFE_ADDRESS)
await stakingManagerLm.connect(daoOwner).grantRole(CHANGE_TOKEN_ROLE, SAFE_ADDRESS)
await stakingManagerRm.connect(daoOwner).grantRole(CHANGE_TOKEN_ROLE, SAFE_ADDRESS)
await lendingManager.connect(daoOwner).grantRole(CHANGE_TOKEN_ROLE, SAFE_ADDRESS)
await registrationManager.connect(daoOwner).grantRole(CHANGE_TOKEN_ROLE, SAFE_ADDRESS)
await rewardsManager.connect(daoOwner).grantRole(CHANGE_TOKEN_ROLE, SAFE_ADDRESS)
await stakingManager.connect(daoOwner).changeToken(pntOnGnosis.target)
await stakingManagerLm.connect(daoOwner).changeToken(pntOnGnosis.target)
await stakingManagerRm.connect(daoOwner).changeToken(pntOnGnosis.target)
Expand Down Expand Up @@ -694,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