Skip to content

Commit

Permalink
test(fork): add integration test for depositing rewards
Browse files Browse the repository at this point in the history
  • Loading branch information
oliviera9 committed Mar 14, 2024
1 parent e07f37b commit ad7f33c
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 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_ETHPNT: FORWARDER_ON_MAINNET_ETHPNT,
PBTC: PBTC_ON_ETHEREUM,
PBTC_MINTER,
CROSS_EXECUTOR,
Expand Down Expand Up @@ -78,6 +79,9 @@ const WITHDRAW_INFLATION_FROM_GNOSIS_USER_DATA =
const WITHDRAW_INFLATION_FROM_GNOSIS_USER_DATA_3 =
// secretlint-disable-next-line
'0x00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000cf759bccfef5f322af58adae2d28885658b5e0200000000000000000000000000000000000000000000000000000000000003a0000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000003000000000000000000000000f4ea6b892853413bd9d9f1a5d3a620a0ba39c5b2000000000000000000000000f4ea6b892853413bd9d9f1a5d3a620a0ba39c5b2000000000000000000000000e396757ec7e6ac7c8e5abe7285dde47b98f22db80000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000e0000000000000000000000000000000000000000000000000000000000000016000000000000000000000000000000000000000000000000000000000000000443352d49b0000000000000000000000006a4bd6de0de7b80f24a307f31b40856da975b5a70000000000000000000000000000000000000000000000056bc75e2d63100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000044095ea7b3000000000000000000000000e396757ec7e6ac7c8e5abe7285dde47b98f22db80000000000000000000000000000000000000000000000056bc75e2d63100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000124c322525d0000000000000000000000000000000000000000000000056bc75e2d63100000000000000000000000000000f4ea6b892853413bd9d9f1a5d3a620a0ba39c5b200000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000010000f1918e00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002a30786631663635363861373635353964383563463638453635393766413538373534343138346444343600000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'
const DEPOSIT_REWARDS_USER_DATA =
// secretlint-disable-next-line
'0x00000000000000000000000000000000000000000000000000000000000000400000000000000000000000002211bfd97b1c02ae8ac305d206e9780ba7d8bff40000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000020000000000000000000000008805aa0c1a8e59b03fa95740f691e28942cf44f60000000000000000000000002ec44f9f31a55b52b3c1ff98647e38d63f829fb70000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000044095ea7b30000000000000000000000002ec44f9f31a55b52b3c1ff98647e38d63f829fb70000000000000000000000000000000000000000000000000000000000000063000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000044dc5e3ccd0000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000006300000000000000000000000000000000000000000000000000000000'

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

Expand Down Expand Up @@ -825,6 +829,21 @@ describe('Integration tests on Gnosis deployment', () => {
)
})

it('[dapp] should deposit rewards from forwarder call (1)', async () => {
const depositedAmount = await rewardsManager.depositedAmountByEpoch(4)
const metadata = encodeMetadata(ethers, {
userData: DEPOSIT_REWARDS_USER_DATA,
sourceNetworkId: PNETWORK_NETWORK_IDS.MAINNET,
senderAddress: FORWARDER_ON_MAINNET_ETHPNT,
destinationNetworkId: PNETWORK_NETWORK_IDS.GNOSIS,
receiverAddress: forwarder.target
})
await expect(mintPToken(pntOnGnosis, pntMinter, forwarder.target, 99n, metadata))
.to.emit(pntOnGnosis, 'Transfer')
.withArgs(FORWARDER_ON_GNOSIS, REWARDS_MANAGER, 99)
expect(await rewardsManager.depositedAmountByEpoch(4)).to.be.eq(99n + depositedAmount)
})

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

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())
await ethers.provider.send('hardhat_setStorageAt', [
ethPnt.target,
INFLATION_OWNER_SLOT,
ethers.zeroPadValue(daoVotingV1.target, 32)
])
expect(await ethPnt.inflationOwner()).to.be.eq(daoVotingV1.target)
await daoVotingV1.connect(association).newVote(
// secretlint-disable-next-line
'0x00000001f4ea6b892853413bd9d9f1a5d3a620a0ba39c5b2000000443352d49b000000000000000000000000dd92eb1478d3189707ab7f4a5ace3a615cdd04760000000000000000000000000000000000000000000000056bc75e2d63100000dd92eb1478d3189707ab7f4a5ace3a615cdd047600000064beabacc8000000000000000000000000f4ea6b892853413bd9d9f1a5d3a620a0ba39c5b20000000000000000000000002211bfd97b1c02ae8ac305d206e9780ba7d8bff40000000000000000000000000000000000000000000000056bc75e2d63100000f4ea6b892853413bd9d9f1a5d3a620a0ba39c5b200000044095ea7b3000000000000000000000000d60792770ca2b54b9231041c8af641f48818da8d0000000000000000000000000000000000000000000000056bc75e2d63100000d60792770ca2b54b9231041c8af641f48818da8d000002a4996adf5500000000000000000000000000000000000000000000000000000000000000640000000000000000000000002422eb5b6a20c7b8e3567c12ed6f5ed9d1cf1f79000000000000000000000000000000000000000000000000000000000000008000f1918e000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000020000000000000000000000008805aa0c1a8e59b03fa95740f691e28942cf44f60000000000000000000000002ec44f9f31a55b52b3c1ff98647e38d63f829fb70000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000044095ea7b30000000000000000000000002ec44f9f31a55b52b3c1ff98647e38d63f829fb70000000000000000000000000000000000000000000000000000000000000063000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000044dc5e3ccd0000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000006300000000000000000000000000000000000000000000000000000000',
'shall we deposit rewards?',
false
)
const voteId = await daoVotingV1.votesLength()
await Promise.all(tokenHolders.map((_holder) => daoVotingV1.connect(_holder).vote(voteId, true)))
const vote = await daoVotingV1.getVote(voteId)
await mineUpTo(vote[3] + 1n)
await expect(daoVotingV1.connect(association).executeVote(voteId))
.to.emit(daoVotingV1, 'ExecuteVote')
.withArgs(voteId)
.and.to.emit(ethPnt, 'Transfer')
.withArgs(FORWARDER_ON_MAINNET_ETHPNT, vault.target, 100)
.and.to.emit(vault, 'PegIn')
.withArgs(
PNT_ON_ETH,
FORWARDER_ON_MAINNET_ETHPNT,
100,
FORWARDER_ON_GNOSIS.slice(2).toLowerCase(),
DEPOSIT_REWARDS_USER_DATA,
PNETWORK_NETWORK_IDS.MAINNET,
PNETWORK_NETWORK_IDS.GNOSIS
)
})

// pBTC is not native! so the execution script should not peg-in
it.skip('[dapp] should open a vote for migrating pBTC treasury funds (4)', async () => {
const amount = ethers.parseEther('100')
Expand Down

0 comments on commit ad7f33c

Please sign in to comment.