NormalOperation.js tests can now be run via embark

This commit is contained in:
perissology 2018-11-15 12:22:12 -08:00
parent 891d2a6f34
commit 9376cfb1e2
4 changed files with 101 additions and 48 deletions

View File

@ -58,15 +58,42 @@ module.exports = {
LiquidPledgingMock: {},
RecoveryVault: {},
LPFactory: {
args: {
_vaultBase: '$LPVault',
_lpBase: '$LiquidPledgingMock',
},
args: ['$LPVault', '$LiquidPledgingMock'],
// args: {
// _vaultBase: '$LPVault',
// _lpBase: '$LiquidPledgingMock',
// },
},
// contracts for testing
StandardToken: {},
},
// afterDeploy: [
// `console.log('we deployed here')`,
// `embark.logger.info('we deployed here')`,
// `LPFactory.methods.newLP("$accounts[0]", "$RecoveryVault").send({ gas: 7000000 })
// .then(({ events }) => {
// console.log('method ran');
// global.LiquidPledging = new web3.eth.Contract(LiquidPledgingMockAbi, events.DeployLiquidPledging.returnValues.liquidPledging);
// global.LPVault = new web3.eth.Contract(LPVaultAbi, events.DeployVault.returnValues.vault);
// StandardToken.methods.mint(accounts[1], web3.utils.toWei('1000')).send();
// StandardToken.methods.approve(global.LiquidPledging.address, '0xFFFFFFFFFFFFFFFF').send({ from: "$accounts[1]" });
// })`
// .catch(err => console.log('error', err))
// `,
// `web3.eth.getAccounts().then(accounts => {
// return LPFactory.methods.newLP(accounts[0], "$RecoveryVault").send({ gas: 7000000 })
// .then(({ events }) => {
// global.LiquidPledging = new web3.eth.Contract(LiquidPledgingMockAbi, events.DeployLiquidPledging.returnValues.liquidPledging);
// global.LPVault = new web3.eth.Contract(LPVaultAbi, events.DeployVault.returnValues.vault);
// StandardToken.methods.mint(accounts[1], web3.utils.toWei('1000')).send();
// StandardToken.methods.approve(global.LiquidPledging.address, '0xFFFFFFFFFFFFFFFF').send({ from: accounts[1] });
// });
// })
// .catch(err => console.log('error', err))
// `,
// ],
},
// merges with the settings in default

View File

@ -1,53 +1,53 @@
const generateClass = require('eth-contract-class').default;
const LPFactoryArtifact = require('../build/LPFactory.json');
const LiquidPledgingArtifact = require('../build/LiquidPledging.json');
const LPVaultArtifact = require('../build/LPVault.json');
const KernelArtifact = require('../build/Kernel.json');
const ACLArtifact = require('../build/ACL.json');
const AppProxyUpgradeableArtifact = require('../build/AppProxyUpgradeable.json');
const StandardTokenTestAtifact = require('../build/StandardToken.json');
const LiquidPledgingMockArtifact = require('../build/LiquidPledgingMock.json');
const RecoveryVaultArtifact = require('../build/RecoveryVault.json');
const LPFactoryArtifact = require('../dist/contracts/LPFactory.json');
const LiquidPledgingArtifact = require('../dist/contracts/LiquidPledging.json');
const LPVaultArtifact = require('../dist/contracts/LPVault.json');
const KernelArtifact = require('../dist/contracts/Kernel.json');
const ACLArtifact = require('../dist/contracts/ACL.json');
const AppProxyUpgradeableArtifact = require('../dist/contracts/AppProxyUpgradeable.json');
const StandardTokenTestAtifact = require('../dist/contracts/StandardToken.json');
const LiquidPledgingMockArtifact = require('../dist/contracts/LiquidPledgingMock.json');
const RecoveryVaultArtifact = require('../dist/contracts/RecoveryVault.json');
module.exports = {
LiquidPledging: generateClass(
LiquidPledgingArtifact.compilerOutput.abi,
LiquidPledgingArtifact.compilerOutput.evm.bytecode.object,
LiquidPledgingArtifact.abiDefinition,
LiquidPledgingArtifact.code,
),
LPFactory: generateClass(
LPFactoryArtifact.compilerOutput.abi,
LPFactoryArtifact.compilerOutput.evm.bytecode.object,
LPFactoryArtifact.abiDefinition,
LPFactoryArtifact.code,
),
LiquidPledgingState: require('../lib/liquidPledgingState.js'),
LPVault: generateClass(
LPVaultArtifact.compilerOutput.abi,
LPVaultArtifact.compilerOutput.evm.bytecode.object,
LPVaultArtifact.abiDefinition,
LPVaultArtifact.code,
),
Kernel: generateClass(
KernelArtifact.compilerOutput.abi,
KernelArtifact.compilerOutput.evm.bytecode.object,
KernelArtifact.abiDefinition,
KernelArtifact.code,
),
ACL: generateClass(
ACLArtifact.compilerOutput.abi,
ACLArtifact.compilerOutput.evm.bytecode.object,
ACLArtifact.abiDefinition,
ACLArtifact.code,
),
AppProxyUpgradeable: generateClass(
AppProxyUpgradeableArtifact.compilerOutput.abi,
AppProxyUpgradeableArtifact.compilerOutput.evm.bytecode.object,
AppProxyUpgradeableArtifact.abiDefinition,
AppProxyUpgradeableArtifact.code,
),
test: {
RecoveryVault: generateClass(
RecoveryVaultArtifact.compilerOutput.abi,
RecoveryVaultArtifact.compilerOutput.evm.bytecode.object,
RecoveryVaultArtifact.abiDefinition,
RecoveryVaultArtifact.code,
),
StandardTokenTest: generateClass(
StandardTokenTestAtifact.compilerOutput.abi,
StandardTokenTestAtifact.compilerOutput.evm.bytecode.object,
StandardTokenTestAtifact.abiDefinition,
StandardTokenTestAtifact.code,
),
LiquidPledgingMock: generateClass(
LiquidPledgingMockArtifact.compilerOutput.abi,
LiquidPledgingMockArtifact.compilerOutput.evm.bytecode.object,
LiquidPledgingMockArtifact.abiDefinition,
LiquidPledgingMockArtifact.code,
),
},
};

