Skip to content

Commit

Permalink
More assertions!
Browse files Browse the repository at this point in the history
  • Loading branch information
davidlucid committed May 1, 2022
1 parent dc52214 commit 7aa950a
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions hardhat/test/fix-accounting.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,18 @@ describe("CEtherDelegateTempExploitAccounting", function () {
// Get attacker's initial balances
var cEther = CEtherDelegate.attach("0xbB025D470162CC5eA24daF7d4566064EE7f5F111");
var exchangeRateStored = await cEther.exchangeRateStored();
var account1UnderlyingSupplyBalanceInitial = (await cEther.balanceOf("0x32075bAd9050d4767018084F0Cb87b3182D36C45")).mul(exchangeRateStored).div(ethers.utils.parseEther("1"));
var account1SupplySharesInitial = await cEther.balanceOf("0x32075bAd9050d4767018084F0Cb87b3182D36C45");
var account1UnderlyingSupplyBalanceInitial = account1SupplySharesInitial.mul(exchangeRateStored).div(ethers.utils.parseEther("1"));
var account1UnderlyingBorrowBalanceInitial = await cEther.borrowBalanceStored("0x32075bAd9050d4767018084F0Cb87b3182D36C45");
var account2UnderlyingSupplyBalanceInitial = (await cEther.balanceOf("0x3686657208883d016971c7395edaed73c107383e")).mul(exchangeRateStored).div(ethers.utils.parseEther("1"));
var account2UnderlyingBorrowBalanceInitial = await cEther.borrowBalanceStored("0x3686657208883d016971c7395edaed73c107383e");
expect(account1UnderlyingSupplyBalanceInitial).to.be.above(0);
expect(account1UnderlyingBorrowBalanceInitial).to.equal(0);
expect(account2UnderlyingSupplyBalanceInitial).to.equal(0);
expect(account2UnderlyingBorrowBalanceInitial).to.be.above(0);

var totalSupplyInitial = await cEther.totalSupply();
var totalBorrowsInitial = await cEther.totalBorrows();

// Call CEther._setImplementationSafe for temp impl
var secondaryExploiterAddresses = ["0x3686657208883d016971c7395edaed73c107383e"];
var becomeImplData = ethers.utils.defaultAbiCoder.encode(["address[]"], [secondaryExploiterAddresses]);
Expand All @@ -67,5 +70,9 @@ describe("CEtherDelegateTempExploitAccounting", function () {
expect(account1UnderlyingBorrowBalanceFinal).to.equal(account2UnderlyingBorrowBalanceInitial.sub(account1UnderlyingSupplyBalanceInitial));
expect(account2UnderlyingSupplyBalanceFinal).to.equal(0);
expect(account2UnderlyingBorrowBalanceFinal).to.equal(0);
var totalSupplyFinal = await cEther.totalSupply();
var totalBorrowsFinal = await cEther.totalBorrows();
expect(totalSupplyFinal).to.equal(totalSupplyInitial.sub(account1SupplySharesInitial));
expect(totalBorrowsFinal).to.equal(totalBorrowsInitial.sub(account1UnderlyingSupplyBalanceInitial));
});
});

0 comments on commit 7aa950a

Please sign in to comment.