Skip to content

Commit

Permalink
fixup! feat: Add multicollateral registry and weakest collateral rede…
Browse files Browse the repository at this point in the history
…mption
  • Loading branch information
bingen committed Apr 23, 2024
1 parent 978a8d3 commit 2843b68
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
21 changes: 13 additions & 8 deletions contracts/test/OwnershipTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,28 +46,33 @@ contract("All Liquity functions with onlyOwner modifier", async (accounts) => {
}
};

const testSetAddresses = async (contract, numberOfAddresses) => {
const testSetAddresses = async (contract, numberOfAddresses, twice=true, method='setAddresses') => {
const dumbContract = await GasPool.new();
const params = Array(numberOfAddresses).fill(dumbContract.address);

// Attempt call from alice
await th.assertRevert(contract.setAddresses(...params, { from: alice }));
await th.assertRevert(contract[method](...params, { from: alice }));

// Attempt to use zero address
await testZeroAddress(contract, params);
await testZeroAddress(contract, params, method);
// Attempt to use non contract
await testNonContractAddress(contract, params);
await testNonContractAddress(contract, params, method);

// Owner can successfully set any address
const txOwner = await contract.setAddresses(...params, { from: owner });
const txOwner = await contract[method](...params, { from: owner });
assert.isTrue(txOwner.receipt.status);
// fails if called twice
await th.assertRevert(contract.setAddresses(...params, { from: owner }));
if (twice) {
await th.assertRevert(contract[method](...params, { from: owner }));
}
};

describe("TroveManager", async (accounts) => {
it("setAddresses(): reverts when called by non-owner, with wrong addresses, or twice", async () => {
await testSetAddresses(troveManager, 9);
it("setAddresses(): reverts when called by non-owner, with wrong addresses", async () => {
await testSetAddresses(troveManager, 9, false);
});
it("setCollateralRegistry(): reverts when called by non-owner, with wrong address, or twice", async () => {
await testSetAddresses(troveManager, 1, true, 'setCollateralRegistry');
});
});

Expand Down
3 changes: 2 additions & 1 deletion contracts/utils/deploymentHelpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,8 @@ class DeploymentHelper {
}

static async deployBoldToken(contracts, MockedBoldToken = BoldToken) {
contracts.boldToken = await MockedBoldToken.new(
contracts.boldToken = await MockedBoldToken.new();
contracts.boldToken.setBranchAddresses(
contracts.troveManager.address,
contracts.stabilityPool.address,
contracts.borrowerOperations.address,
Expand Down

0 comments on commit 2843b68

Please sign in to comment.