liquid-funding/test/helpers/deployLP.js

39 lines
1.2 KiB
JavaScript
Raw Normal View History

2018-06-16 20:02:43 +00:00
const { LPVault, LPFactory, LiquidPledgingState, Kernel, ACL, test } = require('../../lib/contracts');
2018-06-16 19:04:36 +00:00
const { RecoveryVault } = test;
2018-06-16 17:54:30 +00:00
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,
};
};