Skip to content

Commit

Permalink
fix plugin tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tbrent committed Aug 19, 2023
1 parent 550dd24 commit fc32a85
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 24 deletions.
3 changes: 0 additions & 3 deletions contracts/p1/Broker.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ import "./mixins/Component.sol";
import "../plugins/trading/DutchTrade.sol";
import "../plugins/trading/GnosisTrade.sol";

import "hardhat/console.sol";

// Gnosis: uint96 ~= 7e28
uint256 constant GNOSIS_MAX_TOKENS = 7e28;

Expand Down Expand Up @@ -284,7 +282,6 @@ contract BrokerP1 is ComponentP1, IBroker {

/// @return true if the price is current, or it's the RTokenAsset
function priceIsCurrent(IAsset asset) private view returns (bool) {
console.log(asset.lastSave(), block.timestamp);
return asset.lastSave() == block.timestamp || address(asset.erc20()) == address(rToken);
}

Expand Down
5 changes: 0 additions & 5 deletions contracts/plugins/assets/AppreciatingFiatCollateral.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ import "./FiatCollateral.sol";
import "./Asset.sol";
import "./OracleLib.sol";

import "hardhat/console.sol";

/**
* @title AppreciatingFiatCollateral
* Collateral that may need revenue hiding to become truly "up only"
Expand Down Expand Up @@ -112,9 +110,7 @@ abstract contract AppreciatingFiatCollateral is FiatCollateral {
savedLowPrice = low;
savedHighPrice = high;
lastSave = uint48(block.timestamp);
console.log("set lastSave", lastSave);
} else {
console.log("else");
// must be unpriced
assert(low == 0);
}
Expand All @@ -127,7 +123,6 @@ abstract contract AppreciatingFiatCollateral is FiatCollateral {
markStatus(CollateralStatus.SOUND);
}
} catch (bytes memory errData) {
console.log("err");
// see: docs/solidity-style.md#Catching-Empty-Data
if (errData.length == 0) revert(); // solhint-disable-line reason-string
markStatus(CollateralStatus.IFFY);
Expand Down
5 changes: 0 additions & 5 deletions contracts/plugins/assets/FiatCollateral.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import "../../libraries/Fixed.sol";
import "./Asset.sol";
import "./OracleLib.sol";

import "hardhat/console.sol";

uint48 constant MAX_DELAY_UNTIL_DEFAULT = 1209600; // {s} 2 weeks

struct CollateralConfig {
Expand Down Expand Up @@ -135,9 +133,7 @@ contract FiatCollateral is ICollateral, Asset {
savedLowPrice = low;
savedHighPrice = high;
lastSave = uint48(block.timestamp);
console.log("lastSave", lastSave);
} else {
console.log("else");
// must be unpriced
assert(low == 0);
}
Expand All @@ -150,7 +146,6 @@ contract FiatCollateral is ICollateral, Asset {
markStatus(CollateralStatus.SOUND);
}
} catch (bytes memory errData) {
console.log("err");
// see: docs/solidity-style.md#Catching-Empty-Data
if (errData.length == 0) revert(); // solhint-disable-line reason-string
markStatus(CollateralStatus.IFFY);
Expand Down
2 changes: 0 additions & 2 deletions test/Recollateralization.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5175,9 +5175,7 @@ describe(`Recollateralization - P${IMPLEMENTATION}`, () => {
// Run auctions - First Settle trades then Manage Funds
// Will sell all balance of token2
await expect(backingManager.settleTrade(token2.address)).to.be.revertedWith('no trade open')
console.log('before')
await snapshotGasCost(backingManager.rebalance(TradeKind.DUTCH_AUCTION))
console.log('after')
expect(await backingManager.tradesOpen()).to.equal(1)

// Another call should not create any new auctions if still ongoing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -658,10 +658,14 @@ describeFork(`ATokenFiatCollateral - Mainnet Forking P${IMPLEMENTATION}`, functi
describe('Price Handling', () => {
it('Should handle invalid/stale Price', async () => {
// Does not revert with stale price
await advanceTime(ORACLE_TIMEOUT.toString())

// stkAAVEound
await expectUnpriced(aDaiCollateral.address)
await advanceTime(ORACLE_TIMEOUT.sub(12).toString())

// Price is at saved prices
const savedLowPrice = await aDaiCollateral.savedLowPrice()
const savedHighPrice = await aDaiCollateral.savedHighPrice()
const p = await aDaiCollateral.price()
expect(p[0]).to.equal(savedLowPrice)
expect(p[1]).to.equal(savedHighPrice)

// Refresh should mark status IFFY
await aDaiCollateral.refresh()
Expand Down
2 changes: 1 addition & 1 deletion test/plugins/individual-collateral/collateralTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -346,10 +346,10 @@ export default function fn<X extends CollateralFixtureContext>(
})

it('decays price over priceTimeout period', async () => {
await collateral.refresh()
const savedLow = await collateral.savedLowPrice()
const savedHigh = await collateral.savedHighPrice()
// Price should start out at saved prices
await collateral.refresh()
let p = await collateral.price()
expect(p[0]).to.equal(savedLow)
expect(p[1]).to.equal(savedHigh)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -671,10 +671,14 @@ describeFork(`CTokenFiatCollateral - Mainnet Forking P${IMPLEMENTATION}`, functi
describe('Price Handling', () => {
it('Should handle invalid/stale Price', async () => {
// Does not revert with stale price
await advanceTime(ORACLE_TIMEOUT.toString())

// Compound
await expectUnpriced(cDaiCollateral.address)
await advanceTime(ORACLE_TIMEOUT.sub(12).toString())

// Price is at saved prices
const savedLowPrice = await cDaiCollateral.savedLowPrice()
const savedHighPrice = await cDaiCollateral.savedHighPrice()
const p = await cDaiCollateral.price()
expect(p[0]).to.equal(savedLowPrice)
expect(p[1]).to.equal(savedHighPrice)

// Refresh should mark status IFFY
await cDaiCollateral.refresh()
Expand Down

0 comments on commit fc32a85

Please sign in to comment.