Skip to content

Commit

Permalink
Increase branch coverage on extension tests
Browse files Browse the repository at this point in the history
  • Loading branch information
area authored and kronosapiens committed Jun 7, 2022
1 parent 632b7cc commit 51daa24
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 10 deletions.
6 changes: 2 additions & 4 deletions test/extensions/expenditure-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,8 @@ contract("ExpenditureUtils", (accounts) => {
expect(code).to.equal("0x");
});

it("cannot manage the extension if not owner", async () => {
expenditureUtils = await ExpenditureUtils.new();

await checkErrorRevert(expenditureUtils.install(colony.address, { from: USER1 }), "ds-auth-unauthorized");
it("can't use the network-level functions if installed via ColonyNetwork", async () => {
await checkErrorRevert(expenditureUtils.install(ADDRESS_ZERO, { from: USER1 }), "ds-auth-unauthorized");
await checkErrorRevert(expenditureUtils.finishUpgrade({ from: USER1 }), "ds-auth-unauthorized");
await checkErrorRevert(expenditureUtils.deprecate(true, { from: USER1 }), "ds-auth-unauthorized");
await checkErrorRevert(expenditureUtils.uninstall({ from: USER1 }), "ds-auth-unauthorized");
Expand Down
9 changes: 8 additions & 1 deletion test/extensions/funding-queue.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const bnChai = require("bn-chai");
const { ethers } = require("ethers");
const { soliditySha3 } = require("web3-utils");

const { UINT256_MAX, WAD, MINING_CYCLE_DURATION, SECONDS_PER_DAY, CHALLENGE_RESPONSE_WINDOW_DURATION } = require("../../helpers/constants");
const { UINT256_MAX, WAD, MINING_CYCLE_DURATION, SECONDS_PER_DAY, CHALLENGE_RESPONSE_WINDOW_DURATION, ADDRESS_ZERO } = require("../../helpers/constants");

const {
checkErrorRevert,
Expand Down Expand Up @@ -196,6 +196,13 @@ contract("Funding Queues", (accounts) => {

await colony.uninstallExtension(FUNDING_QUEUE, { from: USER0 });
});

it("can't use the network-level functions if installed via ColonyNetwork", async () => {
await checkErrorRevert(fundingQueue.install(ADDRESS_ZERO, { from: USER1 }), "ds-auth-unauthorized");
await checkErrorRevert(fundingQueue.finishUpgrade({ from: USER1 }), "ds-auth-unauthorized");
await checkErrorRevert(fundingQueue.deprecate(true, { from: USER1 }), "ds-auth-unauthorized");
await checkErrorRevert(fundingQueue.uninstall({ from: USER1 }), "ds-auth-unauthorized");
});
});

describe("creating funding proposals", async () => {
Expand Down
10 changes: 8 additions & 2 deletions test/extensions/one-tx-payment.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const bnChai = require("bn-chai");
const { ethers } = require("ethers");
const { soliditySha3 } = require("web3-utils");

const { UINT256_MAX, WAD, INITIAL_FUNDING, GLOBAL_SKILL_ID, FUNDING_ROLE, ADMINISTRATION_ROLE } = require("../../helpers/constants");
const { UINT256_MAX, WAD, INITIAL_FUNDING, GLOBAL_SKILL_ID, FUNDING_ROLE, ADMINISTRATION_ROLE, ADDRESS_ZERO } = require("../../helpers/constants");
const { checkErrorRevert, web3GetCode, rolesToBytes32, expectEvent } = require("../../helpers/test-helper");
const { setupRandomColony, fundColonyWithTokens, getMetaTransactionParameters } = require("../../helpers/test-data-generator");

Expand All @@ -31,7 +31,6 @@ contract("One transaction payments", (accounts) => {
const USER2 = accounts[1].toLowerCase() < accounts[2].toLowerCase() ? accounts[2] : accounts[1];

const ROLES = rolesToBytes32([FUNDING_ROLE, ADMINISTRATION_ROLE]);
const ADDRESS_ZERO = ethers.constants.AddressZero;

before(async () => {
const etherRouter = await EtherRouter.deployed();
Expand Down Expand Up @@ -89,6 +88,13 @@ contract("One transaction payments", (accounts) => {

await colony.uninstallExtension(ONE_TX_PAYMENT);
});

it("can't use the network-level functions if installed via ColonyNetwork", async () => {
await checkErrorRevert(oneTxPayment.install(ADDRESS_ZERO, { from: USER1 }), "ds-auth-unauthorized");
await checkErrorRevert(oneTxPayment.finishUpgrade({ from: USER1 }), "ds-auth-unauthorized");
await checkErrorRevert(oneTxPayment.deprecate(true, { from: USER1 }), "ds-auth-unauthorized");
await checkErrorRevert(oneTxPayment.uninstall({ from: USER1 }), "ds-auth-unauthorized");
});
});

describe("using the extension", async () => {
Expand Down
9 changes: 8 additions & 1 deletion test/extensions/token-supplier.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const bnChai = require("bn-chai");
const { ethers } = require("ethers");
const { soliditySha3 } = require("web3-utils");

const { UINT256_MAX, WAD, SECONDS_PER_DAY } = require("../../helpers/constants");
const { UINT256_MAX, WAD, SECONDS_PER_DAY, ADDRESS_ZERO } = require("../../helpers/constants");
const { setupRandomColony, getMetaTransactionParameters } = require("../../helpers/test-data-generator");
const { checkErrorRevert, currentBlockTime, makeTxAtTimestamp, getBlockTime, forwardTime } = require("../../helpers/test-helper");

Expand Down Expand Up @@ -196,6 +196,13 @@ contract("Token Supplier", (accounts) => {
expect(lastPinged).to.eq.BN(blockTime);
expect(lastRateUpdate).to.eq.BN(blockTime);
});

it("can't use the network-level functions if installed via ColonyNetwork", async () => {
await checkErrorRevert(tokenSupplier.install(ADDRESS_ZERO, { from: USER1 }), "ds-auth-unauthorized");
await checkErrorRevert(tokenSupplier.finishUpgrade({ from: USER1 }), "ds-auth-unauthorized");
await checkErrorRevert(tokenSupplier.deprecate(true, { from: USER1 }), "ds-auth-unauthorized");
await checkErrorRevert(tokenSupplier.uninstall({ from: USER1 }), "ds-auth-unauthorized");
});
});

describe("issuing tokens", async () => {
Expand Down
7 changes: 7 additions & 0 deletions test/extensions/voting-rep.js
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,13 @@ contract("Voting Reputation", (accounts) => {
expect(revealPeriod).to.eq.BN(REVEAL_PERIOD);
expect(escalationPeriod).to.eq.BN(ESCALATION_PERIOD);
});

it("can't use the network-level functions if installed via ColonyNetwork", async () => {
// await checkErrorRevert(voting.install(ADDRESS_ZERO, { from: USER1 }), "ds-auth-unauthorized");
await checkErrorRevert(voting.finishUpgrade({ from: USER1 }), "ds-auth-unauthorized");
await checkErrorRevert(voting.deprecate(true, { from: USER1 }), "ds-auth-unauthorized");
await checkErrorRevert(voting.uninstall({ from: USER1 }), "ds-auth-unauthorized");
});
});

describe("creating motions", async () => {
Expand Down
9 changes: 8 additions & 1 deletion test/extensions/whitelist.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const bnChai = require("bn-chai");
const { ethers } = require("ethers");
const { soliditySha3 } = require("web3-utils");

const { UINT256_MAX, IPFS_HASH } = require("../../helpers/constants");
const { UINT256_MAX, IPFS_HASH, ADDRESS_ZERO } = require("../../helpers/constants");
const { checkErrorRevert, web3GetCode } = require("../../helpers/test-helper");
const { setupRandomColony, getMetaTransactionParameters } = require("../../helpers/test-data-generator");

Expand Down Expand Up @@ -76,6 +76,13 @@ contract("Whitelist", (accounts) => {

await colony.uninstallExtension(WHITELIST, { from: USER0 });
});

it("can't use the network-level functions if installed via ColonyNetwork", async () => {
await checkErrorRevert(whitelist.install(ADDRESS_ZERO, { from: USER1 }), "ds-auth-unauthorized");
await checkErrorRevert(whitelist.finishUpgrade({ from: USER1 }), "ds-auth-unauthorized");
await checkErrorRevert(whitelist.deprecate(true, { from: USER1 }), "ds-auth-unauthorized");
await checkErrorRevert(whitelist.uninstall({ from: USER1 }), "ds-auth-unauthorized");
});
});

describe("using the whitelist", async () => {
Expand Down
2 changes: 1 addition & 1 deletion test/packages/metaTransactionBroadcaster.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const loader = new TruffleLoader({
contractDir: path.resolve(__dirname, "..", "..", "build", "contracts"),
});

contract("Metatransaction broadcaster", (accounts) => {
contract.only("Metatransaction broadcaster", (accounts) => {
const USER0 = accounts[0];
const USER1 = accounts[1];

Expand Down

0 comments on commit 51daa24

Please sign in to comment.