Skip to content

Commit

Permalink
Use the CLI solc instead of solc directly for ABI testcase generation.
Browse files Browse the repository at this point in the history
  • Loading branch information
ricmoo committed Jul 23, 2019
1 parent b132e32 commit 99c7b1c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 44 deletions.
8 changes: 4 additions & 4 deletions packages/testcases/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -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",
Expand All @@ -32,5 +32,5 @@
"publishConfig": {
"access": "public"
},
"tarballHash": "0xfff9df8ed261c3864aa377821af02945ecafd9160c443500de38fee4fe5652ce"
"tarballHash": "0xd661e673f06d0cd44fec8bbef06c1f6e0b0c5113b6311ea0ec236af4310a5b19"
}
40 changes: 3 additions & 37 deletions packages/testcases/src.ts/generation-scripts/abi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 = {
Expand Down
6 changes: 3 additions & 3 deletions tsconfig.project.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,6 @@
{
"path": "./packages/solidity"
},
{
"path": "./packages/testcases"
},
{
"path": "./packages/transactions"
},
Expand Down Expand Up @@ -111,6 +108,9 @@
{
"path": "./packages/experimental"
},
{
"path": "./packages/testcases"
},
{
"path": "./packages/tests"
}
Expand Down

0 comments on commit 99c7b1c

Please sign in to comment.