add proposal app tests
This commit is contained in:
parent
2cfc572cc6
commit
314153f6e7
5
apps/contribution/artifacts.js
Normal file
5
apps/contribution/artifacts.js
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
module.exports = {
|
||||||
|
Contribution: artifacts.require('Contribution.sol'),
|
||||||
|
getContributionContract: name => artifacts.require(name)
|
||||||
|
}
|
||||||
|
|
@ -8,7 +8,7 @@ const { assertRevert } = require('@aragon/test-helpers/assertThrow');
|
|||||||
|
|
||||||
const ZERO_ADDR = '0x0000000000000000000000000000000000000000';
|
const ZERO_ADDR = '0x0000000000000000000000000000000000000000';
|
||||||
|
|
||||||
contract('Token app', (accounts) => {
|
contract('Contribution app', (accounts) => {
|
||||||
let kernelBase, aclBase, daoFactory, dao, acl, contribution, token;
|
let kernelBase, aclBase, daoFactory, dao, acl, contribution, token;
|
||||||
|
|
||||||
const root = accounts[0];
|
const root = accounts[0];
|
||||||
|
5
apps/contributor/artifacts.js
Normal file
5
apps/contributor/artifacts.js
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
module.exports = {
|
||||||
|
Contributor: artifacts.require('Contributor.sol'),
|
||||||
|
getContributorContract: name => artifacts.require(name)
|
||||||
|
}
|
||||||
|
|
16
apps/proposal/contracts/test/Spoof.sol
Normal file
16
apps/proposal/contracts/test/Spoof.sol
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
pragma solidity ^0.4.24;
|
||||||
|
|
||||||
|
import "@aragon/os/contracts/acl/ACL.sol";
|
||||||
|
import "@aragon/os/contracts/kernel/Kernel.sol";
|
||||||
|
import "@aragon/os/contracts/factory/DAOFactory.sol";
|
||||||
|
|
||||||
|
// You might think this file is a bit odd, but let me explain.
|
||||||
|
// We only use for now those imported contracts in our tests, which
|
||||||
|
// means Truffle will not compile them for us, because they are from
|
||||||
|
// an external dependency.
|
||||||
|
|
||||||
|
|
||||||
|
// solium-disable-next-line no-empty-blocks
|
||||||
|
contract Spoof {
|
||||||
|
// ...
|
||||||
|
}
|
3350
apps/proposal/package-lock.json
generated
3350
apps/proposal/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -6,13 +6,14 @@
|
|||||||
"@aragon/os": "^4.1.0",
|
"@aragon/os": "^4.1.0",
|
||||||
"@aragon/cli": "^5.5.0"
|
"@aragon/cli": "^5.5.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {},
|
"devDependencies": {
|
||||||
|
"@aragon/test-helpers": "^1.0.0"
|
||||||
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "npm run start:aragon:ipfs",
|
"start": "npm run start:aragon:ipfs",
|
||||||
"start:aragon:ipfs": "aragon run",
|
"start:aragon:ipfs": "aragon run",
|
||||||
"start:aragon:http": "aragon run --http localhost:8001 --http-served-from ./dist",
|
"start:aragon:http": "aragon run --http localhost:8001 --http-served-from ./dist",
|
||||||
"start:app": "",
|
"start:app": "",
|
||||||
"test": "aragon contracts test",
|
|
||||||
"compile": "aragon contracts compile",
|
"compile": "aragon contracts compile",
|
||||||
"sync-assets": "",
|
"sync-assets": "",
|
||||||
"build:app": "",
|
"build:app": "",
|
||||||
@ -21,7 +22,10 @@
|
|||||||
"publish:patch": "aragon apm publish patch",
|
"publish:patch": "aragon apm publish patch",
|
||||||
"publish:minor": "aragon apm publish minor",
|
"publish:minor": "aragon apm publish minor",
|
||||||
"publish:major": "aragon apm publish major",
|
"publish:major": "aragon apm publish major",
|
||||||
"versions": "aragon apm versions"
|
"versions": "aragon apm versions",
|
||||||
|
"ganache-cli:test": "./node_modules/@aragon/test-helpers/ganache-cli.sh",
|
||||||
|
"test": "aragon contracts test",
|
||||||
|
"coverage": "SOLIDITY_COVERAGE=true npm run ganache-cli:test"
|
||||||
},
|
},
|
||||||
"keywords": []
|
"keywords": []
|
||||||
}
|
}
|
||||||
|
@ -1,5 +0,0 @@
|
|||||||
const Proposal = artifacts.require('Proposal.sol')
|
|
||||||
|
|
||||||
contract('Proposal', (accounts) => {
|
|
||||||
it('should be tested')
|
|
||||||
})
|
|
156
apps/proposal/test/proposal.js
Normal file
156
apps/proposal/test/proposal.js
Normal file
@ -0,0 +1,156 @@
|
|||||||
|
const namehash = require('eth-ens-namehash').hash;
|
||||||
|
|
||||||
|
const Proposal = artifacts.require("Proposal.sol");
|
||||||
|
const { Contributor, getContributorContract } = require("../../contributor/artifacts");
|
||||||
|
const { Contribution, getContributionContract } = require("../../contribution/artifacts");
|
||||||
|
|
||||||
|
const getContract = name => artifacts.require(name)
|
||||||
|
const { assertRevert } = require('@aragon/test-helpers/assertThrow');
|
||||||
|
|
||||||
|
const ZERO_ADDR = '0x0000000000000000000000000000000000000000';
|
||||||
|
|
||||||
|
contract('Proposal app', (accounts) => {
|
||||||
|
let kernelBase, aclBase, daoFactory, dao, acl, proposal, contribution, contributor;
|
||||||
|
|
||||||
|
const root = accounts[0];
|
||||||
|
const member1 = accounts[1];
|
||||||
|
|
||||||
|
before(async() => {
|
||||||
|
kernelBase = await getContract('Kernel').new(true) // petrify immediately
|
||||||
|
aclBase = await getContract('ACL').new()
|
||||||
|
daoFactory = await getContract('DAOFactory').new(kernelBase.address, aclBase.address, ZERO_ADDR);
|
||||||
|
r = await daoFactory.newDAO(root)
|
||||||
|
dao = getContract('Kernel').at(r.logs.filter(l => l.event == 'DeployDAO')[0].args.dao)
|
||||||
|
acl = getContract('ACL').at(await dao.acl())
|
||||||
|
|
||||||
|
//create dao mamnager permission for coin owner
|
||||||
|
await acl.createPermission(
|
||||||
|
root,
|
||||||
|
dao.address,
|
||||||
|
await dao.APP_MANAGER_ROLE(),
|
||||||
|
root,
|
||||||
|
{ from: root }
|
||||||
|
);
|
||||||
|
|
||||||
|
//apps id
|
||||||
|
let appsId = [];
|
||||||
|
appsId[0] = namehash("kredits-contribution");
|
||||||
|
appsId[1] = namehash("kredits-contributor");
|
||||||
|
appsId[2] = namehash("kredits-proposal");
|
||||||
|
appsId[3] = namehash("kredits-token");
|
||||||
|
|
||||||
|
|
||||||
|
//get new app instance from DAO
|
||||||
|
let receipt = await dao.newAppInstance(
|
||||||
|
appsId[2],
|
||||||
|
(await Proposal.new()).address,
|
||||||
|
0x0,
|
||||||
|
false,
|
||||||
|
{ from: root }
|
||||||
|
)
|
||||||
|
proposal = Proposal.at(
|
||||||
|
receipt.logs.filter(l => l.event == 'NewAppProxy')[0].args.proxy
|
||||||
|
);
|
||||||
|
|
||||||
|
receipt = await dao.newAppInstance(
|
||||||
|
appsId[1],
|
||||||
|
(await getContributorContract('Contributor').new()).address,
|
||||||
|
0x0,
|
||||||
|
false,
|
||||||
|
{ from: root }
|
||||||
|
)
|
||||||
|
contributor = Contributor.at(
|
||||||
|
receipt.logs.filter(l => l.event == 'NewAppProxy')[0].args.proxy
|
||||||
|
);
|
||||||
|
|
||||||
|
receipt = await dao.newAppInstance(
|
||||||
|
appsId[0],
|
||||||
|
(await getContributionContract('Contribution').new()).address,
|
||||||
|
0x0,
|
||||||
|
false,
|
||||||
|
{ from: root }
|
||||||
|
)
|
||||||
|
contribution = Contribution.at(
|
||||||
|
receipt.logs.filter(l => l.event == 'NewAppProxy')[0].args.proxy
|
||||||
|
);
|
||||||
|
|
||||||
|
//init app
|
||||||
|
await proposal.initialize(appsId);
|
||||||
|
|
||||||
|
await acl.createPermission(
|
||||||
|
root,
|
||||||
|
proposal.address,
|
||||||
|
await proposal.ADD_PROPOSAL_ROLE(),
|
||||||
|
root,
|
||||||
|
{ from: root }
|
||||||
|
)
|
||||||
|
|
||||||
|
await acl.createPermission(
|
||||||
|
root,
|
||||||
|
proposal.address,
|
||||||
|
await proposal.VOTE_PROPOSAL_ROLE(),
|
||||||
|
root,
|
||||||
|
{ from: root }
|
||||||
|
);
|
||||||
|
|
||||||
|
//init contribution (app)
|
||||||
|
await contribution.initialize(appsId);
|
||||||
|
|
||||||
|
await acl.createPermission(
|
||||||
|
root,
|
||||||
|
contribution.address,
|
||||||
|
await contribution.ADD_CONTRIBUTION_ROLE(),
|
||||||
|
root,
|
||||||
|
{ from: root }
|
||||||
|
)
|
||||||
|
|
||||||
|
await acl.createPermission(
|
||||||
|
root,
|
||||||
|
contribution.address,
|
||||||
|
await contribution.VETO_CONTRIBUTION_ROLE(),
|
||||||
|
root,
|
||||||
|
{ from: root }
|
||||||
|
);
|
||||||
|
|
||||||
|
//acl.grantPermission(proposal, contribution, await contribution.ADD_CONTRIBUTION_ROLE(), {from: root});
|
||||||
|
|
||||||
|
//init contributor app
|
||||||
|
await contributor.initialize(appsId);
|
||||||
|
|
||||||
|
await acl.createPermission(
|
||||||
|
root,
|
||||||
|
contributor.address,
|
||||||
|
await contributor.MANAGE_CONTRIBUTORS_ROLE(),
|
||||||
|
root,
|
||||||
|
{ from: root }
|
||||||
|
)
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("Owner default permissions", async() => {
|
||||||
|
it('check owner can add proposal', async() => {
|
||||||
|
let addProposalPermission = await acl.hasPermission(root, proposal.address, await proposal.ADD_PROPOSAL_ROLE());
|
||||||
|
assert.equal(addProposalPermission, true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('check owner can veto contribution', async() => {
|
||||||
|
let vetoProposalPermission = await acl.hasPermission(root, proposal.address, await proposal.VOTE_PROPOSAL_ROLE());
|
||||||
|
assert.equal(vetoProposalPermission, true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('check owner can add contribution', async() => {
|
||||||
|
let addContributionPermission = await acl.hasPermission(root, contribution.address, await contribution.ADD_CONTRIBUTION_ROLE());
|
||||||
|
assert.equal(addContributionPermission, true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('check owner can veto contribution', async() => {
|
||||||
|
let vetoContributionPermission = await acl.hasPermission(root, contribution.address, await contribution.VETO_CONTRIBUTION_ROLE());
|
||||||
|
assert.equal(vetoContributionPermission, true);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('check owner can manage contributors', async() => {
|
||||||
|
let manageContributorsPermission = await acl.hasPermission(root, contributor.address, await contribution.MANAGE_CONTRIBUTORS_ROLE());
|
||||||
|
assert.equal(manageContributorsPermission, true);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
Loading…
x
Reference in New Issue
Block a user