View File

@ -6,10 +6,10 @@ const chai = require('chai');
const { test } = require('../index');
const deployLP = require('./helpers/deployLP');
const { compilerOutput } = require('../build/TestSimpleProjectPluginFactory.json');
const simpleProjectPluginFactoryAbi = compilerOutput.abi;
const simpleProjectPluginFactoryByteCode = compilerOutput.evm.bytecode.object;
const simpleProjectPluginRuntimeByteCode = '0x' + require('../build/TestSimpleProjectPlugin.json').compilerOutput.evm.deployedBytecode.object;
const compilerOutput = require('../dist/contracts/TestSimpleProjectPluginFactory.json');
const simpleProjectPluginFactoryAbi = compilerOutput.abiDefinition;
const simpleProjectPluginFactoryByteCode = compilerOutput.code;
const simpleProjectPluginRuntimeByteCode = '0x' + require('../dist/contracts/TestSimpleProjectPlugin.json').code;
const assert = chai.assert;
const { assertFail } = test;

View File

@ -1,5 +1,6 @@
/* eslint-env mocha */
/* eslint-disable no-await-in-loop */
const generateClass = require('eth-contract-class').default;
const Ganache = require('ganache-cli');
const Web3 = require('web3');
const { assert } = require('chai');
@ -13,11 +14,34 @@ const printState = async liquidPledgingState => {
console.log(JSON.stringify(st, null, 2));
};
// const _RecoveryVault = embark.require('Embark/contracts/RecoveryVault');
// const RecoveryVault = ge
// const _LPVault = embark.require('Embark/contracts/LPVault');
// const _LiquidPledgingMock = embark.require('Embark/contracts/LiquidPledgingMock');
let accounts;
config({
// contracts: {
// RecoveryVault: {},
// LPVault: {},
// LiquidPledgingMock: {}
// "SimpleStorage": {
// args: [100],
// onDeploy: ["SimpleStorage.methods.setRegistar(web3.eth.defaultAccount).send()"] // example
// }
// }
}, (err, theAccounts) => {
accounts = theAccounts;
});
describe('LiquidPledging test', function() {
this.timeout(0);
let ganache;
let web3;
let accounts;
// let web3;
// let accounts;
let liquidPledging;
let liquidPledgingState;
let vault;
@ -36,15 +60,15 @@ describe('LiquidPledging test', function() {
let giver2Token;
before(async () => {
ganache = Ganache.server({
gasLimit: 6700000,
total_accounts: 11,
});
// ganache = Ganache.server({
// gasLimit: 6700000,
// total_accounts: 11,
// });
ganache.listen(8545, '127.0.0.1');
// ganache.listen(8545, '127.0.0.1');
web3 = new Web3('http://localhost:8545');
accounts = await web3.eth.getAccounts();
// web3 = new Web3('http://localhost:8545');
// accounts = await web3.eth.getAccounts();
giver1 = accounts[1];
delegate1 = accounts[2];
adminProject1 = accounts[3];
@ -55,12 +79,14 @@ describe('LiquidPledging test', function() {
adminProject3 = accounts[8];
recoveryVault = (await RecoveryVault.new(web3)).$address;
escapeHatchCaller = accounts[10];
// baseLP = new LPVault(web3, _LPVault)
});
after(done => {
ganache.close();
done();
});
// after(done => {
// ganache.close();
// done();
// });
it('Should deploy LiquidPledging contract', async () => {
const baseVault = await LPVault.new(web3);