Skip to content

Commit 121e438

Browse files
authored
Merge pull request #409 from ethereum/cleanup
Some minor cleanups to the tests and wrapper
2 parents 251e99f + 4ee53f2 commit 121e438

File tree

3 files changed

+13
-16
lines changed

3 files changed

+13
-16
lines changed

solcjs

+3-3
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ function abort (msg) {
3535

3636
if (program.standardJson) {
3737
var input = fs.readFileSync(process.stdin.fd).toString('utf8');
38-
var output = solc.compileStandardWrapper(input);
38+
var output = solc.compile(input);
3939

4040
try {
4141
var inputJSON = smtchecker.handleSMTQueries(JSON.parse(input), JSON.parse(output), smtsolver.smtSolver);
4242
if (inputJSON) {
43-
output = solc.compileStandardWrapper(JSON.stringify(inputJSON));
43+
output = solc.compile(JSON.stringify(inputJSON));
4444
}
4545
}
4646
catch (e) {
@@ -80,7 +80,7 @@ for (var i = 0; i < files.length; i++) {
8080
}
8181
}
8282

83-
var output = JSON.parse(solc.compileStandardWrapper(JSON.stringify({
83+
var output = JSON.parse(solc.compile(JSON.stringify({
8484
language: 'Solidity',
8585
settings: {
8686
optimizer: {

test/compiler.js

+4-7
Original file line numberDiff line numberDiff line change
@@ -563,31 +563,28 @@ function runTests (solc, versionText) {
563563
t.test('compiling standard JSON (invalid JSON)', function (st) {
564564
var output = JSON.parse(solc.compile('{invalid'));
565565
// TODO: change wrapper to output matching error
566-
st.ok(expectError(output, 'JSONError', 'Line 1, Column 2\n Missing \'}\' or object member name') || expectError(output, 'SOLCError', 'Invalid JSON supplied'));
566+
st.ok(expectError(output, 'JSONError', 'Line 1, Column 2\n Missing \'}\' or object member name') || expectError(output, 'JSONError', 'Invalid JSON supplied:'));
567567
st.end();
568568
});
569569

570570
t.test('compiling standard JSON (invalid language)', function (st) {
571571
var output = JSON.parse(solc.compile('{"language":"InvalidSolidity","sources":{"cont.sol":{"content":""}}}'));
572-
// TODO: change wrapper to output matching error
573-
st.ok(expectError(output, 'JSONError', 'supported as a language.') || expectError(output, 'SOLCError', 'Only Solidity sources are supported'));
572+
st.ok(expectError(output, 'JSONError', 'supported as a language.') && expectError(output, 'JSONError', '"Solidity"'));
574573
st.end();
575574
});
576575

577576
t.test('compiling standard JSON (no sources)', function (st) {
578577
var output = JSON.parse(solc.compile('{"language":"Solidity"}'));
579-
// TODO: change wrapper to output matching error
580-
st.ok(expectError(output, 'JSONError', 'No input sources specified.') || expectError(output, 'SOLCError', 'No input specified'));
578+
st.ok(expectError(output, 'JSONError', 'No input sources specified.'));
581579
st.end();
582580
});
583581

584582
t.test('compiling standard JSON (multiple sources on old compiler)', function (st) {
585583
var output = JSON.parse(solc.compile('{"language":"Solidity","sources":{"cont.sol":{"content":"import \\"lib.sol\\";"},"lib.sol":{"content":""}}}'));
586-
console.log(output);
587584
if (solc.features.multipleInputs) {
588585
st.ok(expectNoError(output));
589586
} else {
590-
st.ok(expectError(output, 'SOLCError', 'Multiple sources provided, but compiler only supports single input') || expectError(output, 'Parser error', 'Parser error: Source not found.'));
587+
st.ok(expectError(output, 'JSONError', 'Multiple sources provided, but compiler only supports single input.') || expectError(output, 'Parser error', 'Parser error: Source not found.'));
591588
}
592589
st.end();
593590
});

wrapper.js

+6-6
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ function setupMethods (soljson) {
122122
return JSON.stringify({
123123
errors: [
124124
{
125-
'type': 'SOLCError',
125+
'type': 'JSONError',
126126
'component': 'solcjs',
127127
'severity': 'error',
128128
'message': message,
@@ -148,17 +148,17 @@ function setupMethods (soljson) {
148148
}
149149

150150
if (input['language'] !== 'Solidity') {
151-
return formatFatalError('Only Solidity sources are supported');
151+
return formatFatalError('Only "Solidity" is supported as a language.');
152152
}
153153

154154
// NOTE: this is deliberately `== null`
155155
if (input['sources'] == null || input['sources'].length === 0) {
156-
return formatFatalError('No input specified');
156+
return formatFatalError('No input sources specified.');
157157
}
158158

159159
// Bail out early
160160
if ((input['sources'].length > 1) && (compileJSONMulti === null)) {
161-
return formatFatalError('Multiple sources provided, but compiler only supports single input');
161+
return formatFatalError('Multiple sources provided, but compiler only supports single input.');
162162
}
163163

164164
function isOptimizerEnabled (input) {
@@ -192,14 +192,14 @@ function setupMethods (soljson) {
192192
}
193193
output = translate.translateJsonCompilerOutput(output, libraries);
194194
if (output == null) {
195-
return formatFatalError('Failed to process output');
195+
return formatFatalError('Failed to process output.');
196196
}
197197
return JSON.stringify(output);
198198
}
199199

200200
var sources = translateSources(input);
201201
if (sources === null || Object.keys(sources).length === 0) {
202-
return formatFatalError('Failed to process sources');
202+
return formatFatalError('Failed to process sources.');
203203
}
204204

205205
// Try linking if libraries were supplied

0 commit comments

Comments
 (0)