Skip to content

Commit

Permalink
refactor(@embark/dapps/tests/contracts): adjustments to get tests pas…
Browse files Browse the repository at this point in the history
…sing

Further refactoring is needed re: potentially duplicated or overlapping logic
in `packages/plugins/solidity-tests` and
`packages/core/utils/src/solidity/remapImports.ts`, as well in disabled test
dapp tests
  • Loading branch information
jrainville authored and michaelsbradleyjr committed Oct 22, 2019
1 parent 207b79e commit d7ccd0d
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 9 deletions.
2 changes: 1 addition & 1 deletion dapps/tests/app/test/solidity_test.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ contract MyTest {
}

function valueShouldBe1() public {
Assert.equal(1, i, "value is not correct");
require(1 == i, "value is not correct");
}
}
8 changes: 6 additions & 2 deletions dapps/tests/contracts/test/another_storage_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,11 @@ config({
"SimpleStorage": {
args: [100]
},
// "AnotherStorage": {
// args: ["$SimpleStorage", "embark.eth"]
// },
"AnotherStorage": {
args: ["$SimpleStorage", "embark.eth"]
args: ["$SimpleStorage", "$SimpleStorage"]
}
}
}
Expand All @@ -30,7 +33,8 @@ contract("AnotherStorage", function() {
assert.equal(result.toString(), SimpleStorage.options.address);
});

it("set ENS address", async function() {
// FIXME add back when the ENS feature is back
xit("set ENS address", async function() {
const result = await AnotherStorage.methods.ens().call();
assert.equal(result.toString(), accounts[0]);
});
Expand Down
2 changes: 1 addition & 1 deletion dapps/tests/contracts/test/ownable_test.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ contract OwnableTests {
}

function shouldnotbezeroAddress() public {
Assert.equal(true, true, "owner is uninitialized");
require(true == true, "owner is uninitialized");
}
}
4 changes: 3 additions & 1 deletion dapps/tests/contracts/test/simple_storage_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ contract("SimpleStorage", function () {
});

it("set storage value", async function () {
await SimpleStorage.methods.set(150).send();
const toSend = SimpleStorage.methods.set(150);
const gas = await toSend.estimateGas();
await toSend.send({gas});
let result = await SimpleStorage.methods.get().call();
assert.strictEqual(parseInt(result, 10), 499650);
});
Expand Down
6 changes: 3 additions & 3 deletions packages/plugins/solidity-tests/src/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import "remix_tests.sol";
// ----------------------
`;
const ASSERT_LIB = new File({
path: "remix_tests.sol",
originalPath: dappPath("remix_tests.sol"),
path: dappPath(".embark", "remix_tests.sol"),
originalPath: dappPath(".embark", "remix_tests.sol"),
type: Types.dappFile,
resolver: (cb) => { cb(remixTests.assertLibCode); }
});
Expand Down Expand Up @@ -84,7 +84,7 @@ class SolidityTestRunner {
async.waterfall([
(next) => {
// write the remix_tests file where it will be found.
fs.writeFile(dappPath('remix_tests.sol'), remixTests.assertLibCode, next);
fs.writeFile(ASSERT_LIB.originalPath, remixTests.assertLibCode, next);
},
(next) => {
events.request("contracts:reset", next);
Expand Down
2 changes: 1 addition & 1 deletion packages/stack/test-runner/src/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class TestRunner {

async.waterfall([
(next) => {
this.events.request("config:contractsConfig:set", Object.assign(this.configObj.contractsConfig, {explicit: true}), next);
this.events.request("config:contractsConfig:set", Object.assign(this.configObj.contractsConfig, {explicit: true, afterDeploy: null, beforeDeploy: null}), next);
},
(next) => {
this.getFilesFromDir(testPath, next);
Expand Down

0 comments on commit d7ccd0d

Please sign in to comment.