Update packages (including testrpc-sc)

leapdao
Alex 6 years ago
parent a6683ba89b
commit 956cb3371e
  1. 2
      lib/app.js
  2. 15
      lib/coverageMap.js
  3. 2
      lib/instrumenter.js
  4. 1249
      package-lock.json
  5. 8
      package.json
  6. 8
      test/app.js
  7. 5
      test/cli/events.js
  8. 3
      test/cli/sign.js
  9. 7
      test/util/vm.js

@ -210,7 +210,7 @@ class App {
if (!this.norpc) {
const defaultRpcOptions = `--accounts ${this.accounts} --port ${this.port}`;
const options = (this.testrpcOptions || defaultRpcOptions) + ` --gasLimit ${gasLimitHex}`;
const command = require.resolve('ethereumjs-testrpc-sc/build/cli.node.js');
const command = require.resolve('ethereumjs-testrpc-sc/cli.js');
// Launch
const execOpts = {maxBuffer: 1024 * 1024 * 10};

@ -3,7 +3,8 @@
* This file contains methods that produce a coverage map to pass to instanbul
* from data generated by `instrumentSolidity.js`
*/
const SolidityCoder = require('web3-eth-abi');
const { AbiCoder } = require('web3-eth-abi');
const SolidityCoder = AbiCoder();
const path = require('path');
const keccak = require('keccakjs');
const fs = require('fs');
@ -103,27 +104,27 @@ module.exports = class CoverageMap {
const event = JSON.parse(events[idx]);
if (event.topics.filter(t => this.lineTopics.indexOf(t) >= 0).length > 0) {
const data = SolidityCoder.decodeParameters(['string', 'uint256'], event.data.replace('0x', ''));
const data = SolidityCoder.decodeParameters(['string', 'uint256'], `0x${event.data}`);
const canonicalContractPath = data[0];
this.coverage[canonicalContractPath].l[parseInt(data[1], 10)] += 1;
} else if (event.topics.filter(t => this.functionTopics.indexOf(t) >= 0).length > 0) {
const data = SolidityCoder.decodeParameters(['string', 'uint256'], event.data.replace('0x', ''));
const data = SolidityCoder.decodeParameters(['string', 'uint256'], `0x${event.data}`);
const canonicalContractPath = data[0];
this.coverage[canonicalContractPath].f[parseInt(data[1], 10)] += 1;
} else if (event.topics.filter(t => this.branchTopics.indexOf(t) >= 0).length > 0) {
const data = SolidityCoder.decodeParameters(['string', 'uint256', 'uint256'], event.data.replace('0x', ''));
const data = SolidityCoder.decodeParameters(['string', 'uint256', 'uint256'], `0x${event.data}`);
const canonicalContractPath = data[0];
this.coverage[canonicalContractPath].b[parseInt(data[1], 10)][parseInt(data[2], 10)] += 1;
} else if (event.topics.filter(t => this.statementTopics.indexOf(t) >= 0).length > 0) {
const data = SolidityCoder.decodeParameters(['string', 'uint256'], event.data.replace('0x', ''));
const data = SolidityCoder.decodeParameters(['string', 'uint256'], `0x${event.data}`);
const canonicalContractPath = data[0];
this.coverage[canonicalContractPath].s[parseInt(data[1], 10)] += 1;
} else if (event.topics.filter(t => this.assertPreTopics.indexOf(t) >= 0).length > 0) {
const data = SolidityCoder.decodeParameters(['string', 'uint256'], event.data.replace('0x', ''));
const data = SolidityCoder.decodeParameters(['string', 'uint256'], `0x${event.data}`);
const canonicalContractPath = data[0];
this.assertCoverage[canonicalContractPath][parseInt(data[1], 10)].preEvents += 1;
} else if (event.topics.filter(t => this.assertPostTopics.indexOf(t) >= 0).length > 0) {
const data = SolidityCoder.decodeParameters(['string', 'uint256'], event.data.replace('0x', ''));
const data = SolidityCoder.decodeParameters(['string', 'uint256'], `0x${event.data}`);
const canonicalContractPath = data[0];
this.assertCoverage[canonicalContractPath][parseInt(data[1], 10)].postEvents += 1;
}

@ -177,7 +177,7 @@ instrumenter.instrumentFunctionDeclaration = function instrumentFunctionDeclarat
const endline = startline + (functionDefinition.match(/\n/g) || []).length;
const endcol = functionDefinition.length - functionDefinition.lastIndexOf('\n');
contract.fnMap[contract.fnId] = {
name: expression.name,
name: expression.isConstructor ? 'constructor' : expression.name,
line: startline,
loc: {
start: {

1249
package-lock.json generated

File diff suppressed because it is too large Load Diff

@ -22,7 +22,7 @@
"license": "ISC",
"dependencies": {
"death": "^1.1.0",
"ethereumjs-testrpc-sc": "6.1.6",
"ethereumjs-testrpc-sc": "6.4.1",
"istanbul": "^0.4.5",
"keccakjs": "^0.2.1",
"req-cwd": "^1.0.1",
@ -30,8 +30,8 @@
"sol-explore": "^1.6.2",
"solidity-parser-antlr": "^0.4.1",
"tree-kill": "^1.2.0",
"web3": "^1.0.0-beta.37",
"web3-eth-abi": "1.0.0-beta.37"
"web3": "^1.0.0-beta.50",
"web3-eth-abi": "1.0.0-beta.50"
},
"devDependencies": {
"crypto-js": "^3.1.9-1",
@ -42,7 +42,7 @@
"ethereumjs-account": "~2.0.4",
"ethereumjs-tx": "^1.2.2",
"ethereumjs-util": "^5.0.1",
"ethereumjs-vm": "https://github.com/sc-forks/ethereumjs-vm-sc.git#6be86e6f12634b711423203e6744cafe07c38e69",
"ethereumjs-vm": "git+https://github.com/sc-forks/ethereumjs-vm-sc.git#3c328147a2c48a379af775930f52c439813a21e2",
"merkle-patricia-tree": "~2.1.2",
"mocha": "^4.1.0",
"request": "^2.88.0",

@ -111,7 +111,7 @@ describe('app', () => {
}
});
it.skip('contract tests events: tests should pass without errors', () => {
it('contract tests events: tests should pass without errors', () => {
if (!process.env.CI) {
assert(pathExists('./coverage') === false, 'should start without: coverage');
assert(pathExists('./coverage.json') === false, 'should start without: coverage.json');
@ -159,6 +159,9 @@ describe('app', () => {
compilers: {
solc: {
version: "0.5.3",
settings: {
evmVersion: "constantinople"
}
}
}
};`;
@ -328,7 +331,7 @@ describe('app', () => {
collectGarbage();
});
it.skip('contract uses inheritance: should generate coverage, cleanup & exit(0)', () => {
it('contract uses inheritance: should generate coverage, cleanup & exit(0)', () => {
// Run against a contract that 'is' another contract
assert(pathExists('./coverage') === false, 'should start without: coverage');
assert(pathExists('./coverage.json') === false, 'should start without: coverage.json');
@ -343,7 +346,6 @@ describe('app', () => {
const produced = JSON.parse(fs.readFileSync('./coverage.json', 'utf8'));
const ownedPath = Object.keys(produced)[0];
const proxyPath = Object.keys(produced)[1];
assert(produced[ownedPath].fnMap['1'].name === 'constructor', 'coverage.json should map "constructor"');
assert(produced[proxyPath].fnMap['1'].name === 'isOwner', 'coverage.json should map "isOwner"');
collectGarbage();

@ -8,12 +8,13 @@ contract('Events', accounts => {
const loggedEvents = [];
Events.deployed().then(instance => {
const allEvents = instance.allEvents();
allEvents.watch((error, event) => { loggedEvents.push(event); });
allEvents.on("data", event => { loggedEvents.push(event); });
instance.test(5).then(() => {
const bad = loggedEvents.filter(e => e.event !== 'LogEventOne' && e.event !== 'LogEventTwo');
assert(bad.length === 0, 'Did not filter events correctly');
allEvents.stopWatching(done);
done();
});
});
});

@ -1,11 +1,8 @@
/* eslint-env node, mocha */
/* global artifacts, contract, assert */
const Web3 = require('web3');
const ethUtil = require('ethereumjs-util');
const provider = new Web3.providers.HttpProvider('http://localhost:8555'); // testrpc-sc
const web3 = new Web3(provider);
const Simple = artifacts.require('./Simple.sol');
contract('Simple', accounts => {

@ -7,7 +7,9 @@ const Transaction = require('ethereumjs-tx');
const utils = require('ethereumjs-util');
const CryptoJS = require('crypto-js');
const Trie = require('merkle-patricia-tree');
const coder = require('web3-eth-abi');
const { AbiCoder } = require('web3-eth-abi');
const SolidityCoder = AbiCoder();
const codeToCompilerInput = require('./util').codeToCompilerInput;
// Don't use this address for anything, obviously!
@ -23,7 +25,7 @@ function encodeFunctionTxData(functionName, types, args) {
const signature = CryptoJS.SHA3(fullName, {
outputLength: 256,
}).toString(CryptoJS.enc.Hex).slice(0, 8);
const dataHex = signature + coder.encodeParameters(types, args).slice(2);
const dataHex = signature + SolidityCoder.encodeParameters(types, args).slice(2);
return `0x${dataHex}`;
}
@ -147,6 +149,7 @@ module.exports.execute = function ex(contract, functionName, args) {
const stateTrie = new Trie();
const vm = new VM({
state: stateTrie,
hardfork: "constantinople"
});
createAccount(stateTrie);

Loading…
Cancel
Save