|
|
|
@ -9,8 +9,8 @@ const shell = require('shelljs'); |
|
|
|
|
/** |
|
|
|
|
* Installs mock truffle project at ./mock with a single contract |
|
|
|
|
* and test specified by the params. |
|
|
|
|
* @param {String} contract <contractName.sol> located in /test/sources/run/ |
|
|
|
|
* @param {[type]} test <testName.js> located in /test/run/ |
|
|
|
|
* @param {String} contract <contractName.sol> located in /test/sources/cli/ |
|
|
|
|
* @param {[type]} test <testName.js> located in /test/cli/ |
|
|
|
|
*/ |
|
|
|
|
module.exports.install = function install(contract, test, config) { |
|
|
|
|
shell.mkdir('./mock'); |
|
|
|
@ -21,13 +21,13 @@ module.exports.install = function install(contract, test, config) { |
|
|
|
|
// Mock contracts
|
|
|
|
|
if (Array.isArray(contract)) { |
|
|
|
|
contract.forEach(item => { |
|
|
|
|
shell.cp(`./test/sources/run/${item}`, `./mock/contracts/${item}`); |
|
|
|
|
shell.cp(`./test/sources/cli/${item}`, `./mock/contracts/${item}`); |
|
|
|
|
}); |
|
|
|
|
} else { |
|
|
|
|
shell.cp(`./test/sources/run/${contract}`, `./mock/contracts/${contract}`); |
|
|
|
|
shell.cp(`./test/sources/cli/${contract}`, `./mock/contracts/${contract}`); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
shell.cp('./test/sources/run/Migrations.sol', './mock/contracts/Migrations.sol'); |
|
|
|
|
shell.cp('./test/sources/cli/Migrations.sol', './mock/contracts/Migrations.sol'); |
|
|
|
|
|
|
|
|
|
// Mock migrations
|
|
|
|
|
const initialMigration = ` |
|
|
|
@ -47,7 +47,7 @@ module.exports.install = function install(contract, test, config) { |
|
|
|
|
fs.writeFileSync('./mock/migrations/2_deploy_contracts.js', deployContracts); |
|
|
|
|
|
|
|
|
|
// Mock test
|
|
|
|
|
shell.cp(`./test/run/${test}`, `./mock/test/${test}`); |
|
|
|
|
shell.cp(`./test/cli/${test}`, `./mock/test/${test}`); |
|
|
|
|
|
|
|
|
|
// Mock truffle.js
|
|
|
|
|
const trufflejs = `module.exports = {
|
|
|
|
@ -68,8 +68,8 @@ module.exports.install = function install(contract, test, config) { |
|
|
|
|
/** |
|
|
|
|
* Installs mock truffle project at ./mock with a single contract |
|
|
|
|
* and test specified by the params. |
|
|
|
|
* @param {String} contract <contractName.sol> located in /test/sources/run/ |
|
|
|
|
* @param {[type]} test <testName.js> located in /test/run/ |
|
|
|
|
* @param {String} contract <contractName.sol> located in /test/sources/cli/ |
|
|
|
|
* @param {[type]} test <testName.js> located in /test/cli/ |
|
|
|
|
*/ |
|
|
|
|
module.exports.installInheritanceTest = function installInheritanceTest(config) { |
|
|
|
|
shell.mkdir('./mock'); |
|
|
|
@ -78,9 +78,9 @@ module.exports.installInheritanceTest = function installInheritanceTest(config) |
|
|
|
|
shell.mkdir('./mock/test'); |
|
|
|
|
|
|
|
|
|
// Mock contracts
|
|
|
|
|
shell.cp('./test/sources/run/Proxy.sol', './mock/contracts/Proxy.sol'); |
|
|
|
|
shell.cp('./test/sources/run/Owned.sol', './mock/contracts/Owned.sol'); |
|
|
|
|
shell.cp('./test/sources/run/Migrations.sol', './mock/contracts/Migrations.sol'); |
|
|
|
|
shell.cp('./test/sources/cli/Proxy.sol', './mock/contracts/Proxy.sol'); |
|
|
|
|
shell.cp('./test/sources/cli/Owned.sol', './mock/contracts/Owned.sol'); |
|
|
|
|
shell.cp('./test/sources/cli/Migrations.sol', './mock/contracts/Migrations.sol'); |
|
|
|
|
|
|
|
|
|
// Mock migrations
|
|
|
|
|
const initialMigration = ` |
|
|
|
@ -102,7 +102,7 @@ module.exports.installInheritanceTest = function installInheritanceTest(config) |
|
|
|
|
fs.writeFileSync('./mock/migrations/2_deploy_contracts.js', deployContracts); |
|
|
|
|
|
|
|
|
|
// Mock test
|
|
|
|
|
shell.cp('./test/run/inheritance.js', './mock/test/inheritance.js'); |
|
|
|
|
shell.cp('./test/cli/inheritance.js', './mock/test/inheritance.js'); |
|
|
|
|
|
|
|
|
|
// Mock truffle.js
|
|
|
|
|
const trufflejs = `module.exports = {
|
|
|
|
@ -121,7 +121,7 @@ module.exports.installInheritanceTest = function installInheritanceTest(config) |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Removes mock truffle project and coverage reports generated by runCovered tests |
|
|
|
|
* Removes mock truffle project and coverage reports generated by exec.js |
|
|
|
|
*/ |
|
|
|
|
module.exports.remove = function remove() { |
|
|
|
|
shell.config.silent = true; |
|
|
|
|