mirror of
https://github.com/pezkuwichain/revive.git
synced 2026-04-22 04:27:58 +00:00
Fix stack overflow issue (#184)
This commit is contained in:
committed by
GitHub
parent
1a8a7926e9
commit
8201401fef
@@ -14,5 +14,6 @@ rustflags = [
|
||||
"-Clink-arg=--pre-js=js/embed/pre.js",
|
||||
"-Clink-arg=-sNODEJS_CATCH_EXIT=0",
|
||||
"-Clink-arg=-sDISABLE_EXCEPTION_CATCHING=0",
|
||||
"-Clink-arg=-sSTACK_SIZE=128kb",
|
||||
"-Copt-level=3"
|
||||
]
|
||||
|
||||
+38
-4
@@ -26,7 +26,7 @@ async function runWorker(page, input) {
|
||||
}, input);
|
||||
}
|
||||
|
||||
test('should successfully compile valid Solidity code in browser', async ({ page }) => {
|
||||
test('should successfully compile valid Solidity code in the browser', async ({ page }) => {
|
||||
await page.goto("http://127.0.0.1:8080");
|
||||
await page.setContent("");
|
||||
const standardInput = loadFixture('storage.json')
|
||||
@@ -41,7 +41,7 @@ test('should successfully compile valid Solidity code in browser', async ({ page
|
||||
expect(output.contracts['fixtures/storage.sol'].Storage.evm).toHaveProperty('bytecode');
|
||||
});
|
||||
|
||||
test('should successfully compile large valid Solidity code in browser', async ({ page }) => {
|
||||
test('should successfully compile large valid Solidity code in the browser', async ({ page }) => {
|
||||
await page.goto("http://127.0.0.1:8080");
|
||||
await page.setContent("");
|
||||
const standardInput = loadFixture('token.json')
|
||||
@@ -56,7 +56,7 @@ test('should successfully compile large valid Solidity code in browser', async (
|
||||
expect(output.contracts['fixtures/token.sol'].MyToken.evm).toHaveProperty('bytecode');
|
||||
});
|
||||
|
||||
test('should throw an error for invalid Solidity code in browser', async ({ page }) => {
|
||||
test('should throw an error for invalid Solidity code in the browser', async ({ page }) => {
|
||||
await page.goto("http://127.0.0.1:8080");
|
||||
await page.setContent("");
|
||||
const standardInput = loadFixture('invalid_contract_content.json')
|
||||
@@ -71,7 +71,7 @@ test('should throw an error for invalid Solidity code in browser', async ({ page
|
||||
expect(output.errors[0].type).toContain('ParserError');
|
||||
});
|
||||
|
||||
test('should return not found error for missing imports in browser', async ({page}) => {
|
||||
test('should return not found error for missing imports in the browser', async ({page}) => {
|
||||
await page.goto("http://127.0.0.1:8080");
|
||||
await page.setContent("");
|
||||
const standardInput = loadFixture('missing_import.json')
|
||||
@@ -85,3 +85,37 @@ test('should return not found error for missing imports in browser', async ({pag
|
||||
expect(output.errors[0]).toHaveProperty('message');
|
||||
expect(output.errors[0].message).toContain('Source "nonexistent/console.sol" not found');
|
||||
});
|
||||
|
||||
test('should successfully compile a valid Solidity contract that instantiates another contract in the browser', async ({ page }) => {
|
||||
await page.goto("http://127.0.0.1:8080");
|
||||
await page.setContent("");
|
||||
const standardInput = loadFixture('instantiate.json')
|
||||
const result = await runWorker(page, standardInput);
|
||||
|
||||
expect(typeof result).toBe('string');
|
||||
let output = JSON.parse(result);
|
||||
expect(output).toHaveProperty('contracts');
|
||||
expect(output.contracts['fixtures/instantiate.sol']).toHaveProperty('ChildContract');
|
||||
expect(output.contracts['fixtures/instantiate.sol'].ChildContract).toHaveProperty('abi');
|
||||
expect(output.contracts['fixtures/instantiate.sol'].ChildContract).toHaveProperty('evm');
|
||||
expect(output.contracts['fixtures/instantiate.sol'].ChildContract.evm).toHaveProperty('bytecode');
|
||||
expect(output.contracts['fixtures/instantiate.sol']).toHaveProperty('MainContract');
|
||||
expect(output.contracts['fixtures/instantiate.sol'].MainContract).toHaveProperty('abi');
|
||||
expect(output.contracts['fixtures/instantiate.sol'].MainContract).toHaveProperty('evm');
|
||||
expect(output.contracts['fixtures/instantiate.sol'].MainContract.evm).toHaveProperty('bytecode');
|
||||
});
|
||||
|
||||
test('should successfully compile a valid Solidity contract that instantiates the token contracts in the browser', async ({ page }) => {
|
||||
await page.goto("http://127.0.0.1:8080");
|
||||
await page.setContent("");
|
||||
const standardInput = loadFixture('instantiate_tokens.json')
|
||||
const result = await runWorker(page, standardInput);
|
||||
|
||||
expect(typeof result).toBe('string');
|
||||
let output = JSON.parse(result);
|
||||
expect(output).toHaveProperty('contracts');
|
||||
expect(output.contracts['fixtures/instantiate_tokens.sol']).toHaveProperty('TokensFactory');
|
||||
expect(output.contracts['fixtures/instantiate_tokens.sol'].TokensFactory).toHaveProperty('abi');
|
||||
expect(output.contracts['fixtures/instantiate_tokens.sol'].TokensFactory).toHaveProperty('evm');
|
||||
expect(output.contracts['fixtures/instantiate_tokens.sol'].TokensFactory.evm).toHaveProperty('bytecode');
|
||||
});
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"language": "Solidity",
|
||||
"sources": {
|
||||
"fixtures/instantiate.sol": {
|
||||
"content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity >=0.8.2 <0.9.0;\ncontract ChildContract {\n constructor() {\n }\n}\ncontract MainContract {\n constructor() {\n ChildContract newContract = new ChildContract();\n }\n}"
|
||||
}
|
||||
},
|
||||
"settings": {
|
||||
"optimizer": {
|
||||
"enabled": true,
|
||||
"runs": 200
|
||||
},
|
||||
"outputSelection": {
|
||||
"*": {
|
||||
"*": ["abi"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -41,6 +41,27 @@ describe('Compile Function Tests', function () {
|
||||
expect(output.contracts['fixtures/token.sol'].MyToken).to.have.property('evm');
|
||||
expect(output.contracts['fixtures/token.sol'].MyToken.evm).to.have.property('bytecode');
|
||||
});
|
||||
|
||||
it("should successfully compile a valid Solidity contract that instantiates the token contracts", async function () {
|
||||
const standardInput = loadFixture("instantiate_tokens.json");
|
||||
|
||||
const result = await compile(standardInput);
|
||||
expect(result).to.be.a("string");
|
||||
const output = JSON.parse(result);
|
||||
expect(output).to.have.property("contracts");
|
||||
expect(output.contracts["fixtures/instantiate_tokens.sol"]).to.have.property(
|
||||
"TokensFactory",
|
||||
);
|
||||
expect(output.contracts["fixtures/instantiate_tokens.sol"].TokensFactory).to.have.property(
|
||||
"abi",
|
||||
);
|
||||
expect(output.contracts["fixtures/instantiate_tokens.sol"].TokensFactory).to.have.property(
|
||||
"evm",
|
||||
);
|
||||
expect(
|
||||
output.contracts["fixtures/instantiate_tokens.sol"].TokensFactory.evm,
|
||||
).to.have.property("bytecode");
|
||||
});
|
||||
}
|
||||
|
||||
it('should throw an error for invalid Solidity code', async function () {
|
||||
@@ -67,4 +88,38 @@ describe('Compile Function Tests', function () {
|
||||
expect(output.errors[0].message).to.exist;
|
||||
expect(output.errors[0].message).to.include('Source "nonexistent/console.sol" not found');
|
||||
});
|
||||
|
||||
it("should successfully compile a valid Solidity contract that instantiates another contract", async function () {
|
||||
const standardInput = loadFixture("instantiate.json");
|
||||
|
||||
const result = await compile(standardInput);
|
||||
expect(result).to.be.a("string");
|
||||
const output = JSON.parse(result);
|
||||
expect(output).to.have.property("contracts");
|
||||
expect(output.contracts["fixtures/instantiate.sol"]).to.have.property(
|
||||
"ChildContract",
|
||||
);
|
||||
expect(output.contracts["fixtures/instantiate.sol"].ChildContract).to.have.property(
|
||||
"abi",
|
||||
);
|
||||
expect(output.contracts["fixtures/instantiate.sol"].ChildContract).to.have.property(
|
||||
"evm",
|
||||
);
|
||||
expect(
|
||||
output.contracts["fixtures/instantiate.sol"].ChildContract.evm,
|
||||
).to.have.property("bytecode");
|
||||
expect(output.contracts["fixtures/instantiate.sol"]).to.have.property(
|
||||
"MainContract",
|
||||
);
|
||||
expect(output.contracts["fixtures/instantiate.sol"].MainContract).to.have.property(
|
||||
"abi",
|
||||
);
|
||||
expect(output.contracts["fixtures/instantiate.sol"].MainContract).to.have.property(
|
||||
"evm",
|
||||
);
|
||||
expect(
|
||||
output.contracts["fixtures/instantiate.sol"].MainContract.evm,
|
||||
).to.have.property("bytecode");
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user