|
1 | 1 | const tape = require('tape');
|
2 | 2 | const semver = require('semver');
|
3 | 3 | const solc = require('../index.js');
|
| 4 | +const linker = require('../linker.js'); |
4 | 5 |
|
5 | 6 | function getBytecode (output, fileName, contractName) {
|
6 | 7 | try {
|
@@ -373,6 +374,50 @@ tape('Compilation', function (t) {
|
373 | 374 | st.ok(L.length > 0);
|
374 | 375 | st.end();
|
375 | 376 | });
|
| 377 | + |
| 378 | + t.test('compiling standard JSON (using wrapper and libraries)', function (st) { |
| 379 | + // Example needs support for compileJSONMulti |
| 380 | + // FIXME: add test for wrapper without multiple files |
| 381 | + if (semver.lt(solc.semver(), '0.1.6')) { |
| 382 | + st.skip('Not supported by solc <0.1.6'); |
| 383 | + st.end(); |
| 384 | + return; |
| 385 | + } |
| 386 | + |
| 387 | + var input = { |
| 388 | + 'language': 'Solidity', |
| 389 | + 'settings': { |
| 390 | + 'libraries': { |
| 391 | + 'lib.sol': { |
| 392 | + 'L': '4200000000000000000000000000000000000001' |
| 393 | + } |
| 394 | + }, |
| 395 | + 'outputSelection': { |
| 396 | + '*': { |
| 397 | + '*': [ 'evm.bytecode' ] |
| 398 | + } |
| 399 | + } |
| 400 | + }, |
| 401 | + 'sources': { |
| 402 | + 'lib.sol': { |
| 403 | + 'content': 'library L { function f() returns (uint) { return 7; } }' |
| 404 | + }, |
| 405 | + 'cont.sol': { |
| 406 | + 'content': 'import "lib.sol"; contract x { function g() { L.f(); } }' |
| 407 | + } |
| 408 | + } |
| 409 | + }; |
| 410 | + |
| 411 | + var output = JSON.parse(solc.compileStandardWrapper(JSON.stringify(input))); |
| 412 | + var x = getBytecodeStandard(output, 'cont.sol', 'x'); |
| 413 | + st.ok(x); |
| 414 | + st.ok(x.length > 0); |
| 415 | + st.ok(Object.keys(linker.findLinkReferences(x)).length === 0); |
| 416 | + var L = getBytecodeStandard(output, 'lib.sol', 'L'); |
| 417 | + st.ok(L); |
| 418 | + st.ok(L.length > 0); |
| 419 | + st.end(); |
| 420 | + }); |
376 | 421 | });
|
377 | 422 |
|
378 | 423 | tape('Loading Legacy Versions', function (t) {
|
|
0 commit comments