Skip to content

Commit

Permalink
Return to automatic version inferral
Browse files Browse the repository at this point in the history
  • Loading branch information
kronosapiens authored and area committed Jan 27, 2022
1 parent 5d7290e commit fc3e6ba
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 54 deletions.
34 changes: 17 additions & 17 deletions test/extensions/coin-machine.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,25 +39,27 @@ contract("Coin Machine", (accounts) => {
let purchaseToken;
let colonyNetwork;
let coinMachine;
let version;

const USER0 = accounts[0];
const USER1 = accounts[1];
const USER2 = accounts[2];

const VERSION = 3;

const ADDRESS_ZERO = ethers.constants.AddressZero;

before(async () => {
const etherRouter = await EtherRouter.deployed();
colonyNetwork = await IColonyNetwork.at(etherRouter.address);

const extension = await CoinMachine.new();
version = await extension.version();
});

beforeEach(async () => {
({ colony, token } = await setupRandomColony(colonyNetwork));
purchaseToken = await setupRandomToken();

await colony.installExtension(COIN_MACHINE, VERSION);
await colony.installExtension(COIN_MACHINE, version);

const coinMachineAddress = await colonyNetwork.getExtensionInstallation(COIN_MACHINE, colony.address);
coinMachine = await CoinMachine.at(coinMachineAddress);
Expand All @@ -76,9 +78,7 @@ contract("Coin Machine", (accounts) => {
await checkErrorRevert(coinMachine.install(colony.address), "extension-already-installed");

const identifier = await coinMachine.identifier();
const version = await coinMachine.version();
expect(identifier).to.equal(COIN_MACHINE);
expect(version).to.eq.BN(VERSION);

const capabilityRoles = await coinMachine.getCapabilityRoles("0x0");
expect(capabilityRoles).to.equal(ethers.constants.HashZero);
Expand All @@ -93,9 +93,9 @@ contract("Coin Machine", (accounts) => {

it("can install the extension with the extension manager", async () => {
({ colony } = await setupRandomColony(colonyNetwork));
await colony.installExtension(COIN_MACHINE, VERSION, { from: USER0 });
await colony.installExtension(COIN_MACHINE, version, { from: USER0 });

await checkErrorRevert(colony.installExtension(COIN_MACHINE, VERSION, { from: USER0 }), "colony-network-extension-already-installed");
await checkErrorRevert(colony.installExtension(COIN_MACHINE, version, { from: USER0 }), "colony-network-extension-already-installed");
await checkErrorRevert(colony.uninstallExtension(COIN_MACHINE, { from: USER1 }), "ds-auth-unauthorized");

await colony.uninstallExtension(COIN_MACHINE, { from: USER0 });
Expand Down Expand Up @@ -272,7 +272,7 @@ contract("Coin Machine", (accounts) => {
await otherToken.unlock();

await colony.uninstallExtension(COIN_MACHINE, { from: USER0 });
await colony.installExtension(COIN_MACHINE, VERSION, { from: USER0 });
await colony.installExtension(COIN_MACHINE, version, { from: USER0 });
const coinMachineAddress = await colonyNetwork.getExtensionInstallation(COIN_MACHINE, colony.address);
coinMachine = await CoinMachine.at(coinMachineAddress);

Expand All @@ -291,7 +291,7 @@ contract("Coin Machine", (accounts) => {

it("cannot buy more than the balance of tokens", async () => {
await colony.uninstallExtension(COIN_MACHINE, { from: USER0 });
await colony.installExtension(COIN_MACHINE, VERSION, { from: USER0 });
await colony.installExtension(COIN_MACHINE, version, { from: USER0 });
const coinMachineAddress = await colonyNetwork.getExtensionInstallation(COIN_MACHINE, colony.address);
coinMachine = await CoinMachine.at(coinMachineAddress);

Expand Down Expand Up @@ -319,7 +319,7 @@ contract("Coin Machine", (accounts) => {
expect(locked).to.equal(true);

colony = await setupColony(colonyNetwork, token.address);
await colony.installExtension(COIN_MACHINE, VERSION);
await colony.installExtension(COIN_MACHINE, version);
const coinMachineAddress = await colonyNetwork.getExtensionInstallation(COIN_MACHINE, colony.address);
coinMachine = await CoinMachine.at(coinMachineAddress);

Expand Down Expand Up @@ -355,7 +355,7 @@ contract("Coin Machine", (accounts) => {

it("can buy tokens with eth", async () => {
await colony.uninstallExtension(COIN_MACHINE, { from: USER0 });
await colony.installExtension(COIN_MACHINE, VERSION, { from: USER0 });
await colony.installExtension(COIN_MACHINE, version, { from: USER0 });
const coinMachineAddress = await colonyNetwork.getExtensionInstallation(COIN_MACHINE, colony.address);
coinMachine = await CoinMachine.at(coinMachineAddress);

Expand Down Expand Up @@ -493,7 +493,7 @@ contract("Coin Machine", (accounts) => {

it("cannot adjust prices while the token balance is zero", async () => {
await colony.uninstallExtension(COIN_MACHINE, { from: USER0 });
await colony.installExtension(COIN_MACHINE, VERSION, { from: USER0 });
await colony.installExtension(COIN_MACHINE, version, { from: USER0 });
const coinMachineAddress = await colonyNetwork.getExtensionInstallation(COIN_MACHINE, colony.address);
coinMachine = await CoinMachine.at(coinMachineAddress);

Expand Down Expand Up @@ -737,7 +737,7 @@ contract("Coin Machine", (accounts) => {
colony = await setupColony(colonyNetwork, token.address);
await token.unlock();

await colony.installExtension(COIN_MACHINE, VERSION, { from: USER0 });
await colony.installExtension(COIN_MACHINE, version, { from: USER0 });
const coinMachineAddress = await colonyNetwork.getExtensionInstallation(COIN_MACHINE, colony.address);
coinMachine = await CoinMachine.at(coinMachineAddress);

Expand All @@ -759,7 +759,7 @@ contract("Coin Machine", (accounts) => {
await purchaseToken.unlock();

await colony.uninstallExtension(COIN_MACHINE, { from: USER0 });
await colony.installExtension(COIN_MACHINE, VERSION, { from: USER0 });
await colony.installExtension(COIN_MACHINE, version, { from: USER0 });
const coinMachineAddress = await colonyNetwork.getExtensionInstallation(COIN_MACHINE, colony.address);
coinMachine = await CoinMachine.at(coinMachineAddress);

Expand Down Expand Up @@ -829,7 +829,7 @@ contract("Coin Machine", (accounts) => {

it("cannot buy more than their user limit allows", async () => {
await colony.uninstallExtension(COIN_MACHINE, { from: USER0 });
await colony.installExtension(COIN_MACHINE, VERSION, { from: USER0 });
await colony.installExtension(COIN_MACHINE, version, { from: USER0 });
const coinMachineAddress = await colonyNetwork.getExtensionInstallation(COIN_MACHINE, colony.address);
coinMachine = await CoinMachine.at(coinMachineAddress);

Expand Down Expand Up @@ -905,7 +905,7 @@ contract("Coin Machine", (accounts) => {

it("cannot set a user limit without a whitelist", async () => {
await colony.uninstallExtension(COIN_MACHINE, { from: USER0 });
await colony.installExtension(COIN_MACHINE, VERSION, { from: USER0 });
await colony.installExtension(COIN_MACHINE, version, { from: USER0 });
const coinMachineAddress = await colonyNetwork.getExtensionInstallation(COIN_MACHINE, colony.address);
coinMachine = await CoinMachine.at(coinMachineAddress);

Expand All @@ -917,7 +917,7 @@ contract("Coin Machine", (accounts) => {

it("can calculate the max purchase at any given time", async () => {
await colony.uninstallExtension(COIN_MACHINE, { from: USER0 });
await colony.installExtension(COIN_MACHINE, VERSION, { from: USER0 });
await colony.installExtension(COIN_MACHINE, version, { from: USER0 });
const coinMachineAddress = await colonyNetwork.getExtensionInstallation(COIN_MACHINE, colony.address);
coinMachine = await CoinMachine.at(coinMachineAddress);

Expand Down
12 changes: 7 additions & 5 deletions test/extensions/evaluated-expenditures.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,23 @@ contract("EvaluatedExpenditure", (accounts) => {
let colonyNetwork;
let colony;
let evaluatedExpenditure;
let version;

const USER0 = accounts[0];
const USER1 = accounts[1];

const VERSION = 2;

before(async () => {
const etherRouter = await EtherRouter.deployed();
colonyNetwork = await IColonyNetwork.at(etherRouter.address);

const extension = await EvaluatedExpenditure.new();
version = await extension.version();
});

beforeEach(async () => {
({ colony } = await setupRandomColony(colonyNetwork));

await colony.installExtension(EVALUATED_EXPENDITURE, VERSION);
await colony.installExtension(EVALUATED_EXPENDITURE, version);

const evaluatedExpenditureAddress = await colonyNetwork.getExtensionInstallation(EVALUATED_EXPENDITURE, colony.address);
evaluatedExpenditure = await EvaluatedExpenditure.at(evaluatedExpenditureAddress);
Expand Down Expand Up @@ -67,9 +69,9 @@ contract("EvaluatedExpenditure", (accounts) => {

it("can install the extension with the extension manager", async () => {
({ colony } = await setupRandomColony(colonyNetwork));
await colony.installExtension(EVALUATED_EXPENDITURE, VERSION, { from: USER0 });
await colony.installExtension(EVALUATED_EXPENDITURE, version, { from: USER0 });

await checkErrorRevert(colony.installExtension(EVALUATED_EXPENDITURE, VERSION, { from: USER0 }), "colony-network-extension-already-installed");
await checkErrorRevert(colony.installExtension(EVALUATED_EXPENDITURE, version, { from: USER0 }), "colony-network-extension-already-installed");
await checkErrorRevert(colony.uninstallExtension(EVALUATED_EXPENDITURE, { from: USER1 }), "ds-auth-unauthorized");

await colony.uninstallExtension(EVALUATED_EXPENDITURE, { from: USER0 });
Expand Down
14 changes: 7 additions & 7 deletions test/extensions/funding-queue.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ contract("Funding Queues", (accounts) => {
let colonyNetwork;
let tokenLocking;
let fundingQueue;
let version;

let reputationTree;

Expand All @@ -64,8 +65,6 @@ contract("Funding Queues", (accounts) => {
const USER1 = accounts[1];
const MINER = accounts[5];

const VERSION = 3;

const WAD2 = WAD.muln(2);

const HEAD = 0;
Expand All @@ -84,6 +83,9 @@ contract("Funding Queues", (accounts) => {
tokenLocking = await TokenLocking.at(tokenLockingAddress);

await removeSubdomainLimit(colonyNetwork);

const extension = await FundingQueue.new();
version = await extension.version();
});

beforeEach(async () => {
Expand All @@ -95,7 +97,7 @@ contract("Funding Queues", (accounts) => {
await colony.addDomain(1, 0, 2);
domain1 = await colony.getDomain(1);
domain2 = await colony.getDomain(2);
await colony.installExtension(FUNDING_QUEUE, VERSION);
await colony.installExtension(FUNDING_QUEUE, version);

const fundingQueueAddress = await colonyNetwork.getExtensionInstallation(FUNDING_QUEUE, colony.address);
fundingQueue = await FundingQueue.at(fundingQueueAddress);
Expand Down Expand Up @@ -172,9 +174,7 @@ contract("Funding Queues", (accounts) => {
await checkErrorRevert(fundingQueue.install(colony.address), "extension-already-installed");

const identifier = await fundingQueue.identifier();
const version = await fundingQueue.version();
expect(identifier).to.equal(FUNDING_QUEUE);
expect(version).to.eq.BN(VERSION);

const capabilityRoles = await fundingQueue.getCapabilityRoles("0x0");
expect(capabilityRoles).to.equal(ethers.constants.HashZero);
Expand All @@ -189,9 +189,9 @@ contract("Funding Queues", (accounts) => {

it("can install the extension with the extension manager", async () => {
({ colony } = await setupRandomColony(colonyNetwork));
await colony.installExtension(FUNDING_QUEUE, VERSION, { from: USER0 });
await colony.installExtension(FUNDING_QUEUE, version, { from: USER0 });

await checkErrorRevert(colony.installExtension(FUNDING_QUEUE, VERSION, { from: USER0 }), "colony-network-extension-already-installed");
await checkErrorRevert(colony.installExtension(FUNDING_QUEUE, version, { from: USER0 }), "colony-network-extension-already-installed");
await checkErrorRevert(colony.uninstallExtension(FUNDING_QUEUE, { from: USER1 }), "ds-auth-unauthorized");

await colony.uninstallExtension(FUNDING_QUEUE, { from: USER0 });
Expand Down
14 changes: 7 additions & 7 deletions test/extensions/one-tx-payment.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,11 @@ contract("One transaction payments", (accounts) => {
let colonyNetwork;
let metaColony;
let oneTxPayment;
let version;

const USER1 = accounts[1].toLowerCase() < accounts[2].toLowerCase() ? accounts[1] : accounts[2];
const USER2 = accounts[1].toLowerCase() < accounts[2].toLowerCase() ? accounts[2] : accounts[1];

const VERSION = 3;

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

Expand All @@ -40,6 +39,9 @@ contract("One transaction payments", (accounts) => {

const metaColonyAddress = await colonyNetwork.getMetaColony();
metaColony = await IMetaColony.at(metaColonyAddress);

const extension = await OneTxPayment.new();
version = await extension.version();
});

beforeEach(async () => {
Expand All @@ -49,7 +51,7 @@ contract("One transaction payments", (accounts) => {

await fundColonyWithTokens(colony, token, INITIAL_FUNDING);

await colony.installExtension(ONE_TX_PAYMENT, VERSION);
await colony.installExtension(ONE_TX_PAYMENT, version);
const oneTxPaymentAddress = await colonyNetwork.getExtensionInstallation(ONE_TX_PAYMENT, colony.address);
oneTxPayment = await OneTxPayment.at(oneTxPaymentAddress);

Expand All @@ -65,9 +67,7 @@ contract("One transaction payments", (accounts) => {
await checkErrorRevert(oneTxPayment.install(colony.address), "extension-already-installed");

const identifier = await oneTxPayment.identifier();
const version = await oneTxPayment.version();
expect(identifier).to.equal(ONE_TX_PAYMENT);
expect(version).to.eq.BN(VERSION);

const capabilityRoles = await oneTxPayment.getCapabilityRoles("0x0");
expect(capabilityRoles).to.equal(ethers.constants.HashZero);
Expand All @@ -82,9 +82,9 @@ contract("One transaction payments", (accounts) => {

it("can install the extension with the extension manager", async () => {
({ colony } = await setupRandomColony(colonyNetwork));
await colony.installExtension(ONE_TX_PAYMENT, VERSION);
await colony.installExtension(ONE_TX_PAYMENT, version);

await checkErrorRevert(colony.installExtension(ONE_TX_PAYMENT, VERSION), "colony-network-extension-already-installed");
await checkErrorRevert(colony.installExtension(ONE_TX_PAYMENT, version), "colony-network-extension-already-installed");
await checkErrorRevert(colony.uninstallExtension(ONE_TX_PAYMENT, { from: USER1 }), "ds-auth-unauthorized");

await colony.uninstallExtension(ONE_TX_PAYMENT);
Expand Down
13 changes: 7 additions & 6 deletions test/extensions/token-supplier.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,26 @@ contract("Token Supplier", (accounts) => {
let colony;
let token;
let colonyNetwork;

let tokenSupplier;
let version;

const USER0 = accounts[0];
const USER1 = accounts[1];
const USER2 = accounts[2];

const VERSION = 3;

const SUPPLY_CEILING = WAD.muln(10);

before(async () => {
const etherRouter = await EtherRouter.deployed();
colonyNetwork = await IColonyNetwork.at(etherRouter.address);

const extension = await TokenSupplier.new();
version = await extension.version();
});

beforeEach(async () => {
({ colony, token } = await setupRandomColony(colonyNetwork));
await colony.installExtension(TOKEN_SUPPLIER, VERSION);
await colony.installExtension(TOKEN_SUPPLIER, version);
await colony.addDomain(1, UINT256_MAX, 1);

const tokenSupplierAddress = await colonyNetwork.getExtensionInstallation(TOKEN_SUPPLIER, colony.address);
Expand All @@ -67,9 +68,9 @@ contract("Token Supplier", (accounts) => {

it("can install the extension with the extension manager", async () => {
({ colony } = await setupRandomColony(colonyNetwork));
await colony.installExtension(TOKEN_SUPPLIER, VERSION, { from: USER0 });
await colony.installExtension(TOKEN_SUPPLIER, version, { from: USER0 });

await checkErrorRevert(colony.installExtension(TOKEN_SUPPLIER, VERSION, { from: USER0 }), "colony-network-extension-already-installed");
await checkErrorRevert(colony.installExtension(TOKEN_SUPPLIER, version, { from: USER0 }), "colony-network-extension-already-installed");
await checkErrorRevert(colony.uninstallExtension(TOKEN_SUPPLIER, { from: USER1 }), "ds-auth-unauthorized");

await colony.uninstallExtension(TOKEN_SUPPLIER, { from: USER0 });
Expand Down
14 changes: 7 additions & 7 deletions test/extensions/voting-rep.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ contract("Voting Reputation", (accounts) => {
let tokenLocking;

let voting;
let version;

let reputationTree;

Expand Down Expand Up @@ -84,8 +85,6 @@ contract("Voting Reputation", (accounts) => {
const USER2 = accounts[2];
const MINER = accounts[5];

const VERSION = 4;

const SALT = soliditySha3({ type: "string", value: shortid.generate() });
const FAKE = soliditySha3({ type: "string", value: shortid.generate() });

Expand Down Expand Up @@ -117,6 +116,9 @@ contract("Voting Reputation", (accounts) => {

const tokenLockingAddress = await colonyNetwork.getTokenLocking();
tokenLocking = await TokenLocking.at(tokenLockingAddress);

const extension = await VotingReputation.new();
version = await extension.version();
});

beforeEach(async () => {
Expand All @@ -129,7 +131,7 @@ contract("Voting Reputation", (accounts) => {
domain2 = await colony.getDomain(2);
domain3 = await colony.getDomain(3);

await colony.installExtension(VOTING_REPUTATION, VERSION);
await colony.installExtension(VOTING_REPUTATION, version);
const votingAddress = await colonyNetwork.getExtensionInstallation(VOTING_REPUTATION, colony.address);
voting = await VotingReputation.at(votingAddress);

Expand Down Expand Up @@ -244,9 +246,7 @@ contract("Voting Reputation", (accounts) => {
await checkErrorRevert(voting.install(colony.address), "extension-already-installed");

const identifier = await voting.identifier();
const version = await voting.version();
expect(identifier).to.equal(VOTING_REPUTATION);
expect(version).to.eq.BN(VERSION);

const capabilityRoles = await voting.getCapabilityRoles("0x0");
expect(capabilityRoles).to.equal(ethers.constants.HashZero);
Expand All @@ -261,9 +261,9 @@ contract("Voting Reputation", (accounts) => {

it("can install the extension with the extension manager", async () => {
({ colony } = await setupRandomColony(colonyNetwork));
await colony.installExtension(VOTING_REPUTATION, VERSION, { from: USER0 });
await colony.installExtension(VOTING_REPUTATION, version, { from: USER0 });

await checkErrorRevert(colony.installExtension(VOTING_REPUTATION, VERSION, { from: USER0 }), "colony-network-extension-already-installed");
await checkErrorRevert(colony.installExtension(VOTING_REPUTATION, version, { from: USER0 }), "colony-network-extension-already-installed");
await checkErrorRevert(colony.uninstallExtension(VOTING_REPUTATION, { from: USER1 }), "ds-auth-unauthorized");

await colony.uninstallExtension(VOTING_REPUTATION, { from: USER0 });
Expand Down
Loading

0 comments on commit fc3e6ba

Please sign in to comment.