Skip to content

Commit

Permalink
Test deprecation of 'old' local skills
Browse files Browse the repository at this point in the history
  • Loading branch information
kronosapiens committed Jul 25, 2024
1 parent e8eb3f9 commit f9dc857
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 1 deletion.
4 changes: 4 additions & 0 deletions contracts/colony/Colony.sol
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,10 @@ contract Colony is BasicMetaTransaction, Multicall, ColonyStorage, PatriciaTreeP
return rootLocalSkill;
}

function getLocalSkill(uint256 _localSkillId) public view returns (LocalSkill memory localSkill) {
localSkill = localSkills[_localSkillId];
}

function verifyReputationProof(
bytes memory key,
bytes memory value,
Expand Down
5 changes: 5 additions & 0 deletions contracts/colony/IColony.sol
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,11 @@ interface IColony is ColonyDataTypes, IRecovery, IBasicMetaTransaction, IMultica
/// @return rootLocalSkill The root local skill id
function getRootLocalSkill() external view returns (uint256 rootLocalSkill);

/// @notice Get the local skill
/// @param localSkillId Id for the local skill
/// @return localSkill The local skill
function getLocalSkill(uint256 localSkillId) external view returns (LocalSkill memory localSkill);

/// @notice Add a colony domain, and its respective local skill under skill with id `_parentSkillId`.
/// New funding pot is created and associated with the domain here.
/// @param _permissionDomainId The domainId in which I have the permission to take this action
Expand Down
17 changes: 17 additions & 0 deletions docs/interfaces/icolony.md
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,23 @@ Get the assigned `_token` payouts of pot with id `_potId`.
|---|---|---|
|payout|uint256|Funding pot payout amount

### `getLocalSkill(uint256 localSkillId):LocalSkill localSkill`

Get the local skill


**Parameters**

|Name|Type|Description|
|---|---|---|
|localSkillId|uint256|Id for the local skill

**Return Parameters**

|Name|Type|Description|
|---|---|---|
|localSkill|LocalSkill|The local skill

### `getNonRewardPotsTotal(address _token):uint256 amount`

Get the total amount of tokens `_token` minus amount reserved to be paid to the reputation and token holders as rewards.
Expand Down
52 changes: 51 additions & 1 deletion test/contracts-network/colony-expenditure.js
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ contract("Colony Expenditure", (accounts) => {
);
});

it.skip("should not allow owners to update a slot skill with a deprecated local skill", async () => {
it("should not allow owners to update a slot skill with a deprecated local skill", async () => {
await colony.deprecateLocalSkill(localSkillId, true);

await checkErrorRevert(colony.setExpenditureSkills(expenditureId, [SLOT0], [localSkillId], { from: ADMIN }), "colony-not-valid-local-skill");
Expand All @@ -324,6 +324,56 @@ contract("Colony Expenditure", (accounts) => {
await checkErrorRevert(colony.setExpenditureSkills(expenditureId, [SLOT0], [100], { from: ADMIN }), "colony-not-valid-local-skill");
});

it("should allow colonies to deprecate 'old' local skills", async () => {
const { OldInterface } = await deployColonyVersionGLWSS4(colonyNetwork);
await deployColonyVersionHMWSS(colonyNetwork);
await downgradeColony(colonyNetwork, colony, "glwss4");

// Make the colonyNetwork the old version
await deployColonyNetworkVersionGLWSS4();

const colonyNetworkAsEtherRouter = await EtherRouter.at(colonyNetwork.address);
const latestResolver = await colonyNetworkAsEtherRouter.resolver();

await downgradeColonyNetwork(colonyNetwork, "glwss4");

// Add two local skills
const oldColony = await OldInterface.at(colony.address);
await oldColony.addLocalSkill();
const localSkillId2 = await colonyNetwork.getSkillCount();
await oldColony.addLocalSkill();
const localSkillId3 = await colonyNetwork.getSkillCount();

// Deprecate localSkillId2 in the old way
await colony.deprecateLocalSkill(localSkillId2, true);

// Upgrade to current version
await colonyNetworkAsEtherRouter.setResolver(latestResolver);
await upgradeColonyOnceThenToLatest(colony);

// Deprecate localSkillId3 in the new way
await colony.deprecateLocalSkill(localSkillId3, true);

const localSkill = await colony.getLocalSkill(localSkillId3);
expect(localSkill.exists).to.be.true;
expect(localSkill.deprecated).to.be.true;

// Both are deprecated
await colony.makeExpenditure(1, UINT256_MAX, 1);
expenditureId = await colony.getExpenditureCount();

await checkErrorRevert(colony.setExpenditureSkills(expenditureId, [SLOT0], [localSkillId2]), "colony-not-valid-local-skill");
await checkErrorRevert(colony.setExpenditureSkills(expenditureId, [SLOT0], [localSkillId3]), "colony-not-valid-local-skill");

// A skill that doesn't exist cannot be deprecated
const fakeLocalSkillId = 10000;
await colony.deprecateLocalSkill(fakeLocalSkillId, true);

const fakeLocalSkill = await colony.getLocalSkill(fakeLocalSkillId);
expect(fakeLocalSkill.exists).to.be.false;
expect(fakeLocalSkill.deprecated).to.be.false;
});

it("should not allow owners to set a (now defunct) global skill, either deprecated or undeprecated", async () => {
const { OldInterface } = await deployColonyVersionGLWSS4(colonyNetwork);
await deployColonyVersionHMWSS(colonyNetwork);
Expand Down

0 comments on commit f9dc857

Please sign in to comment.