Skip to content

Commit

Permalink
tests/: fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bun919tw committed Jan 27, 2021
1 parent 4152ba4 commit 30cd8ed
Show file tree
Hide file tree
Showing 23 changed files with 83 additions and 47 deletions.
24 changes: 24 additions & 0 deletions scenario/src/Builder/CTokenDelegateBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const CDaiDelegateContract = getContract('CDaiDelegate');
const CDaiDelegateScenarioContract = getTestContract('CDaiDelegateScenario');
const CErc20DelegateContract = getContract('CErc20Delegate');
const CErc20DelegateScenarioContract = getTestContract('CErc20DelegateScenario');
const CCapableErc20DelegateContract = getContract('CCapableErc20Delegate');


export interface CTokenDelegateData {
Expand Down Expand Up @@ -122,6 +123,29 @@ export async function buildCTokenDelegate(
description: 'Scenario CErc20 Delegate'
};
}
),

new Fetcher<{ name: StringV; }, CTokenDelegateData>(
`
#### CCapableErc20Delegate
* "CCapableErc20Delegate name:<String>"
* E.g. "CTokenDelegate Deploy CCapableErc20Delegate cLinkDelegate"
`,
'CCapableErc20Delegate',
[
new Arg('name', getStringV),
],
async (
world,
{ name }
) => {
return {
invokation: await CCapableErc20DelegateContract.deploy<CErc20Delegate>(world, from, []),
name: name.val,
contract: 'CCapableErc20Delegate',
description: 'Capable CErc20 Delegate'
};
}
)
];

