Skip to content

Commit b547aa2

Browse files
author
Leonardo
authored
Merge pull request #398 from ethereum/test-fixes
Backport new callback API to 0.5 to compileStandardWrapper
2 parents 2f79710 + 62cf071 commit b547aa2

File tree

2 files changed

+19
-14
lines changed

2 files changed

+19
-14
lines changed

test/compiler.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ tape('Compilation', function (t) {
5757
var output = JSON.parse(solc.lowlevel.compileSingle('contract x { function g() public {} }'));
5858
st.ok('contracts' in output);
5959
var bytecode = getBytecode(output, '', 'x');
60-
st.ok(bytecode);
60+
st.ok(typeof bytecode === 'string');
6161
st.ok(bytecode.length > 0);
6262
st.end();
6363
});
@@ -109,10 +109,10 @@ tape('Compilation', function (t) {
109109
};
110110
var output = JSON.parse(solc.lowlevel.compileMulti(JSON.stringify({sources: input})));
111111
var x = getBytecode(output, 'cont.sol', 'x');
112-
st.ok(x);
112+
st.ok(typeof x === 'string');
113113
st.ok(x.length > 0);
114114
var L = getBytecode(output, 'lib.sol', 'L');
115-
st.ok(L);
115+
st.ok(typeof L === 'string');
116116
st.ok(L.length > 0);
117117
st.end();
118118
});
@@ -138,9 +138,9 @@ tape('Compilation', function (t) {
138138
var output = JSON.parse(solc.lowlevel.compileCallback(JSON.stringify({sources: input}), 0, findImports));
139139
var x = getBytecode(output, 'cont.sol', 'x');
140140
var L = getBytecode(output, 'lib.sol', 'L');
141-
st.ok(x);
141+
st.ok(typeof x === 'string');
142142
st.ok(x.length > 0);
143-
st.ok(L);
143+
st.ok(typeof L === 'string');
144144
st.ok(L.length > 0);
145145
st.end();
146146
});
@@ -388,10 +388,10 @@ tape('Compilation', function (t) {
388388

389389
var output = JSON.parse(solc.compile(JSON.stringify(input)));
390390
var x = getBytecodeStandard(output, 'cont.sol', 'x');
391-
st.ok(x);
391+
st.ok(typeof x === 'string');
392392
st.ok(x.length > 0);
393393
var L = getBytecodeStandard(output, 'lib.sol', 'L');
394-
st.ok(L);
394+
st.ok(typeof L === 'string');
395395
st.ok(L.length > 0);
396396
st.end();
397397
});
@@ -430,10 +430,10 @@ tape('Compilation', function (t) {
430430

431431
var output = JSON.parse(solc.compile(JSON.stringify(input), findImports));
432432
var x = getBytecodeStandard(output, 'cont.sol', 'x');
433-
st.ok(x);
433+
st.ok(typeof x === 'string');
434434
st.ok(x.length > 0);
435435
var L = getBytecodeStandard(output, 'lib.sol', 'L');
436-
st.ok(L);
436+
st.ok(typeof L === 'string');
437437
st.ok(L.length > 0);
438438

439439
var outputNewApi = JSON.parse(solc.compile(JSON.stringify(input), { import: findImports }));
@@ -475,11 +475,11 @@ tape('Compilation', function (t) {
475475

476476
var output = JSON.parse(solc.compile(JSON.stringify(input)));
477477
var x = getBytecodeStandard(output, 'cont.sol', 'x');
478-
st.ok(x);
478+
st.ok(typeof x === 'string');
479479
st.ok(x.length > 0);
480480
st.ok(Object.keys(linker.findLinkReferences(x)).length === 0);
481481
var L = getBytecodeStandard(output, 'lib.sol', 'L');
482-
st.ok(L);
482+
st.ok(typeof L === 'string');
483483
st.ok(L.length > 0);
484484
st.end();
485485
});
@@ -517,11 +517,11 @@ tape('Compilation', function (t) {
517517

518518
var output = JSON.parse(solc.lowlevel.compileStandard(JSON.stringify(input)));
519519
var x = getBytecodeStandard(output, 'cont.sol', 'x');
520-
st.ok(x);
520+
st.ok(typeof x === 'string');
521521
st.ok(x.length > 0);
522522
st.ok(Object.keys(linker.findLinkReferences(x)).length === 0);
523523
var L = getBytecodeStandard(output, 'lib.sol', 'L');
524-
st.ok(L);
524+
st.ok(typeof L === 'string');
525525
st.ok(L.length > 0);
526526
st.end();
527527
});
@@ -555,7 +555,7 @@ tape('Loading Legacy Versions', function (t) {
555555
};
556556
var output = JSON.parse(solcSnapshot.compile(JSON.stringify(input)));
557557
var x = getBytecodeStandard(output, 'cont.sol', 'x');
558-
st.ok(x);
558+
st.ok(typeof x === 'string');
559559
st.ok(x.length > 0);
560560
});
561561
});

wrapper.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,11 @@ function setupMethods (soljson) {
109109
});
110110
}
111111

112+
// Forward compatibility with 0.6.x
113+
if (typeof readCallback === 'object') {
114+
readCallback = readCallback.import;
115+
}
116+
112117
if (readCallback !== undefined && typeof readCallback !== 'function') {
113118
return formatFatalError('Invalid import callback supplied');
114119
}

0 commit comments

Comments
 (0)