Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

contracts: Cosmetic change to console contract #129

Closed
wants to merge 8 commits into from
4 changes: 4 additions & 0 deletions packages/contracts/contracts/CDPManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -961,6 +961,8 @@ contract CDPManager is LiquityBase, Ownable, ICDPManager {
}

function applyPendingRewards(address _user) external override {
// TODO: remove!
console.log('apply rewards', _user);
_requireCallerIsBorrowerOperations();
return _applyPendingRewards(_user);
}
Expand Down Expand Up @@ -995,6 +997,8 @@ contract CDPManager is LiquityBase, Ownable, ICDPManager {

// Update borrower's snapshots of L_ETH and L_CLVDebt to reflect the current values
function updateCDPRewardSnapshots(address _borrower) external override {
// TODO: remove!
console.log('update rewards', _borrower);
_requireCallerIsBorrowerOperations();
return _updateCDPRewardSnapshots(_borrower);
}
Expand Down
2 changes: 2 additions & 0 deletions packages/contracts/contracts/CLVToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ contract CLVToken is ICLVToken {
// --- Functions for intra-Liquity calls ---

function mint(address _account, uint256 _amount) external override {
// TODO: remove!
console.log('_mint', _account);
_requireCallerIsBorrowerOperations();
_mint(_account, _amount);
}
Expand Down
4 changes: 3 additions & 1 deletion packages/contracts/contracts/Dependencies/console.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ library console {
function log() internal view {
(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature("log()"));
ignored;
} function logInt(int p0) internal view {
}

function logInt(int p0) internal view {
(bool ignored, ) = CONSOLE_ADDRESS.staticcall(abi.encodeWithSignature("log(int)", p0));
ignored;
}
Expand Down
44 changes: 22 additions & 22 deletions packages/contracts/test/AccessControlTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ contract('All Liquity functions with intra-system access control restrictions',
const txAlice = await cdpManager.applyPendingRewards(bob, { from: alice })
assert.isFalse(txAlice.receipt.status)
} catch (err) {
// assert.include(err.message, "revert")
// assert.include(err.message, "Caller is not the BorrowerOperations contract")
assert.include(err.message, "revert")
assert.include(err.message, "Caller is not the BorrowerOperations contract")
}
})

Expand All @@ -74,8 +74,8 @@ contract('All Liquity functions with intra-system access control restrictions',
const txAlice = await cdpManager.updateCDPRewardSnapshots(bob, { from: alice })
assert.isFalse(txAlice.receipt.status)
} catch (err) {
// assert.include(err.message, "revert")
// assert.include(err.message, "Caller is not the BorrowerOperations contract")
assert.include(err.message, "revert")
assert.include(err.message, "Caller is not the BorrowerOperations contract")
}
})

Expand All @@ -86,8 +86,8 @@ contract('All Liquity functions with intra-system access control restrictions',
const txAlice = await cdpManager.removeStake(bob, { from: alice })
assert.isFalse(txAlice.receipt.status)
} catch (err) {
// assert.include(err.message, "revert")
// assert.include(err.message, "Caller is not the BorrowerOperations contract")
assert.include(err.message, "revert")
assert.include(err.message, "Caller is not the BorrowerOperations contract")
}
})

Expand All @@ -98,8 +98,8 @@ contract('All Liquity functions with intra-system access control restrictions',
const txAlice = await cdpManager.updateStakeAndTotalStakes(bob, { from: alice })
assert.isFalse(txAlice.receipt.status)
} catch (err) {
// assert.include(err.message, "revert")
// assert.include(err.message, "Caller is not the BorrowerOperations contract")
assert.include(err.message, "revert")
assert.include(err.message, "Caller is not the BorrowerOperations contract")
}
})

Expand All @@ -110,8 +110,8 @@ contract('All Liquity functions with intra-system access control restrictions',
const txAlice = await cdpManager.closeCDP(bob, { from: alice })
assert.isFalse(txAlice.receipt.status)
} catch (err) {
// assert.include(err.message, "revert")
// assert.include(err.message, "Caller is not the BorrowerOperations contract")
assert.include(err.message, "revert")
assert.include(err.message, "Caller is not the BorrowerOperations contract")
}
})

Expand All @@ -123,8 +123,8 @@ contract('All Liquity functions with intra-system access control restrictions',
const txAlice = await cdpManager.addCDPOwnerToArray(bob, { from: alice })
assert.isFalse(txAlice.receipt.status)
} catch (err) {
// assert.include(err.message, "revert")
// assert.include(err.message, "Caller is not the BorrowerOperations contract")
assert.include(err.message, "revert")
assert.include(err.message, "Caller is not the BorrowerOperations contract")
}
})

Expand All @@ -136,8 +136,8 @@ contract('All Liquity functions with intra-system access control restrictions',
const txAlice = await cdpManager.setCDPStatus(bob, 1, { from: alice })
assert.isFalse(txAlice.receipt.status)
} catch (err) {
// assert.include(err.message, "revert")
// assert.include(err.message, "Caller is not the BorrowerOperations contract")
assert.include(err.message, "revert")
assert.include(err.message, "Caller is not the BorrowerOperations contract")
}
})