Expand Down
8 changes: 4 additions & 4 deletions spec/scenario/Borrow.scen
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Test "Borrow some BAT and enters BAT if BAT not entered"
NewComptroller price:1.0
NewCToken ZRX cZRX
NewCToken BAT cBAT
GiveCToken cBAT 10e18 BAT -- Faucet some bat to borrow
Give cBAT 10e18 BAT -- Faucet some bat to borrow
Support cZRX collateralFactor:0.5
Support cBAT collateralFactor:0.5
Prep Geoff Some ZRX cZRX
Expand Down Expand Up @@ -53,7 +53,7 @@ Test "Borrow fails if market not listed"
NewComptroller price:1.0
NewCToken ZRX cZRX
NewCToken BAT cBAT
GiveCToken cBAT 10e18 BAT -- Faucet some bat to borrow
Give cBAT 10e18 BAT -- Faucet some bat to borrow
Support cZRX collateralFactor:0.5
Prep Geoff Some ZRX cZRX
Mint Geoff 100e18 cZRX
Expand All @@ -67,7 +67,7 @@ Test "Borrow some BAT from Excess Cash"
NewComptroller price:1.0
NewCToken ZRX cZRX
NewCToken BAT cBAT
GiveCToken cBAT 10e18 BAT -- Faucet some bat to borrow
Give cBAT 10e18 BAT -- Faucet some bat to borrow
Support cZRX collateralFactor:0.5
Support cBAT collateralFactor:0.5
Prep Geoff Some ZRX cZRX
Expand All @@ -83,7 +83,7 @@ Test "Borrow some BAT reverts if borrow is paused"
Comptroller SetPauseGuardian Coburn
NewCToken ZRX cZRX
NewCToken BAT cBAT
GiveCToken cBAT 10e18 BAT -- Faucet some bat to borrow
Give cBAT 10e18 BAT -- Faucet some bat to borrow
Support cZRX collateralFactor:0.5
Support cBAT collateralFactor:0.5
Prep Geoff Some ZRX cZRX
Expand Down
2 changes: 1 addition & 1 deletion spec/scenario/BorrowBalance.scen
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Macro NewBorrow borrowAmount borrowRate user=Geoff
NewComptroller price:1.0 -- TODO: This should really be a price for a specific asset
NewCToken ZRX cZRX
NewCToken BAT cBAT borrowRate -- note: cannot use macros with named args right now
GiveCToken cBAT 10e18 BAT -- Faucet some bat to borrow
Give cBAT 10e18 BAT -- Faucet some bat to borrow
Support cZRX collateralFactor:0.5
Support cBAT collateralFactor:0.5
SimpleBorrow user borrowAmount
Expand Down
10 changes: 5 additions & 5 deletions spec/scenario/BorrowCap.scen
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Test "Attempt to borrow over set cap ERC20"
NewCToken BAT cBAT
Comptroller SetMarketBorrowCaps (cBAT) (0.5e18)
Assert Equal (Comptroller BorrowCaps cBAT) (Exactly 0.5e18)
GiveCToken cBAT 10e18 BAT -- Faucet some bat to borrow
Give cBAT 10e18 BAT -- Faucet some bat to borrow
Support cZRX collateralFactor:0.5
Support cBAT collateralFactor:0.5
Prep Geoff Some ZRX cZRX
Expand All @@ -23,7 +23,7 @@ Test "Attempt to borrow at set cap ERC20"
NewCToken ZRX cZRX
NewCToken BAT cBAT
Comptroller SetMarketBorrowCaps (cBAT) (1000000000000000001)
GiveCToken cBAT 10e18 BAT -- Faucet some bat to borrow
Give cBAT 10e18 BAT -- Faucet some bat to borrow
Support cZRX collateralFactor:0.5
Support cBAT collateralFactor:0.5
Prep Geoff Some ZRX cZRX
Expand All @@ -42,7 +42,7 @@ Test "Attempt to borrow below set cap ERC20"
NewCToken ZRX cZRX
NewCToken BAT cBAT
Comptroller SetMarketBorrowCaps (cBAT) (10e18)
GiveCToken cBAT 10e18 BAT -- Faucet some bat to borrow
Give cBAT 10e18 BAT -- Faucet some bat to borrow
Support cZRX collateralFactor:0.5
Support cBAT collateralFactor:0.5
Prep Geoff Some ZRX cZRX
Expand Down Expand Up @@ -148,8 +148,8 @@ Test "SetBorrowCaps works correctly too"
Comptroller SetMarketBorrowCaps (cBAT cUSDC) (0.5e18 1000001)
Assert Equal (Comptroller BorrowCaps cBAT) (Exactly 0.5e18)
Assert Equal (Comptroller BorrowCaps cUSDC) (Exactly 1000001)
GiveCToken cBAT 10e18 BAT -- Faucet some bat to borrow
GiveCToken cUSDC 20e6 USDC
Give cBAT 10e18 BAT -- Faucet some bat to borrow
Give cUSDC 20e6 USDC
Support cZRX collateralFactor:0.5
Support cBAT collateralFactor:0.5
Support cUSDC collateralFactor:0.5
Expand Down
6 changes: 3 additions & 3 deletions spec/scenario/BorrowWBTC.scen
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Test "Borrow some WBTC enters WBTC and succeeds when not entered"
NewComptroller price:1.0
NewCToken ZRX cZRX
NewCToken WBTC cWBTC tokenType:WBTC
GiveCToken cWBTC 10e8 WBTC -- Faucet some WBTC to borrow
Give cWBTC 10e8 WBTC -- Faucet some WBTC to borrow
Support cZRX collateralFactor:0.5
Support cWBTC collateralFactor:0.5
Prep Geoff Some ZRX cZRX
Expand Down Expand Up @@ -33,7 +33,7 @@ Test "Borrow some WBTC fails when WBTC paused"
NewComptroller price:1.0
NewCToken ZRX cZRX
NewCToken WBTC cWBTC tokenType:WBTC
GiveCToken cWBTC 10e8 WBTC -- Faucet some WBTC to borrow
Give cWBTC 10e8 WBTC -- Faucet some WBTC to borrow
Support cZRX collateralFactor:0.5
Support cWBTC collateralFactor:0.5
Prep Geoff Some ZRX cZRX
Expand All @@ -50,7 +50,7 @@ Test "Borrow some WBTC from Excess Cash"
NewComptroller price:1.0
NewCToken ZRX cZRX
NewCToken WBTC cWBTC tokenType:WBTC
GiveCToken cWBTC 10e8 WBTC -- Faucet some WBTC to borrow
Give cWBTC 10e8 WBTC -- Faucet some WBTC to borrow
Support cZRX collateralFactor:0.5
Support cWBTC collateralFactor:0.5
Prep Geoff Some ZRX cZRX
Expand Down
2 changes: 1 addition & 1 deletion spec/scenario/BreakLiquidate.scen
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Macro NewBorrow borrowAmount mintAmount borrowRate=0.000005 user=Geoff collatera
Comptroller LiquidationIncentive liquidationIncentive
NewCToken ZRX cZRX
NewCToken BAT cBAT borrowRate
GiveCToken cBAT 10e18 BAT -- Faucet some bat to borrow
Give cBAT 10e18 BAT -- Faucet some bat to borrow
PriceOracle SetPrice cZRX collateralPrice
Support cZRX collateralFactor:0.7
PriceOracle SetPrice cBAT borrowPrice
Expand Down
10 changes: 5 additions & 5 deletions spec/scenario/ChangeDelegate.scen
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@ Test "Change the delegate"
CToken cDEL SetImplementation (CTokenDelegate cErc20Delegate2 Address) True "0x0"
Redeem Jared 50e9 cDEL

Test "Update the delegate for internal cash"
Test "Update the delegate from CErc20 to CCapableErc20"
NewComptroller
NewCToken ZRX cZRX
Support cZRX collateralFactor:0.5
Prep Jared Some ZRX cZRX
Mint Jared 100e18 cZRX
Give cZRX 100e18 ZRX -- Transfer 100e18 ZRX to cZRX
-- Cash: 100e18, Balance: 200e18
Assert Equal (CToken cZRX Cash) (Exactly 100e18)
-- Cash: 200e18, Balance: 200e18
Assert Equal (CToken cZRX Cash) (Exactly 200e18)
Assert Equal (Erc20 ZRX TokenBalance cZRX) (Exactly 200e18)
-- New Deleagte
CTokenDelegate Deploy CErc20Delegate cErc20Delegate2
CToken cZRX SetImplementation (CTokenDelegate cErc20Delegate2 Address) True "0x0"
CTokenDelegate Deploy CCapableErc20Delegate myCapableDelegate
CToken cZRX SetImplementation (CTokenDelegate myCapableDelegate Address) True "0x0"
-- Cash: 200e18, Balance: 200e18
Assert Equal (CToken cZRX Cash) (Exactly 200e18)
Assert Equal (Erc20 ZRX TokenBalance cZRX) (Exactly 200e18)
2 changes: 1 addition & 1 deletion spec/scenario/EnterExitMarkets.scen
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ Test "Realistic Market Scenario"
EnterMarkets Geoff cZRX
Assert Equal (Comptroller Liquidity Geoff) 1.0e18
-- Fail to borrow BAT due to liquidity
GiveCToken cBAT 1000e18 BAT
Give cBAT 1000e18 BAT
HoldInvariants
Borrow Geoff 1000e18 cBAT -- 1000e18 * 0.0015 = 1.5e18 required liquidity
-- But since we're only in ZRX, we only have 1.0e18 liquidity
Expand Down
2 changes: 0 additions & 2 deletions spec/scenario/ExchangeRate.scen
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ Test "ZRX: Exch. Rate:2e9, Cash(51e18) + Borrows(2.0e18) - Reserves(0.5e18) / To
-- Set cash
Erc20 ZRX Faucet cZRX 1.0e18
Assert Equal (Erc20 ZRX TokenBalance cZRX) (Exactly 51.0e18)
CToken cZRX Gulp
-- Mock total borrows
CToken cZRX Mock totalBorrows 2.0e18
Assert Equal (CToken cZRX TotalBorrows) (Exactly 2.0e18)
Expand All @@ -63,7 +62,6 @@ Test "USDC: Exch. Rate:2e-3, Cash(51e18) + Borrows(2.0e18) - Reserves(0.5e18) /
-- Set cash
Erc20 USDC Faucet cUSDC 2.0e6
Assert Equal (Erc20 USDC TokenBalance cUSDC) (Exactly 52.0e6)
CToken cUSDC Gulp
-- Mock total borrows
CToken cUSDC Mock totalBorrows 5.0e6
Assert Equal (CToken cUSDC TotalBorrows) (Exactly 5.0e6)
Expand Down
4 changes: 2 additions & 2 deletions spec/scenario/Fee.scen
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Test "Repay borrow should work and not change exchange rate"
PriceOracle SetPrice cUSDT 1.0
Support cZRX 0.5
Support cUSDT 0.5
GiveCToken cUSDT 10e18 USDT -- Faucet some Tether to borrow
Give cUSDT 10e18 USDT -- Faucet some Tether to borrow
Invariant Static (CToken cUSDT ExchangeRate)
Prep Torrey 100e18 ZRX cZRX
Mint Torrey 100e18 cZRX
Expand All @@ -52,7 +52,7 @@ Test "Should be able to liquidate fee token borrow"
PriceOracle SetPrice cUSDT 1.0
Support cZRX 0.5
Support cUSDT 0.5
GiveCToken cUSDT 10e18 USDT -- Faucet some Tether to borrow
Give cUSDT 10e18 USDT -- Faucet some Tether to borrow
Invariant Static (CToken cUSDT ExchangeRate)
Invariant Static (CToken cZRX ExchangeRate)
Prep Torrey 2e18 ZRX cZRX
Expand Down
2 changes: 1 addition & 1 deletion spec/scenario/InKindLiquidation.scen
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Macro InKindBorrow borrowAmount borrowRate user=Geoff borrowPrice=1.0 mintAmount
PricedComptroller
Comptroller LiquidationIncentive 1.1
NewCToken BAT cBAT borrowRate 2e9 8 borrowTokenType -- note: cannot use macros with named args right now
GiveCToken cBAT giveAmount BAT -- Faucet some bat
Give cBAT giveAmount BAT -- Faucet some bat
PriceOracle SetPrice cBAT borrowPrice
Support cBAT collateralFactor:0.5
Prep user mintAmount BAT cBAT
Expand Down
2 changes: 1 addition & 1 deletion spec/scenario/MintEth.scen
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Test "Mint with insufficient eth balance"
Invariant Remains (CToken cETH UnderlyingBalance Geoff) 0e18
Invariant Remains (Erc20 cETH TokenBalance Geoff) 0e8
Invariant Static (EtherBalance Geoff)
CallMintEth Geoff 1e30 cETH
CallMintEth Geoff 1e20 cETH
Assert Error "sender doesn't have enough funds to send tx. The upfront cost is"

Test "Mint two Eth after minting two Eth, and then I mint two more"
Expand Down
2 changes: 1 addition & 1 deletion spec/scenario/RepayBorrow.scen
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Macro NewBorrow borrowAmount borrowRate
NewComptroller price:1.0 -- TODO: This should really be a price for a specific asset
NewCToken ZRX cZRX
NewCToken BAT cBAT borrowRate -- note: cannot use macros with named args right now
GiveCToken cBAT 10e18 BAT -- Faucet some bat to borrow
Give cBAT 10e18 BAT -- Faucet some bat to borrow
Support cZRX collateralFactor:0.5
Support cBAT collateralFactor:0.5
Prep Geoff Some ZRX cZRX
Expand Down
2 changes: 1 addition & 1 deletion spec/scenario/RepayBorrowWBTC.scen
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Macro NewBorrow borrowAmount borrowRate
NewComptroller price:1.0 -- TODO: This should really be a price for a specific asset
NewCToken ZRX cZRX
NewCToken WBTC cWBTC borrowRate 0.1 8 WBTC -- note: cannot use macros with named args right now
GiveCToken cWBTC 10e8 WBTC -- Faucet some WBTC to borrow
Give cWBTC 10e8 WBTC -- Faucet some WBTC to borrow
Support cZRX collateralFactor:0.5
Support cWBTC collateralFactor:0.5
Prep Geoff Some ZRX cZRX
Expand Down
6 changes: 4 additions & 2 deletions spec/scenario/SupplyCap.scen
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,11 @@ Test "Reserves should not affect supply cap"

