WIP: KreditsKit tests #176
16
contracts/test/Spoof.sol
Normal file
16
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 {
|
||||||
|
// ...
|
||||||
|
}
|
@ -24,11 +24,12 @@
|
|||||||
"lint:contracts": "solhint \"contracts/**/*.sol\" \"apps/*/contracts/**/*.sol\"",
|
"lint:contracts": "solhint \"contracts/**/*.sol\" \"apps/*/contracts/**/*.sol\"",
|
||||||
"lint:contract-tests": "eslint apps/*/test",
|
"lint:contract-tests": "eslint apps/*/test",
|
||||||
"lint:wrapper": "eslint lib/",
|
"lint:wrapper": "eslint lib/",
|
||||||
"test": "npm run test:token && npm run test:contributor && npm run test:contribution && npm run test:proposal",
|
"test": "npm run test:token && npm run test:contributor && npm run test:contribution && npm run test:proposal && npm run test:kit",
|
||||||
"test:token": "cd apps/token && npm run test",
|
"test:token": "cd apps/token && npm run test",
|
||||||
"test:contributor": "cd apps/contributor && npm run test",
|
"test:contributor": "cd apps/contributor && npm run test",
|
||||||
"test:contribution": "cd apps/contribution && npm run test",
|
"test:contribution": "cd apps/contribution && npm run test",
|
||||||
"test:proposal": "cd apps/proposal && npm run test",
|
"test:proposal": "cd apps/proposal && npm run test",
|
||||||
|
"test:kit": "aragon contracts test",
|
||||||
"setup-git-hooks": "sh scripts/git-hooks/install"
|
"setup-git-hooks": "sh scripts/git-hooks/install"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
|
88
test/kreditskit.js
Normal file
88
test/kreditskit.js
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
/* eslint-disable no-undef */
|
||||||
|
const namehash = require('ethers').utils.namehash;
|
||||||
|
const KreditsKit = artifacts.require("KreditsKit.sol");
|
||||||
|
const getContract = name => artifacts.require(name);
|
||||||
|
const ZERO_ADDR = '0x0000000000000000000000000000000000000000';
|
||||||
|
const arapp = require('../arapp.json');
|
||||||
|
const ENS_ADDRESS = arapp.environments.development.registry;
|
||||||
|
|
||||||
|
contract('DAO bare kit', (accounts) => {
|
||||||
|
let kreditsKit;
|
||||||
|
let address;
|
||||||
|
let apps;
|
||||||
|
let kernel;
|
||||||
|
let contribution;
|
||||||
|
let contributor;
|
||||||
|
let proposal;
|
||||||
|
let token;
|
||||||
|
|
||||||
|
before(async () => {
|
||||||
|
//apps id
|
||||||
|
const appsId = [];
|
||||||
|
appsId[0] = namehash("kredits-contribution");
|
||||||
|
appsId[1] = namehash("kredits-contributor");
|
||||||
|
appsId[2] = namehash("kredits-proposal");
|
||||||
|
appsId[3] = namehash("kredits-token");
|
||||||
|
|
||||||
|
const kernelBase = await getContract('Kernel').new(true); // petrify immediately
|
||||||
|
const aclBase = await getContract('ACL').new();
|
||||||
|
const daoFactory = await getContract('DAOFactory').new(kernelBase.address, aclBase.address, ZERO_ADDR);
|
||||||
|
|
||||||
|
kreditsKit = await KreditsKit.new(daoFactory.address, ENS_ADDRESS, appsId, { from: accounts[0] });
|
||||||
|
});
|
||||||
|
|
||||||
|
describe("New DAO instance", () => {
|
||||||
|
it("kit should be defined", async () => {
|
||||||
|
assert.notEqual(kreditsKit, undefined);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('it should deploy DAO', async () => {
|
||||||
|
const receipt = await kreditsKit.newInstance({ from: accounts[0] });
|
||||||
|
|
||||||
|
address = receipt.logs.filter(l => l.event === 'DeployInstance')[0].args.dao;
|
||||||
|
apps = receipt.logs
|
||||||
|
.filter(l => l.event === 'InstalledApp')
|
||||||
|
.map(event => {
|
||||||
|
return { id: event.args.appId, proxy: event.args.appProxy };
|
||||||
|
});
|
||||||
|
|
||||||
|
address.should.not.equal(ZERO_ADDR);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('it should install apps', async () => {
|
||||||
|
apps[0].id.should.equal(namehash('kredits-contribution'));
|
||||||
|
apps[1].id.should.equal(namehash('kredits-contributor'));
|
||||||
|
apps[2].id.should.equal(namehash('kredits-proposal'));
|
||||||
|
apps[3].id.should.equal(namehash('kredits-token'));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('it should initialize apps', async () => {
|
||||||
|
contribution = await getContract('Contribution').at(apps[0].proxy);
|
||||||
|
contributor = await getContract('Contributor').at(apps[1].proxy);
|
||||||
|
proposal = await getContract('Proposal').at(apps[2].proxy);
|
||||||
|
token = await getContract('Token').at(apps[3].proxy);
|
||||||
|
(await Promise.all([
|
||||||
|
contribution.hasInitialized(),
|
||||||
|
contributor.hasInitialized(),
|
||||||
|
proposal.hasInitialized(),
|
||||||
|
token.hasInitialized(),
|
||||||
|
])).should.deep.equal([true, true, true, true]);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('it should set permissions', async () => {
|
||||||
|
kernel = await getContract('Kernel').at(address);
|
||||||
|
(await Promise.all([
|
||||||
|
//check contribution app roles
|
||||||
|
kernel.hasPermission(accounts[0], contribution.address, await space.ADD_CONTRIBUTION_ROLE(), '0x0'),
|
||||||
|
kernel.hasPermission(accounts[0], contribution.address, await space.VETO_CONTRIBUTION_ROLE(), '0x0'),
|
||||||
|
kernel.hasPermission(proposal.address, contribution.address, await space.ADD_CONTRIBUTION_ROLE(), '0x0'),
|
||||||
|
//proposal app roles
|
||||||
|
kernel.hasPermission(accounts[0], proposal.address, await proposal.VOTE_PROPOSAL_ROLE(), '0x0'),
|
||||||
|
//token app roles
|
||||||
|
kernel.hasPermission(accounts[0], token.address, await token.MINT_TOKEN_ROLE(), '0x0'),
|
||||||
|
kernel.hasPermission(contribution.address, token.address, await token.MINT_TOKEN_ROLE(), '0x0'),
|
||||||
|
])).should.deep.equal([true, true, true, true, true, true]);
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
});
|
Loading…
x
Reference in New Issue
Block a user