fix and add tests

This commit is contained in:
Jonathan Rainville 2018-04-19 15:13:41 -04:00
parent 9cdcc4f6d4
commit df5b647ecb
8 changed files with 146 additions and 41 deletions

116
package-lock.json generated
View File

@ -4,6 +4,14 @@
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {
"@sinonjs/formatio": {
"version": "2.0.0",
"resolved": "http://registry.npmjs.org/@sinonjs/formatio/-/formatio-2.0.0.tgz",
"integrity": "sha512-ls6CAMA6/5gG+O/IdsBcblvnd8qcO/l1TYoNeAzp3wcISOxlPXQEus0mLcdwazEkWjaBdaJ3TaxmNgCLWwvWzg==",
"requires": {
"samsam": "1.3.0"
}
},
"abbrev": { "abbrev": {
"version": "1.1.1", "version": "1.1.1",
"resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz",
@ -3077,15 +3085,6 @@
"mime-types": "2.1.18" "mime-types": "2.1.18"
} }
}, },
"formatio": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/formatio/-/formatio-1.1.1.tgz",
"integrity": "sha1-XtPM1jZVEJc4NGXZlhmRAOhhYek=",
"dev": true,
"requires": {
"samsam": "1.1.2"
}
},
"forwarded": { "forwarded": {
"version": "0.1.2", "version": "0.1.2",
"resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.1.2.tgz", "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.1.2.tgz",
@ -5468,6 +5467,11 @@
"verror": "1.10.0" "verror": "1.10.0"
} }
}, },
"just-extend": {
"version": "1.1.27",
"resolved": "https://registry.npmjs.org/just-extend/-/just-extend-1.1.27.tgz",
"integrity": "sha512-mJVp13Ix6gFo3SBAy9U/kL+oeZqzlYYYLQBwXVBlVzIsZwBqGREnOro24oC/8s8aox+rJhtZ2DiQof++IrkA+g=="
},
"keccakjs": { "keccakjs": {
"version": "0.2.1", "version": "0.2.1",
"resolved": "https://registry.npmjs.org/keccakjs/-/keccakjs-0.2.1.tgz", "resolved": "https://registry.npmjs.org/keccakjs/-/keccakjs-0.2.1.tgz",
@ -5701,6 +5705,11 @@
"resolved": "https://registry.npmjs.org/lodash.filter/-/lodash.filter-4.6.0.tgz", "resolved": "https://registry.npmjs.org/lodash.filter/-/lodash.filter-4.6.0.tgz",
"integrity": "sha1-ZosdSYFgOuHMWm+nYBQ+SAtMSs4=" "integrity": "sha1-ZosdSYFgOuHMWm+nYBQ+SAtMSs4="
}, },
"lodash.get": {
"version": "4.4.2",
"resolved": "https://registry.npmjs.org/lodash.get/-/lodash.get-4.4.2.tgz",
"integrity": "sha1-LRd/ZS+jHpObRDjVNBSZ36OCXpk="
},
"lodash.map": { "lodash.map": {
"version": "4.6.0", "version": "4.6.0",
"resolved": "https://registry.npmjs.org/lodash.map/-/lodash.map-4.6.0.tgz", "resolved": "https://registry.npmjs.org/lodash.map/-/lodash.map-4.6.0.tgz",
@ -5737,10 +5746,9 @@
"integrity": "sha1-5QndTEVcGu190QWhdpTapbmsV58=" "integrity": "sha1-5QndTEVcGu190QWhdpTapbmsV58="
}, },
"lolex": { "lolex": {
"version": "1.3.2", "version": "2.3.2",
"resolved": "https://registry.npmjs.org/lolex/-/lolex-1.3.2.tgz", "resolved": "https://registry.npmjs.org/lolex/-/lolex-2.3.2.tgz",
"integrity": "sha1-fD2mL/yzDw9agKJWbKJORdigHzE=", "integrity": "sha512-A5pN2tkFj7H0dGIAM6MFvHKMJcPnjZsOMvR7ujCjfgW5TbV6H9vb1PgxLtHvjqNZTHsUolz+6/WEO0N1xNx2ng=="
"dev": true
}, },
"longest": { "longest": {
"version": "1.0.1", "version": "1.0.1",
@ -6421,6 +6429,33 @@
"resolved": "https://registry.npmjs.org/neo-async/-/neo-async-2.5.0.tgz", "resolved": "https://registry.npmjs.org/neo-async/-/neo-async-2.5.0.tgz",
"integrity": "sha1-drHIIxMMyias+6zMj7rwovozsY8=" "integrity": "sha1-drHIIxMMyias+6zMj7rwovozsY8="
}, },
"nise": {
"version": "1.3.3",
"resolved": "https://registry.npmjs.org/nise/-/nise-1.3.3.tgz",
"integrity": "sha512-v1J/FLUB9PfGqZLGDBhQqODkbLotP0WtLo9R4EJY2PPu5f5Xg4o0rA8FDlmrjFSv9vBBKcfnOSpfYYuu5RTHqg==",
"requires": {
"@sinonjs/formatio": "2.0.0",
"just-extend": "1.1.27",
"lolex": "2.3.2",
"path-to-regexp": "1.7.0",
"text-encoding": "0.6.4"
},
"dependencies": {
"isarray": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz",
"integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8="
},
"path-to-regexp": {
"version": "1.7.0",
"resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-1.7.0.tgz",
"integrity": "sha1-Wf3g9DW62suhA6hOnTvGTpa5k30=",
"requires": {
"isarray": "0.0.1"
}
}
}
},
"node-forge": { "node-forge": {
"version": "0.7.4", "version": "0.7.4",
"resolved": "https://registry.npmjs.org/node-forge/-/node-forge-0.7.4.tgz", "resolved": "https://registry.npmjs.org/node-forge/-/node-forge-0.7.4.tgz",
@ -8347,10 +8382,9 @@
} }
}, },
"samsam": { "samsam": {
"version": "1.1.2", "version": "1.3.0",
"resolved": "https://registry.npmjs.org/samsam/-/samsam-1.1.2.tgz", "resolved": "https://registry.npmjs.org/samsam/-/samsam-1.3.0.tgz",
"integrity": "sha1-vsEf3IOp/aBjQBIQ5AF2wwJNFWc=", "integrity": "sha512-1HwIYD/8UlOtFS3QO3w7ey+SdSDFE4HRNLZoZRYVQefrOY3l17epswImeB1ijgJFQJodIaHcwkp3r/myBjFVbg=="
"dev": true
}, },
"sax": { "sax": {
"version": "1.2.4", "version": "1.2.4",
@ -8594,15 +8628,37 @@
} }
}, },
"sinon": { "sinon": {
"version": "1.17.7", "version": "4.5.0",
"resolved": "https://registry.npmjs.org/sinon/-/sinon-1.17.7.tgz", "resolved": "https://registry.npmjs.org/sinon/-/sinon-4.5.0.tgz",
"integrity": "sha1-RUKk9JugxFwF6y6d2dID4rjv4L8=", "integrity": "sha512-trdx+mB0VBBgoYucy6a9L7/jfQOmvGeaKZT4OOJ+lPAtI8623xyGr8wLiE4eojzBS8G9yXbhx42GHUOVLr4X2w==",
"dev": true,
"requires": { "requires": {
"formatio": "1.1.1", "@sinonjs/formatio": "2.0.0",
"lolex": "1.3.2", "diff": "3.5.0",
"samsam": "1.1.2", "lodash.get": "4.4.2",
"util": "0.10.3" "lolex": "2.3.2",
"nise": "1.3.3",
"supports-color": "5.4.0",
"type-detect": "4.0.8"
},
"dependencies": {
"diff": {
"version": "3.5.0",
"resolved": "https://registry.npmjs.org/diff/-/diff-3.5.0.tgz",
"integrity": "sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA=="
},
"has-flag": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz",
"integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0="
},
"supports-color": {
"version": "5.4.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.4.0.tgz",
"integrity": "sha512-zjaXglF5nnWpsq470jSv6P9DwPvgLkuapYmfDm3JWOm0vkNTVF2tI4UrN2r6jH1qM/uc/WtxYY1hYoA2dOKj5w==",
"requires": {
"has-flag": "3.0.0"
}
}
} }
}, },
"slash": { "slash": {
@ -9511,6 +9567,11 @@
} }
} }
}, },
"text-encoding": {
"version": "0.6.4",
"resolved": "https://registry.npmjs.org/text-encoding/-/text-encoding-0.6.4.tgz",
"integrity": "sha1-45mpgiV6J22uQou5KEXLcb3CbRk="
},
"text-table": { "text-table": {
"version": "0.2.0", "version": "0.2.0",
"resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz", "resolved": "https://registry.npmjs.org/text-table/-/text-table-0.2.0.tgz",
@ -9690,6 +9751,11 @@
"prelude-ls": "1.1.2" "prelude-ls": "1.1.2"
} }
}, },
"type-detect": {
"version": "4.0.8",
"resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz",
"integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g=="
},
"type-is": { "type-is": {
"version": "1.6.16", "version": "1.6.16",
"resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.16.tgz", "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.16.tgz",

View File

@ -88,6 +88,6 @@
"matchdep": "^1.0.1", "matchdep": "^1.0.1",
"mocha": "^3.2.0", "mocha": "^3.2.0",
"mocha-sinon": "^1.1.4", "mocha-sinon": "^1.1.4",
"sinon": "^1.15.4" "sinon": "^4.5.0"
} }
} }

