Use the CLI solc instead of solc directly for ABI testcase generation.
This commit is contained in:
parent
b132e32172
commit
99c7b1ca94
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@ethersproject/testcases",
|
||||
"version": "5.0.0-beta.126",
|
||||
"version": "5.0.0-beta.127",
|
||||
"description": "Testcases for Ethereum and scripts to generate testcases.",
|
||||
"main": "index.js",
|
||||
"browser": "browser.js",
|
||||
|
@ -15,13 +15,13 @@
|
|||
"browserify-zlib": "^0.2.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@ethersproject/cli": ">=5.0.0-beta.133",
|
||||
"@types/bip39": "2.4.1",
|
||||
"@types/bitcoinjs-lib": "3.3.2",
|
||||
"bip39": "2.5.0",
|
||||
"bitcoinjs-lib": "3.3.2",
|
||||
"ethereumjs-tx": "^1.3.5",
|
||||
"ethereumjs-util": "^5.2.0",
|
||||
"solc": "0.5.9"
|
||||
"ethereumjs-util": "^5.2.0"
|
||||
},
|
||||
"keywords": [
|
||||
"Ethereum",
|
||||
|
@ -32,5 +32,5 @@
|
|||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"tarballHash": "0xfff9df8ed261c3864aa377821af02945ecafd9160c443500de38fee4fe5652ce"
|
||||
"tarballHash": "0xd661e673f06d0cd44fec8bbef06c1f6e0b0c5113b6311ea0ec236af4310a5b19"
|
||||
}
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
|
||||
//let web3 = new Web3(new Web3.providers.HttpProvider('http://127.0.0.1:8549'));
|
||||
|
||||
import { compile as _compile } from "solc";
|
||||
//import { compile as _compile } from "solc";
|
||||
import { compile } from "@ethersproject/cli/solc";
|
||||
|
||||
import { randomHexString, randomNumber } from ".."
|
||||
import { BN, keccak256, toChecksumAddress } from "ethereumjs-util";
|
||||
|
@ -58,41 +59,6 @@ class Code {
|
|||
}
|
||||
}
|
||||
|
||||
function compile(source: string): string {
|
||||
let input = {
|
||||
language: "Solidity",
|
||||
sources: {
|
||||
"test.sol": {
|
||||
content: source
|
||||
}
|
||||
},
|
||||
settings: {
|
||||
optimizer: {
|
||||
enabled: true,
|
||||
runs: 200
|
||||
},
|
||||
evmVersion: "byzantium",
|
||||
outputSelection: {
|
||||
"*": {
|
||||
"*": [ "evm.bytecode" ]
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
let output = JSON.parse(_compile(JSON.stringify(input)));
|
||||
let errors = ((<any>output).errors || []).filter((e : any) => (e.severity == "error"));
|
||||
|
||||
if (errors.length) {
|
||||
errors.forEach((error: any) => {
|
||||
console.log(error.formattedMessage);
|
||||
});
|
||||
process.exit();
|
||||
}
|
||||
|
||||
return "0x" + output.contracts["test.sol"].Test.evm.bytecode.object;
|
||||
}
|
||||
|
||||
//idea: "tuple(address)/*StructABCDEFG*/"
|
||||
type TestData = {
|
||||
// The data type
|
||||
|
@ -651,7 +617,7 @@ for (let i = 0; i < 100; i++) {
|
|||
let solidity = generateSolidity(params);
|
||||
console.log(solidity);
|
||||
console.log(i);
|
||||
let bytecode = compile(solidity);
|
||||
let bytecode = compile(solidity)[0].bytecode;
|
||||
//console.log(params.map(p => p.type).join(", "));
|
||||
//console.log(bytecode);
|
||||
let testcase = {
|
||||
|
|
|
@ -66,9 +66,6 @@
|
|||
{
|
||||
"path": "./packages/solidity"
|
||||
},
|
||||
{
|
||||
"path": "./packages/testcases"
|
||||
},
|
||||
{
|
||||
"path": "./packages/transactions"
|
||||
},
|
||||
|
@ -111,6 +108,9 @@
|
|||
{
|
||||
"path": "./packages/experimental"
|
||||
},
|
||||
{
|
||||
"path": "./packages/testcases"
|
||||
},
|
||||
{
|
||||
"path": "./packages/tests"
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue