Skip to content

Commit 7ac6703

Browse files
authored
Merge branch 'main' into cl/solc-0.8.30
2 parents 48b7c19 + b8f3073 commit 7ac6703

File tree

14 files changed

+1179
-1081
lines changed

14 files changed

+1179
-1081
lines changed

.prettierrc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@
22
"trailingComma": "es5",
33
"tabWidth": 2,
44
"semi": false,
5-
"singleQuote": false
5+
"singleQuote": true
66
}
Lines changed: 30 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,33 @@
1-
import * as path from 'path';
1+
import * as path from 'path'
22

3-
const outputDir = 'artifacts';
4-
const binExtension = ':C.pvm';
5-
const asmExtension = ':C.pvmasm';
6-
const llvmExtension = '.ll';
7-
const contractSolFilename = 'contract.sol';
8-
const contractYulFilename = 'contract.yul';
9-
const contractOptimizedLLVMFilename = contractSolFilename + '.C.optimized';
10-
const contractUnoptimizedLLVMFilename = contractSolFilename + '.C.unoptimized';
11-
const pathToOutputDir = path.join(__dirname, '..', outputDir);
12-
const pathToContracts = path.join(__dirname, '..', 'src', 'contracts');
13-
const pathToBasicYulContract = path.join(pathToContracts, 'yul', contractYulFilename);
14-
const pathToBasicSolContract = path.join(pathToContracts, 'solidity', contractSolFilename);
15-
const pathToSolBinOutputFile = path.join(pathToOutputDir, contractSolFilename + binExtension);
16-
const pathToSolAsmOutputFile = path.join(pathToOutputDir, contractSolFilename + asmExtension);
3+
const outputDir = 'artifacts'
4+
const binExtension = ':C.pvm'
5+
const asmExtension = ':C.pvmasm'
6+
const llvmExtension = '.ll'
7+
const contractSolFilename = 'contract.sol'
8+
const contractYulFilename = 'contract.yul'
9+
const contractOptimizedLLVMFilename = contractSolFilename + '.C.optimized'
10+
const contractUnoptimizedLLVMFilename = contractSolFilename + '.C.unoptimized'
11+
const pathToOutputDir = path.join(__dirname, '..', outputDir)
12+
const pathToContracts = path.join(__dirname, '..', 'src', 'contracts')
13+
const pathToBasicYulContract = path.join(
14+
pathToContracts,
15+
'yul',
16+
contractYulFilename
17+
)
18+
const pathToBasicSolContract = path.join(
19+
pathToContracts,
20+
'solidity',
21+
contractSolFilename
22+
)
23+
const pathToSolBinOutputFile = path.join(
24+
pathToOutputDir,
25+
contractSolFilename + binExtension
26+
)
27+
const pathToSolAsmOutputFile = path.join(
28+
pathToOutputDir,
29+
contractSolFilename + asmExtension
30+
)
1731

1832
export const paths = {
1933
outputDir: outputDir,
@@ -30,4 +44,4 @@ export const paths = {
3044
pathToBasicYulContract: pathToBasicYulContract,
3145
pathToSolBinOutputFile: pathToSolBinOutputFile,
3246
pathToSolAsmOutputFile: pathToSolAsmOutputFile,
33-
};
47+
}
Lines changed: 39 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,51 @@
1-
import * as shell from 'shelljs';
2-
import * as fs from 'fs';
3-
import { spawnSync } from 'child_process';
1+
import * as shell from 'shelljs'
2+
import * as fs from 'fs'
3+
import { spawnSync } from 'child_process'
44

55
interface CommandResult {
6-
output: string;
7-
exitCode: number;
6+
output: string
7+
exitCode: number
88
}
99

10-
export const executeCommand = (command: string, stdin?: string): CommandResult => {
11-
if (stdin) {
12-
const process = spawnSync(command, [], {
13-
input: stdin,
14-
shell: true,
15-
encoding: 'utf8',
16-
maxBuffer: 30 * 1024 * 1024
17-
});
10+
export const executeCommand = (
11+
command: string,
12+
stdin?: string
13+
): CommandResult => {
14+
if (stdin) {
15+
const process = spawnSync(command, [], {
16+
input: stdin,
17+
shell: true,
18+
encoding: 'utf8',
19+
maxBuffer: 30 * 1024 * 1024,
20+
})
1821

19-
return {
20-
exitCode: process.status || 0,
21-
output: (process.stdout || process.stderr || '').toString()
22-
};
22+
return {
23+
exitCode: process.status || 0,
24+
output: (process.stdout || process.stderr || '').toString(),
2325
}
26+
}
2427

25-
const result = shell.exec(command, { silent: true, async: false });
26-
return {
27-
exitCode: result.code,
28-
output: result.stdout || result.stderr || ''
29-
};
30-
};
28+
const result = shell.exec(command, { silent: true, async: false })
29+
return {
30+
exitCode: result.code,
31+
output: result.stdout || result.stderr || '',
32+
}
33+
}
3134

3235
export const isFolderExist = (folder: string): boolean => {
33-
return shell.test('-d', folder);
34-
};
36+
return shell.test('-d', folder)
37+
}
3538