View File

@ -158,14 +158,14 @@ describe('embark.Config', function () {
]; ];
const expected = [ const expected = [
{ {
"filename": ".embark/contracts/simple_storage.sol", "filename": ".embark/contracts/embark-framework/embark/master/test_app/app/contracts/simple_storage.sol",
"type": "http", "type": "http",
"path": "https://raw.githubusercontent.com/embark-framework/embark/master/test_app/app/contracts/simple_storage.sol", "path": "https://raw.githubusercontent.com/embark-framework/embark/master/test_app/app/contracts/simple_storage.sol",
"basedir": "", "basedir": "",
"resolver": undefined "resolver": undefined
}, },
{ {
"filename": ".embark/contracts/ERC725.sol", "filename": ".embark/contracts/status-im/contracts/master/contracts/identity/ERC725.sol",
"type": "http", "type": "http",
"path": "https://raw.githubusercontent.com/status-im/contracts/master/contracts/identity/ERC725.sol", "path": "https://raw.githubusercontent.com/status-im/contracts/master/contracts/identity/ERC725.sol",
"basedir": "", "basedir": "",

View File

@ -0,0 +1,19 @@
pragma solidity ^0.4.7;
contract SimpleStorage {
uint public storedData;
import "./ownable.sol";
function SimpleStorage(uint initialValue) {
storedData = initialValue;
}
function set(uint x) {
storedData = x;
}
function get() constant returns (uint retVal) {
return storedData;
}
}

View File

@ -1,7 +1,6 @@
pragma solidity ^0.4.7; pragma solidity ^0.4.7;
contract SimpleStorage { contract SimpleStorage {
uint public storedData; uint public storedData;
import "./ownable.sol";
function SimpleStorage(uint initialValue) { function SimpleStorage(uint initialValue) {
storedData = initialValue; storedData = initialValue;

View File

@ -1,14 +1,27 @@
/*globals describe, it*/ /*globals describe, it*/
const File = require('../lib/core/file'); const File = require('../lib/core/file');
const fs = require('fs-extra'); const fs = require('fs-extra');
const path = require('path');
const assert = require('assert');
const sinon = require('sinon');
describe('embark.File', function () { describe('embark.File', function () {
describe('parseFileForImport', () => { describe('parseFileForImport', () => {
it('should find all the imports', function (done) { it('should find all the imports', function (done) {
const contract = fs.readFileSync('./test/contracts/simple_storage.sol').toString(); const contract = fs.readFileSync('./test/contracts/contract_with_import.sol').toString();
const file = new File({filename: '.embark/contracts/embark-framework/embark/master/test_app/app/contracts/simple_storage.sol', const file = new File({filename: '.embark/contracts/embark-framework/embark/master/test_app/app/contracts/simple_storage.sol',
path: 'https://raw.githubusercontent.com/embark-framework/embark/develop/test_apps/test_app/app/contracts/simple_storage.sol'}); path: 'https://raw.githubusercontent.com/embark-framework/embark/develop/test_apps/test_app/app/contracts/simple_storage.sol'});
const downloadFileStub = sinon.stub(file, 'downloadFile')
.callsFake((path, url, cb) => {
cb();
});
file.parseFileForImport(contract, () => { file.parseFileForImport(contract, () => {
assert.strictEqual(downloadFileStub.callCount, 1);
assert.strictEqual(downloadFileStub.firstCall.args[0],
path.normalize('.embark/contracts/embark-framework/embark/master/test_app/app/contracts/ownable.sol'));
assert.strictEqual(downloadFileStub.firstCall.args[1],
'https://raw.githubusercontent.com/embark-framework/embark/develop/test_apps/test_app/app/contracts/./ownable.sol');
done(); done();
}); });
}); });

View File

@ -72,8 +72,8 @@
1000 1000
] ]
}, },
"ERC725": { "Identity": {
"file": "https://github.com/status-im/contracts/blob/master/contracts/identity/ERC725.sol" "file": "https://github.com/status-im/contracts/blob/master/contracts/identity/Identity.sol"
} }
}, },
"afterDeploy": [ "afterDeploy": [

View File

@ -3,16 +3,24 @@ const fs = require('fs-extra');
const assert = require('assert'); const assert = require('assert');
describe('http contracts', () => { describe('http contracts', () => {
describe('ERC725', () => { const contractPath = '.embark/contracts/status-im/contracts/master/contracts/identity/Identity.sol';
const contractPath = '.embark/contracts/ERC725.sol'; const contractImportPath = '.embark/contracts/status-im/contracts/master/contracts/identity/ERC725.sol';
it('should have downloaded the file in .embark/contracts', (done) => { it('should have downloaded the file in .embark/contracts', (done) => {
fs.access(contractPath, (err) => { fs.access(contractPath, (err) => {
if (err) { if (err) {
assert.fail(contractPath + ' was not downloaded'); assert.fail(contractPath + ' was not downloaded');
} }
done(); done();
}); });
});
it('should have downloaded the file import file too', (done) => {
fs.access(contractImportPath, (err) => {
if (err) {
assert.fail(contractPath + ' was not downloaded');
}
done();
}); });
}); });
}); });