Skip to content

Commit

Permalink
test(fork): add integration test for staking migration
Browse files Browse the repository at this point in the history
  • Loading branch information
oliviera9 committed Mar 14, 2024
1 parent 2525751 commit 2142f64
Showing 1 changed file with 58 additions and 0 deletions.
58 changes: 58 additions & 0 deletions test/fork/dao.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const {
PNETWORK,
ASSOCIATION,
FINANCE_VAULT: FINANCE_VAULT_V1,
FORWARDER_PNT: FORWARDER_ON_MAINNET_PNT,
FORWARDER_ETHPNT: FORWARDER_ON_MAINNET_ETHPNT,
PBTC: PBTC_ON_ETHEREUM,
PBTC_MINTER,
Expand Down Expand Up @@ -82,6 +83,9 @@ const WITHDRAW_INFLATION_FROM_GNOSIS_USER_DATA_3 =
const DEPOSIT_REWARDS_USER_DATA =
// secretlint-disable-next-line
'0x00000000000000000000000000000000000000000000000000000000000000400000000000000000000000002211bfd97b1c02ae8ac305d206e9780ba7d8bff40000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000020000000000000000000000008805aa0c1a8e59b03fa95740f691e28942cf44f60000000000000000000000002ec44f9f31a55b52b3c1ff98647e38d63f829fb70000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000044095ea7b30000000000000000000000002ec44f9f31a55b52b3c1ff98647e38d63f829fb70000000000000000000000000000000000000000000000000000000000000063000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000044dc5e3ccd0000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000006300000000000000000000000000000000000000000000000000000000'
const MIGRATE_USER_DATA =
// secretlint-disable-next-line
'0x0000000000000000000000000000000000000000000000000000000000000040000000000000000000000000c4442915b1fb44972ee4d8404ce05a8d2a1248da0000000000000000000000000000000000000000000000000000000000000220000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000020000000000000000000000008805aa0c1a8e59b03fa95740f691e28942cf44f6000000000000000000000000dee8ebe2b7152eccd935fd67134bf1bad55302bc0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000044095ea7b3000000000000000000000000dee8ebe2b7152eccd935fd67134bf1bad55302bc0000000000000000000000000000000000000000000000056a6418b5058600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000642b54f551000000000000000000000000c4442915b1fb44972ee4d8404ce05a8d2a1248da0000000000000000000000000000000000000000000000056a6418b5058600000000000000000000000000000000000000000000000000000000000000093a8000000000000000000000000000000000000000000000000000000000'

const getBytes = (_hexString) => Buffer.from(_hexString.slice(2), 'hex')

Expand Down Expand Up @@ -844,6 +848,29 @@ describe('Integration tests on Gnosis deployment', () => {
expect(await rewardsManager.depositedAmountByEpoch(4)).to.be.eq(99n + depositedAmount)
})

it('[dapp] should stake from forwarder call (migration)', async () => {
const amount = ethers.parseUnits('99.9')
const staker = tokenHolders[0]
const stakedAmount = await daoPNT.balanceOf(tokenHolders[0])
expect(await pntOnGnosis.balanceOf(staker.address)).to.be.eq(5000)
const smBalance = await pntOnGnosis.balanceOf(STAKING_MANAGER)
const metadata = encodeMetadata(ethers, {
userData: MIGRATE_USER_DATA,
sourceNetworkId: PNETWORK_NETWORK_IDS.MAINNET,
senderAddress: FORWARDER_ON_MAINNET_PNT,
destinationNetworkId: PNETWORK_NETWORK_IDS.GNOSIS,
receiverAddress: forwarder.target
})
await expect(mintPToken(pntOnGnosis, pntMinter, forwarder.target, amount, metadata))
.to.emit(pntOnGnosis, 'Transfer')
.withArgs(FORWARDER_ON_GNOSIS, STAKING_MANAGER, amount)
.and.to.emit(stakingManager, 'Staked')
.withArgs(staker, amount, ONE_DAY * 7)
expect(await pntOnGnosis.balanceOf(staker.address)).to.be.eq(5000)
expect(await daoPNT.balanceOf(staker)).to.be.eq(amount + stakedAmount)
expect(await pntOnGnosis.balanceOf(STAKING_MANAGER)).to.be.eq(smBalance + amount)
})

it('[dapp] should delegateVote from forwarder call', async () => {
const stakedAmount = ethers.parseUnits('10')
await mintPntOnGnosis(user.address, stakedAmount)
Expand Down Expand Up @@ -1205,6 +1232,37 @@ describe('Integration tests on Ethereum deployment', () => {
)
})

it('[dappv1] should migrate stake to DAO v3', async () => {
const staker = tokenHolders[1]
await staker.sendTransaction({
to: '0xeb10e80D99655B51E3a981E888a73D0B21e21A6C',
// secretlint-disable-next-line
data: '0x2e17de780000000000000000000000000000000000000000000000056bc75e2d63100000'
})
await staker.sendTransaction({
to: '0x89ab32156e46f46d02ade3fecbe5fc4243b9aaed',
// secretlint-disable-next-line
data: '0x095ea7b3000000000000000000000000e2cb2c8fdc086fc576b49acf2f71d44dde7e38040000000000000000000000000000000000000000000000056bc75e2d63100000'
})
await expect(
staker.sendTransaction({
to: '0xe2cb2C8fDc086FC576b49aCF2F71D44DDe7e3804',
// secretlint-disable-next-line
data: '0x996adf550000000000000000000000000000000000000000000000056bc75e2d631000000000000000000000000000002422eb5b6a20c7b8e3567c12ed6f5ed9d1cf1f79000000000000000000000000000000000000000000000000000000000000008000f1918e000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000220000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000020000000000000000000000008805aa0c1a8e59b03fa95740f691e28942cf44f6000000000000000000000000dee8ebe2b7152eccd935fd67134bf1bad55302bc0000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000044095ea7b3000000000000000000000000dee8ebe2b7152eccd935fd67134bf1bad55302bc0000000000000000000000000000000000000000000000056a6418b5058600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000642b54f551000000000000000000000000c4442915b1fb44972ee4d8404ce05a8d2a1248da0000000000000000000000000000000000000000000000056a6418b5058600000000000000000000000000000000000000000000000000000000000000093a8000000000000000000000000000000000000000000000000000000000'
})
)
.to.emit(vault, 'PegIn')
.withArgs(
PNT_ON_ETH,
FORWARDER_ON_MAINNET_PNT,
ethers.parseUnits('100'),
FORWARDER_ON_GNOSIS.slice(2).toLocaleLowerCase(),
MIGRATE_USER_DATA,
PNETWORK_NETWORK_IDS.MAINNET,
PNETWORK_NETWORK_IDS.GNOSIS
)
})

it('[dapp] should open a vote for depositing rewards', async () => {
expect(await ethPnt.inflationOwner()).to.be.eq(crossExecutor.target)
const INFLATION_OWNER_SLOT = '0x131' // 305 (found brute forcing eth_getStorageAt())
Expand Down

0 comments on commit 2142f64

Please sign in to comment.