From 165bd0d11d7d950169dc09a0acac6a9fbdcdbf66 Mon Sep 17 00:00:00 2001 From: Olga Kunyavskaya Date: Tue, 23 Jul 2024 15:57:05 +0300 Subject: [PATCH] add new test --- eth-custodian/test/EthCustodianProxy.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/eth-custodian/test/EthCustodianProxy.js b/eth-custodian/test/EthCustodianProxy.js index e48cdf0..c6ab327 100644 --- a/eth-custodian/test/EthCustodianProxy.js +++ b/eth-custodian/test/EthCustodianProxy.js @@ -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; @@ -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));