Test "Infimint attack"
NewComptroller price:1.0
NewCToken ZRX cZRX
NewCToken BAT cBAT
CTokenDelegate Deploy CCapableErc20Delegate myCapableDelegate
NewCToken ZRX cZRX 0.000005 2e9 8 Standard CErc20DelegatorScenario CCapableErc20Delegate
NewCToken BAT cBAT 0.000005 2e9 8 Standard CErc20DelegatorScenario CCapableErc20Delegate
GiveCToken cBAT 10e18 BAT -- Faucet some bat to borrow
GiveCToken cZRX 1000e18 ZRX
Support cZRX collateralFactor:0.5
Support cBAT collateralFactor:0.5
Prep Geoff Some BAT cBAT
Expand Down
2 changes: 1 addition & 1 deletion spec/scenario/Unitroller.scen
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ Pending "Keeps all storage"
---
NewCToken ZRX cZRX delegatorType:CErc20Delegator cTokenType:CErc20Delegate
NewCToken BAT cBAT delegatorType:CErc20Delegator cTokenType:CErc20Delegate
GiveCToken cBAT 10e18 BAT -- Faucet some bat to borrow
Give cBAT 10e18 BAT -- Faucet some bat to borrow
Support cZRX collateralFactor:0.5
Support cBAT collateralFactor:0.4
Prep Geoff Some ZRX cZRX
Expand Down
4 changes: 0 additions & 4 deletions tests/Contracts/CErc20Harness.sol
Original file line number Diff line number Diff line change
Expand Up @@ -372,10 +372,6 @@ contract CErc20DelegateHarness is CErc20Delegate {
function harnessCallBorrowAllowed(uint amount) public returns (uint) {
return comptroller.borrowAllowed(address(this), msg.sender, amount);
}

function harnessSetInternalCash(uint amount) public {
internalCash = amount;
}
}