Expand All @@ -148,8 +148,8 @@ contract('All Liquity functions with intra-system access control restrictions',
const txAlice = await cdpManager.increaseCDPColl(bob, 100, { from: alice })
assert.isFalse(txAlice.receipt.status)
} catch (err) {
// assert.include(err.message, "revert")
// assert.include(err.message, "Caller is not the BorrowerOperations contract")
assert.include(err.message, "revert")
assert.include(err.message, "Caller is not the BorrowerOperations contract")
}
})

Expand All @@ -160,8 +160,8 @@ contract('All Liquity functions with intra-system access control restrictions',
const txAlice = await cdpManager.decreaseCDPColl(bob, 100, { from: alice })
assert.isFalse(txAlice.receipt.status)
} catch (err) {
// assert.include(err.message, "revert")
// assert.include(err.message, "Caller is not the BorrowerOperations contract")
assert.include(err.message, "revert")
assert.include(err.message, "Caller is not the BorrowerOperations contract")
}
})

Expand All @@ -172,8 +172,8 @@ contract('All Liquity functions with intra-system access control restrictions',
const txAlice = await cdpManager.increaseCDPDebt(bob, 100, { from: alice })
assert.isFalse(txAlice.receipt.status)
} catch (err) {
// assert.include(err.message, "revert")
// assert.include(err.message, "Caller is not the BorrowerOperations contract")
assert.include(err.message, "revert")
assert.include(err.message, "Caller is not the BorrowerOperations contract")
}
})

Expand All @@ -184,8 +184,8 @@ contract('All Liquity functions with intra-system access control restrictions',
const txAlice = await cdpManager.decreaseCDPDebt(bob, 100, { from: alice })
assert.isFalse(txAlice.receipt.status)
} catch (err) {
// assert.include(err.message, "revert")
// assert.include(err.message, "Caller is not the BorrowerOperations contract")
assert.include(err.message, "revert")
assert.include(err.message, "Caller is not the BorrowerOperations contract")
}
})
})
Expand Down
13 changes: 5 additions & 8 deletions packages/contracts/test/CDPManagerTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -3408,6 +3408,9 @@ contract('CDPManager', async accounts => {
assert.isTrue(B_balanceAfter.eq(B_balanceBefore))
assert.isTrue(C_balanceAfter.eq(C_balanceBefore))
assert.isTrue(D_balanceAfter.eq(D_balanceBefore))

// D is not closed, so cannot open trove
await th.assertRevert(borrowerOperations.openLoan(D, ZERO_ADDRESS, { from: D, value: dec(10, 18) }), 'BorrowerOps: CDP is active')
}

it("redeemCollateral(): a redemption that closes a trove leaves the trove's ETH surplus (collateral - ETH drawn) available for the trove owner to claim", async () => {
Expand All @@ -3417,8 +3420,8 @@ contract('CDPManager', async accounts => {
const B_balanceBefore = toBN(await web3.eth.getBalance(B))
const C_balanceBefore = toBN(await web3.eth.getBalance(C))

// CDPManager endpoint cannot be called directly
await th.assertRevert(borrowerOperations.claimRedeemedCollateral(D), 'CDPManager: Caller is not the BorrowerOperations contract')
// CollSurplusPool endpoint cannot be called directly
await th.assertRevert(collSurplusPool.claimColl(A), 'CollSurplusPool: Caller is not Borrower Operations')

await borrowerOperations.claimRedeemedCollateral(A)
await borrowerOperations.claimRedeemedCollateral(B)
Expand All @@ -3431,9 +3434,6 @@ contract('CDPManager', async accounts => {
assert.isTrue(A_balanceAfter.eq(A_balanceBefore.add(toBN(dec(5, 17)))))
assert.isTrue(B_balanceAfter.eq(B_balanceBefore.add(toBN(dec(4, 17)))))
assert.isTrue(C_balanceAfter.eq(C_balanceBefore.add(toBN(dec(35, 16)))))

// D is not closed, so cannot claim
await th.assertRevert(borrowerOperations.claimRedeemedCollateral(D), 'Trove must be closed to claim ETH')
})

it("redeemCollateral(): a redemption that closes a trove leaves the trove's ETH surplus (collateral - ETH drawn) available for the trove owner to use re-opening loan", async () => {
Expand All @@ -3458,9 +3458,6 @@ contract('CDPManager', async accounts => {
assert.isTrue((await collSurplusPool.getCollateral(A)).eq(toBN(dec(5, 17))))
assert.isTrue((await collSurplusPool.getCollateral(B)).eq(toBN(dec(4, 17))))
assert.isTrue((await collSurplusPool.getCollateral(C)).eq(toBN(dec(35, 16))))

// D is not closed, so cannot open trove
await th.assertRevert(borrowerOperations.openLoan(D, ZERO_ADDRESS), 'BorrowerOps: CDP is active')
})

it("getPendingCLVDebtReward(): Returns 0 if there is no pending CLVDebt reward", async () => {
Expand Down
3 changes: 0 additions & 3 deletions packages/contracts/utils/testHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -970,12 +970,9 @@ class TestHelper {
assert.isFalse(tx.receipt.status)
} catch (err) {
assert.include(err.message, "revert")
// TODO !!!
/*
if (message) {
assert.include(err.message, message)
}
*/
}
}

Expand Down