dapphub / dapple

EVM contract system developer multitool
GNU General Public License v3.0
298 stars 59 forks source link

Error fires: "TypeError: First argument must be a string, Buffer..." #344

Closed SilentCicero closed 7 years ago

SilentCicero commented 7 years ago

I'm getting this error for almost no particular reason:

/home/nick/github/boardroom-contracts-solc4/node_modules/solc/soljson.js:1
(function (exports, require, module, __filename, __dirname) { var Module;if(!Module)Module=(typeof Module!=="undefined"?Module:null)||{};var moduleOverrides={};for(var key in Module){if(Module.hasOwnProperty(key)){moduleOverrides[key]=Module[key]}}var ENVIRONMENT_IS_WEB=typeof window==="object";var ENVIRONMENT_IS_WORKER=typeof importScripts==="function";var ENVIRONMENT_IS_NODE=typeof process==="object"&&typeof require==="function"&&!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_WORKER;var ENVIRONMENT_IS_SHELL=!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_NODE&&!ENVIRONMENT_IS_WORKER;if(ENVIRONMENT_IS_NODE){if(!Module["print"])Module["print"]=function print(x){process["stdout"].write(x+"\n")};if(!Module["printErr"])Module["printErr"]=function printErr(x){process["stderr"].write(x+"\n")};var nodeFS=require("fs");var nodePath=require("path");Module["read"]=function read(filename,binary){filename=nodePath["normalize"](filename);var ret=nodeFS["readFileSync

TypeError: First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.
    at fromObject (buffer.js:259:9)
    at Function.Buffer.from (buffer.js:96:10)
    at new Buffer (buffer.js:75:17)
    at Function.testResult (/home/nick/github/boardroom-contracts-solc4/node_modules/dapple-test/lib/vmtest.js:74:13)
    at Object.captureTestResults [as callback] (/home/nick/github/boardroom-contracts-solc4/node_modules/dapple-test/lib/vmtest.js:308:27)
    at /home/nick/github/boardroom-contracts-solc4/node_modules/web3/lib/web3/method.js:142:25
    at /home/nick/github/boardroom-contracts-solc4/node_modules/web3/lib/web3/requestmanager.js:82:20
    at engine.sendAsync (/home/nick/github/boardroom-contracts-solc4/node_modules/dapple-chain/lib/server.js:185:11)
    at /home/nick/github/boardroom-contracts-solc4/node_modules/web3-provider-engine/index.js:127:9
    at /home/nick/github/boardroom-contracts-solc4/node_modules/web3-provider-engine/node_modules/async/lib/async.js:52:16
npm ERR! Test failed.  See above for more details.

I'm using dapple 0.8.15, pragma solidity ^0.4.3;. The errors can come from almost nothing, i.e. adding a blank method, adding in repeat code that has nothing to do with strings, Buffers or anything of the sort. I cant trace the error, as it's not loud enough.

I've now had this error on two occasions, with two test files that worked fine in dapple 7.3, solc 3x.

Any thoughts on how to debug this?

It's definitely a dapple thing, my contract code is valid, and virtually the same as before re: dapple 7.2

Seems this has something to do with it: https://github.com/nexusdev/dapple-test/blob/master/lib/vmtest.js#L74 https://github.com/nexusdev/dapple-test/blob/master/lib/vmtest.js#L303 https://github.com/nexusdev/dapple-chain/blob/master/lib/server.js#L181

Potentially the server.js is the culprit.

If you uncomment this line test, and run it: npm test.. you will see the error: https://github.com/boardroom-project/boardroom-contracts/blob/master/contracts/examples/tests/CampaignRules_test.sol#L93

To recreate:

git clone https://github.com/boardroom-project/boardroom-contracts.git
npm install

Uncomment these lines: https://github.com/boardroom-project/boardroom-contracts/blob/master/contracts/examples/tests/CampaignRules_test.sol#L93

then:

npm test
mhhf commented 7 years ago

Sorry for the late response. Found the error and will release a fix in about one hour. It was caused by an incoherent contract argument naming between solc and solcjs, in this case between runtimeBytecode and bin-runtime. https://github.com/ethereum/solc-js/issues/67

mhhf commented 7 years ago

Successfully tested with dapple 0.8.18!

SilentCicero commented 7 years ago

@mhhf thanks Dennis, shall we close?