contract CErc20DelegateScenario is CErc20Delegate {
Expand Down
2 changes: 0 additions & 2 deletions tests/SpinaramaTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ describe('Spinarama', () => {
await send(cToken, 'harnessSetExchangeRate', [etherMantissa(1)]);
await send(cToken, 'harnessSetBalance', [from, 10]);
await send(cToken.underlying, 'harnessSetBalance', [cToken._address, 10]);
await send(cToken, 'gulp');
await send(cToken.underlying, 'approve', [cToken._address, 10], {from});
await minerStop();
const p1 = send(cToken, 'redeem', [10], {from});
Expand All @@ -93,7 +92,6 @@ describe('Spinarama', () => {
await send(cToken1.underlying, 'harnessSetBalance', [from, 10]);
await send(cToken1.underlying, 'approve', [cToken1._address, 10], {from});
await send(cToken2.underlying, 'harnessSetBalance', [cToken2._address, 10]);
await send(cToken2, 'gulp');
await send(cToken2, 'harnessSetTotalSupply', [100]);
await send(cToken2.underlying, 'approve', [cToken2._address, 10], {from});
await send(cToken2, 'harnessSetExchangeRate', [etherMantissa(1)]);
Expand Down
1 change: 0 additions & 1 deletion tests/Tokens/borrowAndRepayTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ async function preBorrow(cToken, borrower, borrowAmount) {
await send(cToken.comptroller, 'setBorrowVerify', [true]);
await send(cToken.interestRateModel, 'setFailBorrowRate', [false]);
await send(cToken.underlying, 'harnessSetBalance', [cToken._address, borrowAmount]);
await send(cToken, 'gulp');
await send(cToken, 'harnessSetFailTransferToAddress', [borrower, false]);
await send(cToken, 'harnessSetAccountBorrows', [borrower, 0, 0]);
await send(cToken, 'harnessSetTotalBorrows', [0]);
Expand Down
8 changes: 6 additions & 2 deletions tests/Tokens/cTokenTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,16 +199,20 @@ describe('CToken', function () {

it("calculates with cash and cTokenSupply", async () => {
const cTokenSupply = 5e18, totalBorrows = 0, totalReserves = 0;
expect(
await send(cToken.underlying, 'transfer', [cToken._address, etherMantissa(500)])
).toSucceed();
await send(cToken, 'harnessExchangeRateDetails', [cTokenSupply, totalBorrows, totalReserves].map(etherUnsigned));
expect(await send(cToken, 'harnessSetInternalCash', [etherMantissa(500)])).toSucceed();
const result = await call(cToken, 'exchangeRateStored');
expect(result).toEqualNumber(etherMantissa(100));
});

it("calculates with cash, borrows, reserves and cTokenSupply", async () => {
const cTokenSupply = 500e18, totalBorrows = 500e18, totalReserves = 5e18;
expect(
await send(cToken.underlying, 'transfer', [cToken._address, etherMantissa(500)])
).toSucceed();
await send(cToken, 'harnessExchangeRateDetails', [cTokenSupply, totalBorrows, totalReserves].map(etherUnsigned));
expect(await send(cToken, 'harnessSetInternalCash', [etherMantissa(500)])).toSucceed();
const result = await call(cToken, 'exchangeRateStored');
expect(result).toEqualNumber(etherMantissa(1.99));
});
Expand Down
3 changes: 0 additions & 3 deletions tests/Tokens/mintAndRedeemTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ async function preRedeem(cToken, redeemer, redeemTokens, redeemAmount, exchangeR
await send(cToken.comptroller, 'setRedeemVerify', [true]);
await send(cToken.interestRateModel, 'setFailBorrowRate', [false]);
await send(cToken.underlying, 'harnessSetBalance', [cToken._address, redeemAmount]);
await send(cToken, 'harnessSetInternalCash', [redeemAmount]);
await send(cToken.underlying, 'harnessSetBalance', [redeemer, 0]);
await send(cToken.underlying, 'harnessSetFailTransferToAddress', [redeemer, false]);
await send(cToken, 'harnessSetExchangeRate', [etherMantissa(exchangeRate)]);
Expand Down Expand Up @@ -194,7 +193,6 @@ describe('CToken', function () {

it("fails if insufficient protocol cash to transfer out", async() => {
await send(cToken.underlying, 'harnessSetBalance', [cToken._address, 1]);
await send(cToken, 'harnessSetInternalCash', [1]);
expect(await redeemFresh(cToken, redeemer, redeemTokens, redeemAmount)).toHaveTokenFailure('TOKEN_INSUFFICIENT_CASH', 'REDEEM_TRANSFER_OUT_NOT_POSSIBLE');
});

Expand Down Expand Up @@ -260,7 +258,6 @@ describe('CToken', function () {

it("returns error from redeemFresh without emitting any extra logs", async () => {
await setBalance(cToken.underlying, cToken._address, 0);
await send(cToken, 'harnessSetInternalCash', [0]);
expect(await quickRedeem(cToken, redeemer, redeemTokens, {exchangeRate})).toHaveTokenFailure('TOKEN_INSUFFICIENT_CASH', 'REDEEM_TRANSFER_OUT_NOT_POSSIBLE');
});

Expand Down
5 changes: 1 addition & 4 deletions tests/Tokens/reservesTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ describe('CToken', function () {
expect(
await send(cToken.underlying, 'harnessSetBalance', [cToken._address, cash])
).toSucceed();
expect(await send(cToken, 'harnessSetInternalCash', [cash])).toSucceed();
});

it("fails if called by non-admin", async () => {
Expand All @@ -130,7 +129,6 @@ describe('CToken', function () {
it("fails if amount exceeds available cash", async () => {
const cashLessThanReserves = reserves.minus(2);
await send(cToken.underlying, 'harnessSetBalance', [cToken._address, cashLessThanReserves]);
await send(cToken, 'harnessSetInternalCash', [cashLessThanReserves]);
expect(await send(cToken, 'harnessReduceReservesFresh', [reserves])).toHaveTokenFailure('TOKEN_INSUFFICIENT_CASH', 'REDUCE_RESERVES_CASH_NOT_AVAILABLE');
expect(await call(cToken, 'totalReserves')).toEqualNumber(reserves);
});
Expand Down Expand Up @@ -161,7 +159,6 @@ describe('CToken', function () {
expect(
await send(cToken.underlying, 'harnessSetBalance', [cToken._address, cash])
).toSucceed();
expect(await send(cToken, 'harnessSetInternalCash', [cash])).toSucceed();
});

it("emits a reserve-reduction failure if interest accrual fails", async () => {
Expand All @@ -186,7 +183,7 @@ describe('CToken', function () {
describe('gulp', () => {
let cToken;
beforeEach(async () => {
cToken = await makeCToken();
cToken = await makeCToken({kind: 'ccapable'});
});

it('absorbs excess cash into reserves', async () => {
Expand Down
Loading

0 comments on commit 30cd8ed

Please sign in to comment.