Skip to content

Commit

Permalink
add new test
Browse files Browse the repository at this point in the history
  • Loading branch information
olga24912 committed Jul 23, 2024
1 parent ca3fbd7 commit 165bd0d
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions eth-custodian/test/EthCustodianProxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const { ethers, upgrades } = require("hardhat");
const { expect } = require('chai');
const { serialize } = require('rainbow-bridge-lib/rainbow/borsh.js');
const { borshifyOutcomeProof } = require('rainbow-bridge-lib/rainbow/borshify-proof.js');
const proof = require("./proof_template_from_testnet.json");

const UNPAUSED_ALL = 0;
const PAUSED_DEPOSIT_TO_EVM = 1 << 0;
Expand Down Expand Up @@ -246,6 +247,22 @@ describe('EthCustodianProxy contract', () => {
expect(balanceDiff).to.equal(amount)
});

it('Should successfully withdraw and emit the event pre-migration with post-migration block height', async () => {
await ethCustodianProxy.migrateToNewProofProducer(newProofProducerData, blockHeightFromProof + 1);
const balanceBefore = ethers.BigNumber.from(await ethers.provider.getBalance(user2.address));

await expect(
ethCustodianProxy.withdraw(borshifyOutcomeProof(proof), blockHeightFromProof + 2)
)
.to.emit(ethCustodian, 'Withdrawn')
.withArgs(user2.address, amount);

const balanceAfter = ethers.BigNumber.from(await ethers.provider.getBalance(user2.address));
const balanceDiff = balanceAfter.sub(balanceBefore);

expect(balanceDiff).to.equal(amount)
});

it('Should successfully withdraw and emit the event pre-migration', async () => {
await ethCustodianProxy.migrateToNewProofProducer(newProofProducerData, blockHeightFromProof + 1);
const balanceBefore = BigInt(await ethers.provider.getBalance(user2.address));
Expand Down

0 comments on commit 165bd0d

Please sign in to comment.