all tests passing
This commit is contained in:
parent
e3c7c3a367
commit
68c5826c35
|
@ -5,14 +5,15 @@ import "./LPVault.sol";
|
||||||
import "./LiquidPledging.sol";
|
import "./LiquidPledging.sol";
|
||||||
import "./LPConstants.sol";
|
import "./LPConstants.sol";
|
||||||
|
|
||||||
contract LPFactory is LPConstants, DAOFactory {
|
contract LPFactory is LPConstants, DAOFactory(new Kernel(), new ACL(), 0) {
|
||||||
|
bytes32 public constant RECOVERY_VAULT_ID = keccak256("recoveryVault");
|
||||||
address public vaultBase;
|
address public vaultBase;
|
||||||
address public lpBase;
|
address public lpBase;
|
||||||
|
|
||||||
event DeployVault(address vault);
|
event DeployVault(address vault);
|
||||||
event DeployLiquidPledging(address liquidPledging);
|
event DeployLiquidPledging(address liquidPledging);
|
||||||
|
|
||||||
function LPFactory(address _vaultBase, address _lpBase) public DAOFactory(new Kernel(), new ACL(), 0) {
|
function LPFactory(address _vaultBase, address _lpBase) public {
|
||||||
require(_vaultBase != 0);
|
require(_vaultBase != 0);
|
||||||
require(_lpBase != 0);
|
require(_lpBase != 0);
|
||||||
vaultBase = _vaultBase;
|
vaultBase = _vaultBase;
|
||||||
|
@ -34,8 +35,8 @@ contract LPFactory is LPConstants, DAOFactory {
|
||||||
lp.initialize(address(v));
|
lp.initialize(address(v));
|
||||||
|
|
||||||
// set the recoveryVault to the escapeHatchDestination
|
// set the recoveryVault to the escapeHatchDestination
|
||||||
kernel.setRecoveryVaultId(keccak256(APP_ADDR_NAMESPACE, keccak256("recoveryVault")));
|
kernel.setRecoveryVaultId(RECOVERY_VAULT_ID);
|
||||||
kernel.setApp(APP_ADDR_NAMESPACE, keccak256("recoveryVault"), _escapeHatchDestination);
|
kernel.setApp(APP_ADDR_NAMESPACE, RECOVERY_VAULT_ID, _escapeHatchDestination);
|
||||||
|
|
||||||
_setPermissions(_root, acl, kernel, v, lp);
|
_setPermissions(_root, acl, kernel, v, lp);
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,17 +85,13 @@ contract LPVault is AragonApp, LiquidPledgingACLHelpers {
|
||||||
_;
|
_;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO if we remove EscapableApp, we won't be able to escape the base contracts???
|
|
||||||
function LPVault() {
|
|
||||||
initialized();
|
|
||||||
};
|
|
||||||
|
|
||||||
/// @param _liquidPledging Address of the liquidPledging instance associated
|
/// @param _liquidPledging Address of the liquidPledging instance associated
|
||||||
/// with this LPVault
|
/// with this LPVault
|
||||||
function initialize(address _liquidPledging) onlyInit external {
|
function initialize(address _liquidPledging) onlyInit external {
|
||||||
require(_liquidPledging != 0x0);
|
require(_liquidPledging != 0x0);
|
||||||
liquidPledging = ILiquidPledging(_liquidPledging);
|
|
||||||
initialized();
|
initialized();
|
||||||
|
|
||||||
|
liquidPledging = ILiquidPledging(_liquidPledging);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @notice Used to decentralize, toggles whether the LPVault will
|
/// @notice Used to decentralize, toggles whether the LPVault will
|
||||||
|
|
|
@ -50,6 +50,7 @@ contract LiquidPledgingBase is AragonApp, LiquidPledgingStorage, PledgeAdmins, P
|
||||||
/// @param _vault The vault where the ETH backing the pledges is stored
|
/// @param _vault The vault where the ETH backing the pledges is stored
|
||||||
function initialize(address _vault) onlyInit public {
|
function initialize(address _vault) onlyInit public {
|
||||||
require(_vault != 0x0);
|
require(_vault != 0x0);
|
||||||
|
initialized();
|
||||||
|
|
||||||
vault = ILPVault(_vault);
|
vault = ILPVault(_vault);
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
pragma solidity ^0.4.18;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* WARNING: for testing only. DO NOT USE
|
||||||
|
**/
|
||||||
|
contract RecoveryVault {}
|
18
index.js
18
index.js
|
@ -10,34 +10,34 @@ const generateClass = require('eth-contract-class').default;
|
||||||
module.exports = {
|
module.exports = {
|
||||||
LiquidPledging: generateClass(
|
LiquidPledging: generateClass(
|
||||||
LiquidPledgingArtifact.compilerOutput.abi,
|
LiquidPledgingArtifact.compilerOutput.abi,
|
||||||
`0x${LiquidPledgingArtifact.compilerOutput.evm.bytecode.object}`,
|
LiquidPledgingArtifact.compilerOutput.evm.bytecode.object,
|
||||||
),
|
),
|
||||||
LPFactory: generateClass(
|
LPFactory: generateClass(
|
||||||
LPFactoryArtifact.compilerOutput.abi,
|
LPFactoryArtifact.compilerOutput.abi,
|
||||||
`0x${LPFactoryArtifact.compilerOutput.evm.bytecode.object}`,
|
LPFactoryArtifact.compilerOutput.evm.bytecode.object,
|
||||||
),
|
),
|
||||||
LiquidPledgingState: require('./lib/liquidPledgingState.js'),
|
LiquidPledgingState: require('./lib/liquidPledgingState.js'),
|
||||||
LPVault: generateClass(
|
LPVault: generateClass(
|
||||||
LPVaultArtifact.compilerOutput.abi,
|
LPVaultArtifact.compilerOutput.abi,
|
||||||
`0x${LPVaultArtifact.compilerOutput.evm.bytecode.object}`,
|
LPVaultArtifact.compilerOutput.evm.bytecode.object,
|
||||||
),
|
),
|
||||||
Kernel: generateClass(
|
Kernel: generateClass(
|
||||||
KernelArtifact.compilerOutput.abi,
|
KernelArtifact.compilerOutput.abi,
|
||||||
`0x${KernelArtifact.compilerOutput.evm.bytecode.object}`,
|
KernelArtifact.compilerOutput.evm.bytecode.object,
|
||||||
),
|
),
|
||||||
ACL: generateClass(
|
ACL: generateClass(
|
||||||
ACLArtifact.compilerOutput.abi,
|
ACLArtifact.compilerOutput.abi,
|
||||||
`0x${ACLArtifact.compilerOutput.evm.bytecode.object}`,
|
ACLArtifact.compilerOutput.evm.bytecode.object,
|
||||||
),
|
),
|
||||||
test: {
|
test: {
|
||||||
StandardTokenTest: generateClass(
|
StandardTokenTest: generateClass(
|
||||||
StandardTokenTestAtifact.compilerOutput.abi,
|
StandardTokenTestAtifact.compilerOutput.abi,
|
||||||
`0x${StandardTokenTestAtifact.compilerOutput.evm.bytecode.object}`,
|
StandardTokenTestAtifact.compilerOutput.evm.bytecode.object,
|
||||||
),
|
),
|
||||||
assertFail: require('./test/helpers/assertFail'),
|
assertFail: require('./test/helpers/assertFail'),
|
||||||
LiquidPledgingMock: generateClass(
|
LiquidPledgingMock: generateClass(
|
||||||
LiquidPledgingMockArtifact.compilerOutput.abi,
|
LiquidPledgingMockArtifact.compilerOutput.abi,
|
||||||
`0x${LiquidPledgingMockArtifact.compilerOutput.evm.bytecode.object}`,
|
LiquidPledgingMockArtifact.compilerOutput.evm.bytecode.object,
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
|
@ -3428,9 +3428,9 @@
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"eth-contract-class": {
|
"eth-contract-class": {
|
||||||
"version": "0.0.9",
|
"version": "0.0.10",
|
||||||
"resolved": "https://registry.npmjs.org/eth-contract-class/-/eth-contract-class-0.0.9.tgz",
|
"resolved": "https://registry.npmjs.org/eth-contract-class/-/eth-contract-class-0.0.10.tgz",
|
||||||
"integrity": "sha512-GPYELUmWGytLNmtZMfEDywlpbVAnG1VVvjJ9RPjZQXmdV/lOnjLRX6RO8Gyy02e4tFzy6o9jFQ7tTYernMN1eg==",
|
"integrity": "sha512-WfEzKkQgtO3Q+SAy48NDGADPMq6cEXustA6OD8y51WMWb9HpP7gxajh8t8MquPyg0fm6Z//42nEASkM1e8RhhA==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"web3-core-promievent": "^1.0.0-beta.21"
|
"web3-core-promievent": "^1.0.0-beta.21"
|
||||||
}
|
}
|
||||||
|
@ -10207,14 +10207,14 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"solcpiler": {
|
"solcpiler": {
|
||||||
"version": "1.0.0-beta.3",
|
"version": "1.0.0-beta.5",
|
||||||
"resolved": "https://registry.npmjs.org/solcpiler/-/solcpiler-1.0.0-beta.3.tgz",
|
"resolved": "https://registry.npmjs.org/solcpiler/-/solcpiler-1.0.0-beta.5.tgz",
|
||||||
"integrity": "sha512-s3INuICPz9xOk3ayybyYLqfwGth6XIXansIDKleDBxlgJ8zPjcp8uy3RHHXiVDFSX8k3upIAT3lwNfwtkg1Xfw==",
|
"integrity": "sha512-cfKUgeSnuwM2NTp0o8PVfHLfRjnEzlPTNNOXX0AQhNVdeEq03yYd8SLK0x66HKXSL6cL42KWyi4oHk8Y8m/jSA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"app-root-path": "^2.0.1",
|
"app-root-path": "^2.0.1",
|
||||||
"async": "^2.5.0",
|
"async": "^2.5.0",
|
||||||
"eth-contract-class": "^0.0.9",
|
"eth-contract-class": "^0.0.10",
|
||||||
"globby": "^8.0.1",
|
"globby": "^8.0.1",
|
||||||
"lodash": "^4.17.4",
|
"lodash": "^4.17.4",
|
||||||
"mkdirp": "^0.5.1",
|
"mkdirp": "^0.5.1",
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "npm run build && mocha --harmony",
|
"test": "npm run build && mocha --harmony",
|
||||||
"compile:sol": "solcpiler -i './contracts/**/*.sol' ./node_modules/@aragon/os/contracts/{kernel/Kernel.sol,acl/ACL.sol} --output-sol-dir build/contracts",
|
"compile:sol": "solcpiler --solc-version v0.4.18+commit.9cf6e910 -i './contracts/**/*.sol' ./node_modules/@aragon/os/contracts/{kernel/Kernel.sol,acl/ACL.sol} --output-sol-dir build/contracts",
|
||||||
"compile:js": "babel -d lib/ js/",
|
"compile:js": "babel -d lib/ js/",
|
||||||
"compile": "npm run compile:sol && npm run compile:js",
|
"compile": "npm run compile:sol && npm run compile:js",
|
||||||
"build": "npm run compile",
|
"build": "npm run compile",
|
||||||
|
@ -45,7 +45,7 @@
|
||||||
"lerna": "^2.2.0",
|
"lerna": "^2.2.0",
|
||||||
"mocha": "^3.5.0",
|
"mocha": "^3.5.0",
|
||||||
"random-bytes": "^1.0.0",
|
"random-bytes": "^1.0.0",
|
||||||
"solcpiler": "1.0.0-beta.3",
|
"solcpiler": "1.0.0-beta.5",
|
||||||
"web3": "1.0.0-beta.34"
|
"web3": "1.0.0-beta.34"
|
||||||
},
|
},
|
||||||
"homepage": "https://github.com/Giveth/liquidpledging#readme",
|
"homepage": "https://github.com/Giveth/liquidpledging#readme",
|
||||||
|
@ -53,6 +53,6 @@
|
||||||
"@aragon/os": "3.1.9",
|
"@aragon/os": "3.1.9",
|
||||||
"async": "^2.4.0",
|
"async": "^2.4.0",
|
||||||
"chai": "^4.1.0",
|
"chai": "^4.1.0",
|
||||||
"eth-contract-class": "^0.0.9"
|
"eth-contract-class": "^0.0.10"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,24 +1,18 @@
|
||||||
/* eslint-env mocha */
|
/* eslint-env mocha */
|
||||||
/* eslint-disable no-await-in-loop */
|
/* eslint-disable no-await-in-loop */
|
||||||
const TestRPC = require('ganache-cli');
|
const Ganache = require('ganache-cli');
|
||||||
const Web3 = require('web3');
|
const Web3 = require('web3');
|
||||||
const chai = require('chai');
|
const chai = require('chai');
|
||||||
const {
|
const { test } = require('../index');
|
||||||
LPVault,
|
const deployLP = require('./helpers/deployLP');
|
||||||
LPFactory,
|
|
||||||
LiquidPledgingState,
|
|
||||||
test,
|
|
||||||
} = require('../index');
|
|
||||||
|
|
||||||
const simpleProjectPluginFactoryAbi = require('../build/TestSimpleProjectPluginFactory.sol')
|
const { compilerOutput } = require('../build/TestSimpleProjectPluginFactory.json');
|
||||||
.TestSimpleProjectPluginFactoryAbi;
|
const simpleProjectPluginFactoryAbi = compilerOutput.abi;
|
||||||
const simpleProjectPluginFactoryByteCode = require('../build/TestSimpleProjectPluginFactory.sol')
|
const simpleProjectPluginFactoryByteCode = compilerOutput.evm.bytecode.object;
|
||||||
.TestSimpleProjectPluginFactoryByteCode;
|
const simpleProjectPluginRuntimeByteCode = '0x' + require('../build/TestSimpleProjectPlugin.json').compilerOutput.evm.deployedBytecode.object;
|
||||||
const simpleProjectPluginRuntimeByteCode = require('../build/TestSimpleProjectPluginFactory.sol')
|
|
||||||
.TestSimpleProjectPluginRuntimeByteCode;
|
|
||||||
const assert = chai.assert;
|
const assert = chai.assert;
|
||||||
|
|
||||||
const { StandardTokenTest, assertFail, LiquidPledgingMock } = test;
|
const { assertFail } = test;
|
||||||
|
|
||||||
const printState = async liquidPledgingState => {
|
const printState = async liquidPledgingState => {
|
||||||
const st = await liquidPledgingState.getState();
|
const st = await liquidPledgingState.getState();
|
||||||
|
@ -28,7 +22,7 @@ const printState = async liquidPledgingState => {
|
||||||
describe('LiquidPledging plugins test', function() {
|
describe('LiquidPledging plugins test', function() {
|
||||||
this.timeout(0);
|
this.timeout(0);
|
||||||
|
|
||||||
let testrpc;
|
let ganache;
|
||||||
let web3;
|
let web3;
|
||||||
let accounts;
|
let accounts;
|
||||||
let liquidPledging;
|
let liquidPledging;
|
||||||
|
@ -37,48 +31,32 @@ describe('LiquidPledging plugins test', function() {
|
||||||
let giver1;
|
let giver1;
|
||||||
let adminProject1;
|
let adminProject1;
|
||||||
let adminDelegate1;
|
let adminDelegate1;
|
||||||
let token;
|
|
||||||
|
|
||||||
before(async () => {
|
before(async () => {
|
||||||
testrpc = TestRPC.server({
|
ganache = Ganache.server({
|
||||||
gasLimit: 6700000,
|
gasLimit: 6700000,
|
||||||
total_accounts: 10,
|
total_accounts: 10,
|
||||||
});
|
});
|
||||||
|
|
||||||
testrpc.listen(8545, '127.0.0.1');
|
ganache.listen(8545, '127.0.0.1');
|
||||||
|
|
||||||
web3 = new Web3('http://localhost:8545');
|
web3 = new Web3('http://localhost:8545');
|
||||||
accounts = await web3.eth.getAccounts();
|
accounts = await web3.eth.getAccounts();
|
||||||
giver1 = accounts[1];
|
|
||||||
adminProject1 = accounts[2];
|
adminProject1 = accounts[2];
|
||||||
adminDelegate1 = accounts[3];
|
adminDelegate1 = accounts[3];
|
||||||
|
|
||||||
|
const deployment = await deployLP(web3);
|
||||||
|
giver1 = deployment.giver1;
|
||||||
|
vault = deployment.vault;
|
||||||
|
liquidPledging = deployment.liquidPledging;
|
||||||
|
liquidPledgingState = deployment.liquidPledgingState;
|
||||||
});
|
});
|
||||||
|
|
||||||
after(done => {
|
after(done => {
|
||||||
testrpc.close();
|
ganache.close();
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Should deploy LiquidPledging contract', async function() {
|
|
||||||
const baseVault = await LPVault.new(web3, accounts[0]);
|
|
||||||
const baseLP = await LiquidPledgingMock.new(web3, accounts[0]);
|
|
||||||
lpFactory = await LPFactory.new(web3, baseVault.$address, baseLP.$address);
|
|
||||||
|
|
||||||
const r = await lpFactory.newLP(accounts[0], accounts[0]);
|
|
||||||
|
|
||||||
const vaultAddress = r.events.DeployVault.returnValues.vault;
|
|
||||||
vault = new LPVault(web3, vaultAddress);
|
|
||||||
|
|
||||||
const lpAddress = r.events.DeployLiquidPledging.returnValues.liquidPledging;
|
|
||||||
liquidPledging = new LiquidPledgingMock(web3, lpAddress);
|
|
||||||
|
|
||||||
liquidPledgingState = new LiquidPledgingState(liquidPledging);
|
|
||||||
|
|
||||||
token = await StandardTokenTest.new(web3);
|
|
||||||
await token.mint(giver1, web3.utils.toWei('1000'));
|
|
||||||
await token.approve(liquidPledging.$address, '0xFFFFFFFFFFFFFFFF', { from: giver1 });
|
|
||||||
});
|
|
||||||
|
|
||||||
it('Should create create giver with no plugin', async function() {
|
it('Should create create giver with no plugin', async function() {
|
||||||
await liquidPledging.addGiver('Giver1', '', 0, '0x0', { from: adminProject1 });
|
await liquidPledging.addGiver('Giver1', '', 0, '0x0', { from: adminProject1 });
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
/* eslint-env mocha */
|
/* eslint-env mocha */
|
||||||
/* eslint-disable no-await-in-loop */
|
/* eslint-disable no-await-in-loop */
|
||||||
const TestRPC = require('ganache-cli');
|
const Ganache = require('ganache-cli');
|
||||||
const Web3 = require('web3');
|
const Web3 = require('web3');
|
||||||
const { assert } = require('chai');
|
const { assert } = require('chai');
|
||||||
const { LPVault, LPFactory, LiquidPledgingState, test } = require('../index');
|
const { test } = require('../index');
|
||||||
|
const deployLP = require('./helpers/deployLP');
|
||||||
|
|
||||||
const { StandardTokenTest, assertFail, LiquidPledgingMock } = test;
|
const { assertFail } = test;
|
||||||
|
|
||||||
const printState = async liquidPledgingState => {
|
const printState = async liquidPledgingState => {
|
||||||
const st = await liquidPledgingState.getState();
|
const st = await liquidPledgingState.getState();
|
||||||
|
@ -15,7 +16,7 @@ const printState = async liquidPledgingState => {
|
||||||
describe('LiquidPledging cancelPledge normal scenario', function() {
|
describe('LiquidPledging cancelPledge normal scenario', function() {
|
||||||
this.timeout(0);
|
this.timeout(0);
|
||||||
|
|
||||||
let testrpc;
|
let ganache;
|
||||||
let web3;
|
let web3;
|
||||||
let accounts;
|
let accounts;
|
||||||
let liquidPledging;
|
let liquidPledging;
|
||||||
|
@ -27,45 +28,31 @@ describe('LiquidPledging cancelPledge normal scenario', function() {
|
||||||
let token;
|
let token;
|
||||||
|
|
||||||
before(async () => {
|
before(async () => {
|
||||||
testrpc = TestRPC.server({
|
ganache = Ganache.server({
|
||||||
gasLimit: 6700000,
|
gasLimit: 6700000,
|
||||||
total_accounts: 10,
|
total_accounts: 10,
|
||||||
});
|
});
|
||||||
|
|
||||||
testrpc.listen(8545, '127.0.0.1');
|
ganache.listen(8545, '127.0.0.1');
|
||||||
|
|
||||||
web3 = new Web3('http://localhost:8545');
|
web3 = new Web3('http://localhost:8545');
|
||||||
accounts = await web3.eth.getAccounts();
|
accounts = await web3.eth.getAccounts();
|
||||||
giver1 = accounts[1];
|
|
||||||
adminProject1 = accounts[2];
|
adminProject1 = accounts[2];
|
||||||
adminProject2 = accounts[3];
|
adminProject2 = accounts[3];
|
||||||
|
|
||||||
|
const deployment = await deployLP(web3);
|
||||||
|
giver1 = deployment.giver1;
|
||||||
|
vault = deployment.vault;
|
||||||
|
liquidPledging = deployment.liquidPledging;
|
||||||
|
liquidPledgingState = deployment.liquidPledgingState;
|
||||||
|
token = deployment.token;
|
||||||
});
|
});
|
||||||
|
|
||||||
after(done => {
|
after(done => {
|
||||||
testrpc.close();
|
ganache.close();
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Should deploy LiquidPledging contract', async () => {
|
|
||||||
const baseVault = await LPVault.new(web3, accounts[0]);
|
|
||||||
const baseLP = await LiquidPledgingMock.new(web3, accounts[0]);
|
|
||||||
lpFactory = await LPFactory.new(web3, baseVault.$address, baseLP.$address);
|
|
||||||
|
|
||||||
const r = await lpFactory.newLP(accounts[0], accounts[0]);
|
|
||||||
|
|
||||||
const vaultAddress = r.events.DeployVault.returnValues.vault;
|
|
||||||
vault = new LPVault(web3, vaultAddress);
|
|
||||||
|
|
||||||
const lpAddress = r.events.DeployLiquidPledging.returnValues.liquidPledging;
|
|
||||||
liquidPledging = new LiquidPledgingMock(web3, lpAddress);
|
|
||||||
|
|
||||||
liquidPledgingState = new LiquidPledgingState(liquidPledging);
|
|
||||||
|
|
||||||
token = await StandardTokenTest.new(web3);
|
|
||||||
await token.mint(giver1, web3.utils.toWei('1000'));
|
|
||||||
await token.approve(liquidPledging.$address, '0xFFFFFFFFFFFFFFFF', { from: giver1 });
|
|
||||||
});
|
|
||||||
|
|
||||||
it('Should add project and donate ', async () => {
|
it('Should add project and donate ', async () => {
|
||||||
await liquidPledging.addProject('Project1', 'URLProject1', adminProject1, 0, 0, '0x0', {
|
await liquidPledging.addProject('Project1', 'URLProject1', adminProject1, 0, 0, '0x0', {
|
||||||
from: adminProject1,
|
from: adminProject1,
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
/* eslint-env mocha */
|
/* eslint-env mocha */
|
||||||
/* eslint-disable no-await-in-loop */
|
/* eslint-disable no-await-in-loop */
|
||||||
const TestRPC = require('ganache-cli');
|
const Ganache = require('ganache-cli');
|
||||||
const Web3 = require('web3');
|
const Web3 = require('web3');
|
||||||
const { assert } = require('chai');
|
const { assert } = require('chai');
|
||||||
const { LPVault, LPFactory, LiquidPledgingState, test } = require('../index');
|
const { test } = require('../index');
|
||||||
|
const deployLP = require('./helpers/deployLP');
|
||||||
|
|
||||||
const { StandardTokenTest, assertFail, LiquidPledgingMock } = test;
|
const { assertFail } = test;
|
||||||
|
|
||||||
const printState = async liquidPledgingState => {
|
const printState = async liquidPledgingState => {
|
||||||
const st = await liquidPledgingState.getState();
|
const st = await liquidPledgingState.getState();
|
||||||
|
@ -15,7 +16,7 @@ const printState = async liquidPledgingState => {
|
||||||
describe('DelegationChain test', function() {
|
describe('DelegationChain test', function() {
|
||||||
this.timeout(0);
|
this.timeout(0);
|
||||||
|
|
||||||
let testrpc;
|
let ganache;
|
||||||
let web3;
|
let web3;
|
||||||
let accounts;
|
let accounts;
|
||||||
let liquidPledging;
|
let liquidPledging;
|
||||||
|
@ -31,48 +32,34 @@ describe('DelegationChain test', function() {
|
||||||
|
|
||||||
const gasUsage = {};
|
const gasUsage = {};
|
||||||
before(async () => {
|
before(async () => {
|
||||||
testrpc = TestRPC.server({
|
ganache = Ganache.server({
|
||||||
gasLimit: 6700000,
|
gasLimit: 6700000,
|
||||||
total_accounts: 10,
|
total_accounts: 10,
|
||||||
});
|
});
|
||||||
|
|
||||||
testrpc.listen(8545, '127.0.0.1');
|
ganache.listen(8545, '127.0.0.1');
|
||||||
|
|
||||||
web3 = new Web3('http://localhost:8545');
|
web3 = new Web3('http://localhost:8545');
|
||||||
accounts = await web3.eth.getAccounts();
|
accounts = await web3.eth.getAccounts();
|
||||||
giver1 = accounts[1];
|
|
||||||
delegate1 = accounts[2];
|
delegate1 = accounts[2];
|
||||||
delegate2 = accounts[3];
|
delegate2 = accounts[3];
|
||||||
delegate3 = accounts[4];
|
delegate3 = accounts[4];
|
||||||
adminProject1 = accounts[5];
|
adminProject1 = accounts[5];
|
||||||
giver2 = accounts[6];
|
giver2 = accounts[6];
|
||||||
|
|
||||||
|
const deployment = await deployLP(web3);
|
||||||
|
giver1 = deployment.giver1;
|
||||||
|
vault = deployment.vault;
|
||||||
|
liquidPledging = deployment.liquidPledging;
|
||||||
|
liquidPledgingState = deployment.liquidPledgingState;
|
||||||
|
token = deployment.token;
|
||||||
});
|
});
|
||||||
|
|
||||||
after(done => {
|
after(done => {
|
||||||
testrpc.close();
|
ganache.close();
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Should deploy LiquidPledging contract', async () => {
|
|
||||||
const baseVault = await LPVault.new(web3, accounts[0]);
|
|
||||||
const baseLP = await LiquidPledgingMock.new(web3, accounts[0]);
|
|
||||||
lpFactory = await LPFactory.new(web3, baseVault.$address, baseLP.$address);
|
|
||||||
|
|
||||||
const r = await lpFactory.newLP(accounts[0], accounts[0]);
|
|
||||||
|
|
||||||
const vaultAddress = r.events.DeployVault.returnValues.vault;
|
|
||||||
vault = new LPVault(web3, vaultAddress);
|
|
||||||
|
|
||||||
const lpAddress = r.events.DeployLiquidPledging.returnValues.liquidPledging;
|
|
||||||
liquidPledging = new LiquidPledgingMock(web3, lpAddress);
|
|
||||||
|
|
||||||
liquidPledgingState = new LiquidPledgingState(liquidPledging);
|
|
||||||
|
|
||||||
token = await StandardTokenTest.new(web3);
|
|
||||||
await token.mint(giver1, web3.utils.toWei('1000'));
|
|
||||||
await token.approve(liquidPledging.$address, '0xFFFFFFFFFFFFFFFF', { from: giver1 });
|
|
||||||
});
|
|
||||||
|
|
||||||
it('Should add pledgeAdmins', async () => {
|
it('Should add pledgeAdmins', async () => {
|
||||||
await liquidPledging.addGiver('Giver1', 'URLGiver1', 86400, 0, { from: giver1 }); // pledgeAdmin 1
|
await liquidPledging.addGiver('Giver1', 'URLGiver1', 86400, 0, { from: giver1 }); // pledgeAdmin 1
|
||||||
await liquidPledging.addDelegate('Delegate1', 'URLDelegate1', 259200, 0, { from: delegate1 }); // pledgeAdmin 2
|
await liquidPledging.addDelegate('Delegate1', 'URLDelegate1', 259200, 0, { from: delegate1 }); // pledgeAdmin 2
|
||||||
|
|
|
@ -4,10 +4,11 @@ const TestRPC = require('ganache-cli');
|
||||||
const Web3 = require('web3');
|
const Web3 = require('web3');
|
||||||
const { assert } = require('chai');
|
const { assert } = require('chai');
|
||||||
const { LPVault, LPFactory, LiquidPledgingState, Kernel, ACL, test } = require('../index');
|
const { LPVault, LPFactory, LiquidPledgingState, Kernel, ACL, test } = require('../index');
|
||||||
|
const { RecoveryVault } = require('../build/contracts');
|
||||||
|
|
||||||
const { StandardTokenTest, assertFail, LiquidPledgingMock } = test;
|
const { StandardTokenTest, assertFail, LiquidPledgingMock } = test;
|
||||||
|
|
||||||
describe('Vault test', function() {
|
describe('LPVault test', function() {
|
||||||
this.timeout(0);
|
this.timeout(0);
|
||||||
|
|
||||||
let testrpc;
|
let testrpc;
|
||||||
|
@ -18,7 +19,7 @@ describe('Vault test', function() {
|
||||||
let vault;
|
let vault;
|
||||||
let vaultOwner;
|
let vaultOwner;
|
||||||
let escapeHatchCaller;
|
let escapeHatchCaller;
|
||||||
let escapeHatchDestination;
|
let recoveryVault;
|
||||||
let giver1;
|
let giver1;
|
||||||
let adminProject1;
|
let adminProject1;
|
||||||
let restrictedPaymentsConfirmer;
|
let restrictedPaymentsConfirmer;
|
||||||
|
@ -37,9 +38,9 @@ describe('Vault test', function() {
|
||||||
giver1 = accounts[1];
|
giver1 = accounts[1];
|
||||||
adminProject1 = accounts[2];
|
adminProject1 = accounts[2];
|
||||||
vaultOwner = accounts[3];
|
vaultOwner = accounts[3];
|
||||||
escapeHatchDestination = accounts[4];
|
escapeHatchCaller = accounts[4];
|
||||||
escapeHatchCaller = accounts[5];
|
recoveryVault = (await RecoveryVault.new(web3)).$address;
|
||||||
restrictedPaymentsConfirmer = accounts[6];
|
restrictedPaymentsConfirmer = accounts[5];
|
||||||
});
|
});
|
||||||
|
|
||||||
after(done => {
|
after(done => {
|
||||||
|
@ -47,12 +48,14 @@ describe('Vault test', function() {
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Should deploy Vault contract', async function() {
|
it('Should deploy LPVault contract', async function() {
|
||||||
const baseVault = await LPVault.new(web3, escapeHatchDestination);
|
const baseVault = await LPVault.new(web3);
|
||||||
const baseLP = await LiquidPledgingMock.new(web3, escapeHatchDestination);
|
const baseLP = await LiquidPledgingMock.new(web3, {
|
||||||
lpFactory = await LPFactory.new(web3, baseVault.$address, baseLP.$address);
|
gas: 6700000,
|
||||||
|
});
|
||||||
|
lpFactory = await LPFactory.new(web3, baseVault.$address, baseLP.$address, { gas: 6700000 });
|
||||||
|
|
||||||
const r = await lpFactory.newLP(accounts[0], escapeHatchDestination);
|
const r = await lpFactory.newLP(accounts[0], recoveryVault);
|
||||||
|
|
||||||
const vaultAddress = r.events.DeployVault.returnValues.vault;
|
const vaultAddress = r.events.DeployVault.returnValues.vault;
|
||||||
vault = new LPVault(web3, vaultAddress);
|
vault = new LPVault(web3, vaultAddress);
|
||||||
|
@ -85,12 +88,6 @@ describe('Vault test', function() {
|
||||||
await vault.ESCAPE_HATCH_CALLER_ROLE(),
|
await vault.ESCAPE_HATCH_CALLER_ROLE(),
|
||||||
{ $extraGas: 200000 },
|
{ $extraGas: 200000 },
|
||||||
);
|
);
|
||||||
await acl.revokePermission(
|
|
||||||
accounts[0],
|
|
||||||
vault.$address,
|
|
||||||
await vault.ESCAPE_HATCH_CALLER_ROLE(),
|
|
||||||
{ $extraGas: 200000 },
|
|
||||||
);
|
|
||||||
|
|
||||||
await liquidPledging.addGiver('Giver1', '', 0, '0x0', { from: giver1, $extraGas: 100000 });
|
await liquidPledging.addGiver('Giver1', '', 0, '0x0', { from: giver1, $extraGas: 100000 });
|
||||||
await liquidPledging.addProject('Project1', '', adminProject1, 0, 0, '0x0', {
|
await liquidPledging.addProject('Project1', '', adminProject1, 0, 0, '0x0', {
|
||||||
|
@ -116,35 +113,6 @@ describe('Vault test', function() {
|
||||||
assert.equal(10000, balance);
|
assert.equal(10000, balance);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('escapeFunds should fail', async function() {
|
|
||||||
// only vaultOwner can escapeFunds
|
|
||||||
await assertFail(vault.escapeFunds(0x0, 1000, { gas: 4000000 }));
|
|
||||||
|
|
||||||
// can't send more then the balance
|
|
||||||
await assertFail(vault.escapeFunds(0x0, 11000, { from: vaultOwner, gas: 4000000 }));
|
|
||||||
});
|
|
||||||
|
|
||||||
it('escapeFunds should send funds to escapeHatchDestination', async function() {
|
|
||||||
const preBalance = await token.balanceOf(escapeHatchDestination);
|
|
||||||
|
|
||||||
await assertFail(vault.escapeFunds(0x0, 1000, { from: escapeHatchCaller, gas: 1000000 }));
|
|
||||||
|
|
||||||
await vault.escapeFunds(token.$address, 1000, { from: escapeHatchCaller, $extraGas: 200000 });
|
|
||||||
|
|
||||||
const vaultBalance = await token.balanceOf(vault.$address);
|
|
||||||
assert.equal(9000, vaultBalance);
|
|
||||||
|
|
||||||
const expected = web3.utils
|
|
||||||
.toBN(preBalance)
|
|
||||||
.add(web3.utils.toBN('1000'))
|
|
||||||
.toString();
|
|
||||||
const postBalance = await token.balanceOf(escapeHatchDestination);
|
|
||||||
|
|
||||||
assert.equal(expected, postBalance);
|
|
||||||
|
|
||||||
await token.transfer(vault.$address, 1000, { from: escapeHatchDestination, $extraGas: 200000 });
|
|
||||||
});
|
|
||||||
|
|
||||||
it('should restrict confirm payment to payments under specified amount', async function() {
|
it('should restrict confirm payment to payments under specified amount', async function() {
|
||||||
await liquidPledging.withdraw(2, 300, { from: adminProject1, $extraGas: 200000 });
|
await liquidPledging.withdraw(2, 300, { from: adminProject1, $extraGas: 200000 });
|
||||||
await liquidPledging.withdraw(2, 700, { from: adminProject1, $extraGas: 200000 });
|
await liquidPledging.withdraw(2, 700, { from: adminProject1, $extraGas: 200000 });
|
||||||
|
@ -161,4 +129,21 @@ describe('Vault test', function() {
|
||||||
await assertFail(vault.confirmPayment(1, { from: restrictedPaymentsConfirmer, gas: 4000000 }));
|
await assertFail(vault.confirmPayment(1, { from: restrictedPaymentsConfirmer, gas: 4000000 }));
|
||||||
await vault.confirmPayment(0, { from: restrictedPaymentsConfirmer, $extraGas: 200000 });
|
await vault.confirmPayment(0, { from: restrictedPaymentsConfirmer, $extraGas: 200000 });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('Only escapeHatchCaller role should be able to pull "escapeHatch"', async function() {
|
||||||
|
const preVaultBalance = await token.balanceOf(vault.$address);
|
||||||
|
|
||||||
|
// transferToVault is a bit confusing, but is the name of the function in aragonOs
|
||||||
|
// this is the escapeHatch and will transfer all funds to the recoveryVault
|
||||||
|
await assertFail(vault.transferToVault(token.$address, { from: vaultOwner, gas: 6700000 }));
|
||||||
|
assert.equal(await token.balanceOf(vault.$address), preVaultBalance);
|
||||||
|
|
||||||
|
await vault.transferToVault(token.$address, { from: escapeHatchCaller, $extraGas: 100000 });
|
||||||
|
|
||||||
|
const vaultBalance = await token.balanceOf(vault.$address);
|
||||||
|
assert.equal(0, vaultBalance);
|
||||||
|
|
||||||
|
const recoveryVaultBalance = await token.balanceOf(recoveryVault);
|
||||||
|
assert.equal(preVaultBalance, recoveryVaultBalance);
|
||||||
|
});
|
||||||
});
|
});
|
|
@ -4,6 +4,7 @@ const Ganache = require('ganache-cli');
|
||||||
const Web3 = require('web3');
|
const Web3 = require('web3');
|
||||||
const { assert } = require('chai');
|
const { assert } = require('chai');
|
||||||
const { LPVault, LPFactory, LiquidPledgingState, Kernel, ACL, test } = require('../index');
|
const { LPVault, LPFactory, LiquidPledgingState, Kernel, ACL, test } = require('../index');
|
||||||
|
const { RecoveryVault } = require('../build/contracts');
|
||||||
|
|
||||||
const { StandardTokenTest, assertFail, LiquidPledgingMock } = test;
|
const { StandardTokenTest, assertFail, LiquidPledgingMock } = test;
|
||||||
const { utils } = Web3;
|
const { utils } = Web3;
|
||||||
|
@ -29,7 +30,7 @@ describe('LiquidPledging test', function() {
|
||||||
let adminProject2a;
|
let adminProject2a;
|
||||||
let adminProject3;
|
let adminProject3;
|
||||||
let delegate2;
|
let delegate2;
|
||||||
let escapeHatchDestination;
|
let recoveryVault;
|
||||||
let escapeHatchCaller;
|
let escapeHatchCaller;
|
||||||
let acl;
|
let acl;
|
||||||
let giver1Token;
|
let giver1Token;
|
||||||
|
@ -53,7 +54,7 @@ describe('LiquidPledging test', function() {
|
||||||
delegate2 = accounts[6];
|
delegate2 = accounts[6];
|
||||||
giver2 = accounts[7];
|
giver2 = accounts[7];
|
||||||
adminProject3 = accounts[8];
|
adminProject3 = accounts[8];
|
||||||
escapeHatchDestination = accounts[9];
|
recoveryVault = (await RecoveryVault.new(web3)).$address;
|
||||||
escapeHatchCaller = accounts[10];
|
escapeHatchCaller = accounts[10];
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -69,10 +70,7 @@ describe('LiquidPledging test', function() {
|
||||||
});
|
});
|
||||||
lpFactory = await LPFactory.new(web3, baseVault.$address, baseLP.$address, { gas: 6700000 });
|
lpFactory = await LPFactory.new(web3, baseVault.$address, baseLP.$address, { gas: 6700000 });
|
||||||
|
|
||||||
assert.isAbove(Number(await baseVault.getInitializationBlock()), 0);
|
const r = await lpFactory.newLP(accounts[0], recoveryVault);
|
||||||
assert.isAbove(Number(await baseLP.getInitializationBlock()), 0);
|
|
||||||
|
|
||||||
const r = await lpFactory.newLP(accounts[0], escapeHatchDestination);
|
|
||||||
|
|
||||||
const vaultAddress = r.events.DeployVault.returnValues.vault;
|
const vaultAddress = r.events.DeployVault.returnValues.vault;
|
||||||
vault = new LPVault(web3, vaultAddress);
|
vault = new LPVault(web3, vaultAddress);
|
||||||
|
@ -80,6 +78,9 @@ describe('LiquidPledging test', function() {
|
||||||
const lpAddress = r.events.DeployLiquidPledging.returnValues.liquidPledging;
|
const lpAddress = r.events.DeployLiquidPledging.returnValues.liquidPledging;
|
||||||
liquidPledging = new LiquidPledgingMock(web3, lpAddress);
|
liquidPledging = new LiquidPledgingMock(web3, lpAddress);
|
||||||
|
|
||||||
|
assert.isAbove(Number(await vault.getInitializationBlock()), 0);
|
||||||
|
assert.isAbove(Number(await liquidPledging.getInitializationBlock()), 0);
|
||||||
|
|
||||||
liquidPledgingState = new LiquidPledgingState(liquidPledging);
|
liquidPledgingState = new LiquidPledgingState(liquidPledging);
|
||||||
|
|
||||||
// set permissions
|
// set permissions
|
||||||
|
@ -494,4 +495,29 @@ describe('LiquidPledging test', function() {
|
||||||
const giver1Bal = await giver1Token.balanceOf(giver1);
|
const giver1Bal = await giver1Token.balanceOf(giver1);
|
||||||
assert.equal(new utils.BN(preGiver1Bal).subn(11).toString(), giver1Bal);
|
assert.equal(new utils.BN(preGiver1Bal).subn(11).toString(), giver1Bal);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('Should recover funds from contract instances', async function() {
|
||||||
|
assert.equal(await giver1Token.balanceOf(recoveryVault), 0);
|
||||||
|
assert.equal(await giver1Token.balanceOf(liquidPledging.$address), 0);
|
||||||
|
|
||||||
|
// shouldn't be able to send eth to contract
|
||||||
|
await assertFail(
|
||||||
|
web3.eth.sendTransaction({
|
||||||
|
to: liquidPledging.$address,
|
||||||
|
value: 1000,
|
||||||
|
from: giver1,
|
||||||
|
gas: 6700000,
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
|
// however, we can't stop tokens, so lets make sure we can recover them
|
||||||
|
await giver1Token.transfer(liquidPledging.$address, 1000, { from: giver1 });
|
||||||
|
assert.equal(await giver1Token.balanceOf(liquidPledging.$address), 1000);
|
||||||
|
|
||||||
|
const kernel = new Kernel(web3, await liquidPledging.kernel());
|
||||||
|
await liquidPledging.transferToVault(giver1Token.$address, { $extraGas: 100000 });
|
||||||
|
|
||||||
|
assert.equal(await giver1Token.balanceOf(recoveryVault), 1000);
|
||||||
|
assert.equal(await giver1Token.balanceOf(liquidPledging.$address), 0);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,11 +1,9 @@
|
||||||
/* eslint-env mocha */
|
/* eslint-env mocha */
|
||||||
/* eslint-disable no-await-in-loop */
|
/* eslint-disable no-await-in-loop */
|
||||||
const TestRPC = require('ganache-cli');
|
const Ganache = require('ganache-cli');
|
||||||
const Web3 = require('web3');
|
const Web3 = require('web3');
|
||||||
const { assert } = require('chai');
|
const { assert } = require('chai');
|
||||||
const { LPVault, LPFactory, LiquidPledgingState, test } = require('../index');
|
const deployLP = require('./helpers/deployLP');
|
||||||
|
|
||||||
const { StandardTokenTest, assertFail, LiquidPledgingMock } = test;
|
|
||||||
|
|
||||||
const printState = async liquidPledgingState => {
|
const printState = async liquidPledgingState => {
|
||||||
const st = await liquidPledgingState.getState();
|
const st = await liquidPledgingState.getState();
|
||||||
|
@ -15,12 +13,11 @@ const printState = async liquidPledgingState => {
|
||||||
describe('NormalizePledge test', function() {
|
describe('NormalizePledge test', function() {
|
||||||
this.timeout(0);
|
this.timeout(0);
|
||||||
|
|
||||||
let testrpc;
|
let ganache;
|
||||||
let web3;
|
let web3;
|
||||||
let accounts;
|
let accounts;
|
||||||
let liquidPledging;
|
let liquidPledging;
|
||||||
let liquidPledgingState;
|
let liquidPledgingState;
|
||||||
let vault;
|
|
||||||
let giver1;
|
let giver1;
|
||||||
let giver2;
|
let giver2;
|
||||||
let delegate1;
|
let delegate1;
|
||||||
|
@ -30,50 +27,36 @@ describe('NormalizePledge test', function() {
|
||||||
let token;
|
let token;
|
||||||
|
|
||||||
before(async () => {
|
before(async () => {
|
||||||
testrpc = TestRPC.server({
|
ganache = Ganache.server({
|
||||||
gasLimit: 6700000,
|
gasLimit: 6700000,
|
||||||
total_accounts: 10,
|
total_accounts: 10,
|
||||||
});
|
});
|
||||||
|
|
||||||
testrpc.listen(8545, '127.0.0.1');
|
ganache.listen(8545, '127.0.0.1');
|
||||||
|
|
||||||
web3 = new Web3('http://localhost:8545');
|
web3 = new Web3('http://localhost:8545');
|
||||||
accounts = await web3.eth.getAccounts();
|
accounts = await web3.eth.getAccounts();
|
||||||
giver1 = accounts[1];
|
|
||||||
delegate1 = accounts[2];
|
delegate1 = accounts[2];
|
||||||
delegate2 = accounts[3];
|
delegate2 = accounts[3];
|
||||||
adminProject1 = accounts[4];
|
adminProject1 = accounts[4];
|
||||||
adminProject2 = accounts[5];
|
adminProject2 = accounts[5];
|
||||||
giver2 = accounts[6];
|
giver2 = accounts[6];
|
||||||
|
|
||||||
|
const deployment = await deployLP(web3);
|
||||||
|
giver1 = deployment.giver1;
|
||||||
|
liquidPledging = deployment.liquidPledging;
|
||||||
|
liquidPledgingState = deployment.liquidPledgingState;
|
||||||
|
token = deployment.token;
|
||||||
|
|
||||||
|
await token.mint(giver2, web3.utils.toWei('1000'));
|
||||||
|
await token.approve(liquidPledging.$address, '0xFFFFFFFFFFFFFFFF', { from: giver2 });
|
||||||
});
|
});
|
||||||
|
|
||||||
after(done => {
|
after(done => {
|
||||||
testrpc.close();
|
ganache.close();
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Should deploy LiquidPledging contract', async () => {
|
|
||||||
const baseVault = await LPVault.new(web3, accounts[0]);
|
|
||||||
const baseLP = await LiquidPledgingMock.new(web3, accounts[0]);
|
|
||||||
lpFactory = await LPFactory.new(web3, baseVault.$address, baseLP.$address);
|
|
||||||
|
|
||||||
const r = await lpFactory.newLP(accounts[0], accounts[0]);
|
|
||||||
|
|
||||||
const vaultAddress = r.events.DeployVault.returnValues.vault;
|
|
||||||
vault = new LPVault(web3, vaultAddress);
|
|
||||||
|
|
||||||
const lpAddress = r.events.DeployLiquidPledging.returnValues.liquidPledging;
|
|
||||||
liquidPledging = new LiquidPledgingMock(web3, lpAddress);
|
|
||||||
|
|
||||||
liquidPledgingState = new LiquidPledgingState(liquidPledging);
|
|
||||||
|
|
||||||
token = await StandardTokenTest.new(web3);
|
|
||||||
await token.mint(giver1, web3.utils.toWei('1000'));
|
|
||||||
await token.mint(giver2, web3.utils.toWei('1000'));
|
|
||||||
await token.approve(liquidPledging.$address, '0xFFFFFFFFFFFFFFFF', { from: giver1 });
|
|
||||||
await token.approve(liquidPledging.$address, '0xFFFFFFFFFFFFFFFF', { from: giver2 });
|
|
||||||
});
|
|
||||||
|
|
||||||
it('Should add pledgeAdmins', async () => {
|
it('Should add pledgeAdmins', async () => {
|
||||||
await liquidPledging.addGiver('Giver1', 'URLGiver1', 86400, 0, { from: giver1 }); // pledgeAdmin 1
|
await liquidPledging.addGiver('Giver1', 'URLGiver1', 86400, 0, { from: giver1 }); // pledgeAdmin 1
|
||||||
await liquidPledging.addDelegate('Delegate1', 'URLDelegate1', 259200, 0, { from: delegate1 }); // pledgeAdmin 2
|
await liquidPledging.addDelegate('Delegate1', 'URLDelegate1', 259200, 0, { from: delegate1 }); // pledgeAdmin 2
|
||||||
|
|
|
@ -0,0 +1,38 @@
|
||||||
|
const { LPVault, LPFactory, LiquidPledgingState, Kernel, ACL, test } = require('../../index');
|
||||||
|
const { RecoveryVault } = require('../../build/contracts');
|
||||||
|
|
||||||
|
module.exports = async web3 => {
|
||||||
|
const accounts = await web3.eth.getAccounts();
|
||||||
|
const giver1 = accounts[1];
|
||||||
|
|
||||||
|
const baseVault = await LPVault.new(web3);
|
||||||
|
const baseLP = await test.LiquidPledgingMock.new(web3, {
|
||||||
|
gas: 6700000,
|
||||||
|
});
|
||||||
|
const lpFactory = await LPFactory.new(web3, baseVault.$address, baseLP.$address, {
|
||||||
|
gas: 6700000,
|
||||||
|
});
|
||||||
|
|
||||||
|
const recoveryVault = (await RecoveryVault.new(web3)).$address;
|
||||||
|
const r = await lpFactory.newLP(accounts[0], recoveryVault);
|
||||||
|
|
||||||
|
const vaultAddress = r.events.DeployVault.returnValues.vault;
|
||||||
|
const vault = new LPVault(web3, vaultAddress);
|
||||||
|
|
||||||
|
const lpAddress = r.events.DeployLiquidPledging.returnValues.liquidPledging;
|
||||||
|
const liquidPledging = new test.LiquidPledgingMock(web3, lpAddress);
|
||||||
|
|
||||||
|
const liquidPledgingState = new LiquidPledgingState(liquidPledging);
|
||||||
|
|
||||||
|
const token = await test.StandardTokenTest.new(web3);
|
||||||
|
await token.mint(giver1, web3.utils.toWei('1000'));
|
||||||
|
await token.approve(liquidPledging.$address, '0xFFFFFFFFFFFFFFFF', { from: giver1 });
|
||||||
|
|
||||||
|
return {
|
||||||
|
liquidPledging,
|
||||||
|
liquidPledgingState,
|
||||||
|
vault,
|
||||||
|
token,
|
||||||
|
giver1,
|
||||||
|
};
|
||||||
|
};
|
Loading…
Reference in New Issue