36-
export const isFileExist = (pathToFileDir: string, fileName: string, fileExtension: string): boolean => {
37-
return shell.ls(pathToFileDir).stdout.includes(fileName + fileExtension);
38-
};
39+
export const isFileExist = (
40+
pathToFileDir: string,
41+
fileName: string,
42+
fileExtension: string
43+
): boolean => {
44+
return shell.ls(pathToFileDir).stdout.includes(fileName + fileExtension)
45+
}
3946

4047
export const isFileEmpty = (file: string): boolean => {
41-
if (fs.existsSync(file)) {
42-
return (fs.readFileSync(file).length === 0);
43-
}
44-
};
48+
if (fs.existsSync(file)) {
49+
return fs.readFileSync(file).length === 0
50+
}
51+
}
Lines changed: 37 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,44 @@
1-
import {executeCommand} from "../src/helper";
2-
import { paths } from '../src/entities';
3-
1+
import { executeCommand } from '../src/helper'
2+
import { paths } from '../src/entities'
43

54
//id1746
6-
describe("Run with --asm by default", () => {
7-
const command = `resolc ${paths.pathToBasicSolContract} --asm`;
8-
const result = executeCommand(command);
9-
const commandInvalid = 'resolc --asm';
10-
const resultInvalid = executeCommand(commandInvalid);
5+
describe('Run with --asm by default', () => {
6+
const command = `resolc ${paths.pathToBasicSolContract} --asm`
7+
const result = executeCommand(command)
8+
const commandInvalid = 'resolc --asm'
9+
const resultInvalid = executeCommand(commandInvalid)
1110

12-
it("Valid command exit code = 0", () => {
13-
expect(result.exitCode).toBe(0);
14-
});
11+
it('Valid command exit code = 0', () => {
12+
expect(result.exitCode).toBe(0)
13+
})
1514

16-
it("--asm output is presented", () => {
17-
const expectedPatterns = [/(deploy)/i, /(call)/i, /(seal_return)/i];
15+
it('--asm output is presented', () => {
16+
const expectedPatterns = [/(deploy)/i, /(call)/i, /(seal_return)/i]
1817

1918
for (const pattern of expectedPatterns) {
20-
expect(result.output).toMatch(pattern);
19+
expect(result.output).toMatch(pattern)
2120
}
22-
});
23-
24-
it("solc exit code == resolc exit code", () => {
25-
const command = `solc ${paths.pathToBasicSolContract} --asm`;
26-
const solcResult = executeCommand(command);
27-
expect(solcResult.exitCode).toBe(result.exitCode);
28-
});
29-
30-
it("run invalid: resolc --asm", () => {
31-
expect(resultInvalid.output).toMatch(/(No input sources specified|Compilation aborted)/i);
32-
});
33-
34-
it("Invalid command exit code = 1", () => {
35-
expect(resultInvalid.exitCode).toBe(1);
36-
});
37-
38-
it("Invalid solc exit code == Invalid resolc exit code", () => {
39-
const command = 'solc --asm';
40-
const solcResult = executeCommand(command);
41-
expect(solcResult.exitCode).toBe(resultInvalid.exitCode);
42-
});
43-
});
21+
})
22+
23+
it('solc exit code == resolc exit code', () => {
24+
const command = `solc ${paths.pathToBasicSolContract} --asm`
25+
const solcResult = executeCommand(command)
26+
expect(solcResult.exitCode).toBe(result.exitCode)
27+
})
28+
29+
it('run invalid: resolc --asm', () => {
30+
expect(resultInvalid.output).toMatch(
31+
/(No input sources specified|Compilation aborted)/i
32+
)
33+
})
34+
35+
it('Invalid command exit code = 1', () => {
36+
expect(resultInvalid.exitCode).toBe(1)
37+
})
38+
39+
it('Invalid solc exit code == Invalid resolc exit code', () => {
40+
const command = 'solc --asm'
41+
const solcResult = executeCommand(command)
42+
expect(solcResult.exitCode).toBe(resultInvalid.exitCode)
43+
})
44+
})

0 commit comments

Comments
 (0)