Skip to content

Commit df5b647

Browse files
committed
fix and add tests
1 parent 9cdcc4f commit df5b647

File tree

8 files changed

+147
-42
lines changed

8 files changed

+147
-42
lines changed

package-lock.json

Lines changed: 92 additions & 26 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,6 @@
8888
"matchdep": "^1.0.1",
8989
"mocha": "^3.2.0",
9090
"mocha-sinon": "^1.1.4",
91-
"sinon": "^1.15.4"
91+
"sinon": "^4.5.0"
9292
}
9393
}

test/config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,14 +158,14 @@ describe('embark.Config', function () {
158158
];
159159
const expected = [
160160
{
161-
"filename": ".embark/contracts/simple_storage.sol",
161+
"filename": ".embark/contracts/embark-framework/embark/master/test_app/app/contracts/simple_storage.sol",
162162
"type": "http",
163163
"path": "https://raw.githubusercontent.com/embark-framework/embark/master/test_app/app/contracts/simple_storage.sol",
164164
"basedir": "",
165165
"resolver": undefined
166166
},
167167
{
168-
"filename": ".embark/contracts/ERC725.sol",
168+
"filename": ".embark/contracts/status-im/contracts/master/contracts/identity/ERC725.sol",
169169
"type": "http",
170170
"path": "https://raw.githubusercontent.com/status-im/contracts/master/contracts/identity/ERC725.sol",
171171
"basedir": "",
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
pragma solidity ^0.4.7;
2+
contract SimpleStorage {
3+
uint public storedData;
4+
import "./ownable.sol";
5+
6+
function SimpleStorage(uint initialValue) {
7+
storedData = initialValue;
8+
}
9+
10+
function set(uint x) {
11+
storedData = x;
12+
}
13+
14+
function get() constant returns (uint retVal) {
15+
return storedData;
16+
}
17+
18+
}
19+

test/contracts/simple_storage.sol

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
pragma solidity ^0.4.7;
22
contract SimpleStorage {
33
uint public storedData;
4-
import "./ownable.sol";
54

65
function SimpleStorage(uint initialValue) {
76
storedData = initialValue;

test/file.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,27 @@
11
/*globals describe, it*/
22
const File = require('../lib/core/file');
33
const fs = require('fs-extra');
4+
const path = require('path');
5+
const assert = require('assert');
6+
const sinon = require('sinon');
47

58
describe('embark.File', function () {
69
describe('parseFileForImport', () => {
710
it('should find all the imports', function (done) {
8-
const contract = fs.readFileSync('./test/contracts/simple_storage.sol').toString();
11+
const contract = fs.readFileSync('./test/contracts/contract_with_import.sol').toString();
912
const file = new File({filename: '.embark/contracts/embark-framework/embark/master/test_app/app/contracts/simple_storage.sol',
1013
path: 'https://raw.githubusercontent.com/embark-framework/embark/develop/test_apps/test_app/app/contracts/simple_storage.sol'});
14+
const downloadFileStub = sinon.stub(file, 'downloadFile')
15+
.callsFake((path, url, cb) => {
16+
cb();
17+
});
18+
1119
file.parseFileForImport(contract, () => {
20+
assert.strictEqual(downloadFileStub.callCount, 1);
21+
assert.strictEqual(downloadFileStub.firstCall.args[0],
22+
path.normalize('.embark/contracts/embark-framework/embark/master/test_app/app/contracts/ownable.sol'));
23+
assert.strictEqual(downloadFileStub.firstCall.args[1],
24+
'https://raw.githubusercontent.com/embark-framework/embark/develop/test_apps/test_app/app/contracts/./ownable.sol');
1225
done();
1326
});
1427
});

test_apps/test_app/config/contracts.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@
7272
1000
7373
]
7474
},
75-
"ERC725": {
76-
"file": "https://github.com/status-im/contracts/blob/master/contracts/identity/ERC725.sol"
75+
"Identity": {
76+
"file": "https://github.com/status-im/contracts/blob/master/contracts/identity/Identity.sol"
7777
}
7878
},
7979
"afterDeploy": [

test_apps/test_app/test/http_contract_test.js

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,24 @@ const fs = require('fs-extra');
33
const assert = require('assert');
44

55
describe('http contracts', () => {
6-
describe('ERC725', () => {
7-
const contractPath = '.embark/contracts/ERC725.sol';
6+
const contractPath = '.embark/contracts/status-im/contracts/master/contracts/identity/Identity.sol';
7+
const contractImportPath = '.embark/contracts/status-im/contracts/master/contracts/identity/ERC725.sol';
88

9-
it('should have downloaded the file in .embark/contracts', (done) => {
10-
fs.access(contractPath, (err) => {
11-
if (err) {
12-
assert.fail(contractPath + ' was not downloaded');
13-
}
14-
done();
15-
});
9+
it('should have downloaded the file in .embark/contracts', (done) => {
10+
fs.access(contractPath, (err) => {
11+
if (err) {
12+
assert.fail(contractPath + ' was not downloaded');
13+
}
14+
done();
15+
});
16+
});
17+
18+
it('should have downloaded the file import file too', (done) => {
19+
fs.access(contractImportPath, (err) => {
20+
if (err) {
21+
assert.fail(contractPath + ' was not downloaded');
22+
}
23+
done();
1624
});
1725
});
1826
});

0 commit comments

Comments
 (0)