Git Product home page Git Product logo

ganache-cli-archive's Issues

eth_estimateGas returns wrong estimation

Hi, I'm currently playing around with browser-solidity connected to the testrpc, they have a logic there, that before each transaction to the real node (and they assume testrpc to be real node of course) they call estimateGas, then adjust gas for transaction to what was returned by estimation, then send transaction. The problem is, that for a transaction that will actually eat 225444 gas, it estimates only 75444. There is also situations when the estimate is bigger than actual use.

how to use evm_snapshot

Hi, I have tried to use evm_snapshot using

server.provider.manager.evm_snapshot(function(err,snapshotId){...});

but I get some error in web3 in the test using snapsho and revert.

I am not sure I am using it correctly

I initialise testrpc this way (in mocha code):

var TestRPC = require("ethereumjs-testrpc");
var server = TestRPC.server();
before(function(done){
    server.listen(8545, function() {
        web3.setProvider(new web3.providers.HttpProvider("http://localhost:8545"));
        done();
    });
})

the only test that fail is the one using the snapshot feature. any help woudl be appreciated
Thanks

Feature: Use HD wallet

TODO:

  • allow -m/--mnemonic to input an HD wallet mnemonic
  • print out private keys
  • print out mnemonic
  • -d option uses a default mnemonic instead of default seed
  • Finally, create accounts through the HD wallet rather than generating them randomly like we do now.

Sample code provided by @axic:

const bip39 = require('bip39')
const hdkey = require('ethereumjs-wallet/hdkey')

var mnemonic = 'awake book subject inch gentle blur grant damage process float month clown'
var wallet = hdkey.fromMasterSeed(bip39.mnemonicToSeed(mnemonic)

var account = wallet.derivePath("m/44'/60'/0'/0/" + index) // index is a number
var address = account.getWallet().getAddressString() // 0x prefixed String
var publicKey = account.getWallet().getPublicKey() // Buffer
var secretkey = account.getWallet().getPrivateKey() // Buffer

Speed Hacks

Here are some sneaky things you can do to get some speedups

  • use the fake stateTrie if you don't care about state roots
    ( you can still checkpoint and revert )
  • skip proper tx signing by overriding the from: field
  • skip tx signing for eth_call's
transaction.from = new Buffer(ethUtil.stripHexPrefix(txParams.from), 'hex')

please improve install instructions for ubuntu user

Tried to install using sudo npm install -g ethereumjs-testrpc (after first installing npm on ubuntu), and it failed with below errors. Please advise - thanks.

[email protected] rebuild /usr/local/lib/node_modules/ethereumjs-testrpc/node_modules/ethereumjs-util/node_modules/secp256k1
node-gyp rebuild

npm http 304 https://registry.npmjs.org/bindings
npm http 304 https://registry.npmjs.org/elliptic
npm http 304 https://registry.npmjs.org/bn.js
npm http 304 https://registry.npmjs.org/drbg.js
npm http 304 https://registry.npmjs.org/nan
/bin/sh: 1: node: not found
gyp: Call to 'node -e "require('nan')"' returned exit status 127. while trying to load binding.gyp
gyp ERR! configure error
gyp ERR! stack Error: gyp failed with exit code: 1
gyp ERR! stack at ChildProcess.onCpExit (/usr/share/node-gyp/lib/configure.js:431:16)
gyp ERR! stack at ChildProcess.EventEmitter.emit (events.js:98:17)
gyp ERR! stack at Process.ChildProcess._handle.onexit (child_process.js:797:12)
gyp ERR! System Linux 4.2.0-34-generic
gyp ERR! command "nodejs" "/usr/bin/node-gyp" "rebuild"
gyp ERR! cwd /usr/local/lib/node_modules/ethereumjs-testrpc/node_modules/ethereumjs-util/node_modules/secp256k1
gyp ERR! node -v v0.10.25
gyp ERR! node-gyp -v v0.10.10
gyp ERR! not ok
npm ERR! weird error 1
npm WARN This failure might be due to the use of legacy binary "node"
npm WARN For further explanations, please read
/usr/share/doc/nodejs/README.Debian

npm ERR! not ok code 0
npm WARN This failure might be due to the use of legacy binary "node"
npm WARN For further explanations, please read
/usr/share/doc/nodejs/README.Debian

npm ERR! error rolling back Error: ENOTEMPTY, rmdir '/usr/local/lib/node_modules/ethereumjs-testrpc/node_modules/ethereumjs-wallet/node_modules/secp256k1/node_modules/nan'
npm ERR! error rolling back [email protected] { [Error: ENOTEMPTY, rmdir '/usr/local/lib/node_modules/ethereumjs-testrpc/node_modules/ethereumjs-wallet/node_modules/secp256k1/node_modules/nan']
npm ERR! error rolling back errno: 53,
npm ERR! error rolling back code: 'ENOTEMPTY',
npm ERR! error rolling back path: '/usr/local/lib/node_modules/ethereumjs-testrpc/node_modules/ethereumjs-wallet/node_modules/secp256k1/node_modules/nan' }
npm ERR! weird error 1
npm ERR! Error: ENOENT, lstat '/usr/local/lib/node_modules/ethereumjs-testrpc/node_modules/ethereumjs-wallet/node_modules/secp256k1/node_modules/elliptic/lib/elliptic/curve/edwards.js'
npm ERR! If you need help, you may report this log at:
npm ERR! http://github.com/isaacs/npm/issues
npm ERR! or email it to:
npm ERR! [email protected]

npm ERR! System Linux 4.2.0-34-generic
npm ERR! command "/usr/bin/nodejs" "/usr/bin/npm" "install" "-g" "ethereumjs-testrpc"
npm ERR! cwd /home/michael
npm ERR! node -v v0.10.25
npm ERR! npm -v 1.3.10
npm ERR! path /usr/local/lib/node_modules/ethereumjs-testrpc/node_modules/ethereumjs-wallet/node_modules/secp256k1/node_modules/elliptic/lib/elliptic/curve/edwards.js
npm ERR! fstream_path /usr/local/lib/node_modules/ethereumjs-testrpc/node_modules/ethereumjs-wallet/node_modules/secp256k1/node_modules/elliptic/lib/elliptic/curve/edwards.js
npm ERR! fstream_type File
npm ERR! fstream_class FileWriter
npm ERR! code ENOENT
npm ERR! errno 34
npm ERR! fstream_stack /usr/lib/nodejs/fstream/lib/writer.js:284:26
npm ERR! fstream_stack Object.oncomplete (fs.js:107:15)
npm ERR! Error: ENOENT, lstat '/usr/local/lib/node_modules/ethereumjs-testrpc/node_modules/ethereumjs-wallet/node_modules/secp256k1/node_modules/bn.js/lib/bn.js'
npm ERR! If you need help, you may report this log at:
npm ERR! http://github.com/isaacs/npm/issues
npm ERR! or email it to:
npm ERR! [email protected]

npm ERR! System Linux 4.2.0-34-generic
npm ERR! command "/usr/bin/nodejs" "/usr/bin/npm" "install" "-g" "ethereumjs-testrpc"
npm ERR! cwd /home/michael
npm ERR! node -v v0.10.25
npm ERR! npm -v 1.3.10
npm ERR! path /usr/local/lib/node_modules/ethereumjs-testrpc/node_modules/ethereumjs-wallet/node_modules/secp256k1/node_modules/bn.js/lib/bn.js
npm ERR! fstream_path /usr/local/lib/node_modules/ethereumjs-testrpc/node_modules/ethereumjs-wallet/node_modules/secp256k1/node_modules/bn.js/lib/bn.js
npm ERR! fstream_type File
npm ERR! fstream_class FileWriter
npm ERR! code ENOENT
npm ERR! errno 34
npm ERR! fstream_stack /usr/lib/nodejs/fstream/lib/writer.js:284:26
npm ERR! fstream_stack Object.oncomplete (fs.js:107:15)
npm ERR! Error: ENOENT, lstat '/usr/local/lib/node_modules/ethereumjs-testrpc/node_modules/ethereumjs-wallet/node_modules/aes-js/~/.grip/style-cache/github2-27099ff875724b3da49fac6911968f783aa96ed08970c77185d963ce6c21af75.css'
npm ERR! If you need help, you may report this log at:
npm ERR! http://github.com/isaacs/npm/issues
npm ERR! or email it to:
npm ERR! [email protected]

npm ERR! System Linux 4.2.0-34-generic
npm ERR! command "/usr/bin/nodejs" "/usr/bin/npm" "install" "-g" "ethereumjs-testrpc"
npm ERR! cwd /home/michael
npm ERR! node -v v0.10.25
npm ERR! npm -v 1.3.10
npm ERR! path /usr/local/lib/node_modules/ethereumjs-testrpc/node_modules/ethereumjs-wallet/node_modules/aes-js//.grip/style-cache/github2-27099ff875724b3da49fac6911968f783aa96ed08970c77185d963ce6c21af75.css
npm ERR! fstream_path /usr/local/lib/node_modules/ethereumjs-testrpc/node_modules/ethereumjs-wallet/node_modules/aes-js/
/.grip/style-cache/github2-27099ff875724b3da49fac6911968f783aa96ed08970c77185d963ce6c21af75.css
npm ERR! fstream_type File
npm ERR! fstream_class FileWriter
npm ERR! code ENOENT
npm ERR! errno 34
npm ERR! fstream_stack /usr/lib/nodejs/fstream/lib/writer.js:284:26
npm ERR! fstream_stack Object.oncomplete (fs.js:107:15)
npm ERR! tar pack Error reading /home/michael/tmp/npm-8718-BCqEhiQ4/1459746703831-0.9252500941511244/package
npm ERR! addLocalDirectory Could not pack "/home/michael/tmp/npm-8718-BCqEhiQ4/1459746703831-0.9252500941511244/package" to "/home/michael/.npm/sha3/1.2.0/package.tgz"
npm http GET https://registry.npmjs.org/pbkdf2

[email protected] preinstall /usr/local/lib/node_modules/ethereumjs-testrpc/node_modules/ethereumjs-wallet/node_modules/scrypt.js/node_modules/scrypt
node node-scrypt-preinstall.js

sh: 1: node: not found
npm WARN This failure might be due to the use of legacy binary "node"
npm WARN For further explanations, please read
/usr/share/doc/nodejs/README.Debian

npm http 304 https://registry.npmjs.org/pbkdf2
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /home/michael/npm-debug.log
npm ERR! not ok code 0

VM Error for generic calls don't propagate

Let A, B be two contracts. A has an instance of B and B has a function that throws (function gothrow(){ throw; }). If this function is called via solidity interface (e.g. b.gothrow()) the error is propagated to the caller (A) and results in an overall throw of the transaction. If the function is called in a generic way (address(b).call(bytes4(sha("gothrow()")));) an error in B is thrown but NOT propagated and the calling function proceeds with its transaction!

I suppose this is not the expected behavior.

An minimal example with truffle/ testrpc and a detailed error description can be found here: https://github.com/mhhf/testrpc_error_propagation

infinite event loop

I get this error with testrpc:

"Error: Error: sender doesn't have enough funds to send tx. The upfront cost is: 19999980000000000 and the senders account only has: 19218460000000000
    at runCall (/usr/lib/node_modules/ethereumjs-testrpc/node_modules/ethereumjs-vm/lib/runTx.js:93:10)
    at /usr/lib/node_modules/ethereumjs-testrpc/node_modules/async/lib/async.js:718:13
    at Immediate.iterate [as _onImmediate] (/usr/lib/node_modules/ethereumjs-testrpc/node_modules/async/lib/async.js:262:13)
    at processImmediate [as _immediateCallback] (timers.js:383:17)

First of all, I don't get this error with geth.
But also after this error, an event which is supposed to be emitted at the very end of the smart contract function is emitted in a infinite loop:

{"name":"ballot-queue-worker","hostname":"local.cocorico.cc-local","pid":6571,"level":30,"balance":"19218460000000000","event":{"logIndex":0,"transactionIndex":0,"transactionHash":"0x966daa499879fe93a1c8c43cdb69dec5843166c47f3088d5af76fbb0c4f845c7","blockHash":"0xd6701b9c7eacb014cb2374012b22297e417ea83ae50844fdc0b75982db06d41c","blockNumber":7,"address":"0x01cf04804565c1f45aec92cf94a2a78e239aa231","type":"mined","event":"Ballot","args":{"voter":"0xb4d0b2358bd40fabd1d260eee60871e4c0c0e176","proposal":"0"}},"msg":"ballot event","time":"2016-04-03T20:33:07.479Z","v":0}
{"name":"ballot-queue-worker","hostname":"local.cocorico.cc-local","pid":6571,"level":30,"balance":"19218460000000000","event":{"logIndex":0,"transactionIndex":0,"transactionHash":"0x966daa499879fe93a1c8c43cdb69dec5843166c47f3088d5af76fbb0c4f845c7","blockHash":"0xd6701b9c7eacb014cb2374012b22297e417ea83ae50844fdc0b75982db06d41c","blockNumber":7,"address":"0x01cf04804565c1f45aec92cf94a2a78e239aa231","type":"mined","event":"Ballot","args":{"voter":"0xb4d0b2358bd40fabd1d260eee60871e4c0c0e176","proposal":"0"}},"msg":"ballot event","time":"2016-04-03T20:33:07.653Z","v":0}
{"name":"ballot-queue-worker","hostname":"local.cocorico.cc-local","pid":6571,"level":30,"balance":"19218460000000000","event":{"logIndex":0,"transactionIndex":0,"transactionHash":"0x966daa499879fe93a1c8c43cdb69dec5843166c47f3088d5af76fbb0c4f845c7","blockHash":"0xd6701b9c7eacb014cb2374012b22297e417ea83ae50844fdc0b75982db06d41c","blockNumber":7,"address":"0x01cf04804565c1f45aec92cf94a2a78e239aa231","type":"mined","event":"Ballot","args":{"voter":"0xb4d0b2358bd40fabd1d260eee60871e4c0c0e176","proposal":"0"}},"msg":"ballot event","time":"2016-04-03T20:33:07.837Z","v":0}
{"name":"ballot-queue-worker","hostname":"local.cocorico.cc-local","pid":6571,"level":30,"balance":"19218460000000000","event":{"logIndex":0,"transactionIndex":0,"transactionHash":"0x966daa499879fe93a1c8c43cdb69dec5843166c47f3088d5af76fbb0c4f845c7","blockHash":"0xd6701b9c7eacb014cb2374012b22297e417ea83ae50844fdc0b75982db06d41c","blockNumber":7,"address":"0x01cf04804565c1f45aec92cf94a2a78e239aa231","type":"mined","event":"Ballot","args":{"voter":"0xb4d0b2358bd40fabd1d260eee60871e4c0c0e176","proposal":"0"}},"msg":"ballot event","time":"2016-04-03T20:33:08.118Z","v":0}
...

Since the transaction cannot occur, it would be surprisingly to have this event emitted even once.
But here it's emitted in a loop.

Any idea what's wrong?

Thank you !

Unable to install testrpc in Windows 2012 R2

Hi,
I am trying to install ethereumjs-testrpc in Windows 2012 R2 64-bit OS machine and getting the following error, any help will be greatly appreciated. The PATH env variable has git, python etc. 2.7.11 is the python version that I got from anaconda.
Thanks,

--------- ERROR ---------------------------
24837 verbose lifecycle [email protected]install: CWD: C:\Users\119078\AppData\Roaming\npm\node_modules\ethereumjs-testrpc\node_modules\secp256k1
24838 silly lifecycle [email protected]
install: Args: [ '/d /s /c', 'npm run rebuild' ]
24839 silly lifecycle [email protected]install: Returned: code: 1 signal: null
24840 info lifecycle [email protected]
install: Failed to exec install script
24841 verbose unlock done using C:\Users\119078\AppData\Roaming\npm-cache_locks\staging-179b54b46d2bd924.lock for C:\Users\119078\AppData\Roaming\npm\node_modules.staging
24842 silly rollbackFailedOptional Starting
24843 silly rollbackFailedOptional Finishing
24844 silly runTopLevelLifecycles Starting
24845 silly runTopLevelLifecycles Finishing
24846 silly install printInstalled
24847 verbose stack Error: [email protected] install: npm run rebuild
24847 verbose stack Exit status 1
24847 verbose stack at EventEmitter. (C:\Users\119078\AppData\Roaming\npm\node_modules\npm\lib\utils\lifecycle.js:239:16)
24847 verbose stack at emitTwo (events.js:100:13)
24847 verbose stack at EventEmitter.emit (events.js:185:7)
24847 verbose stack at ChildProcess. (C:\Users\119078\AppData\Roaming\npm\node_modules\npm\lib\utils\spawn.js:24:14)
24847 verbose stack at emitTwo (events.js:100:13)
24847 verbose stack at ChildProcess.emit (events.js:185:7)
24847 verbose stack at maybeClose (internal/child_process.js:850:16)
24847 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:215:5)
24848 verbose pkgid [email protected]
24849 verbose cwd C:\Users\119078
24850 error Windows_NT 6.3.9600

wrong return value for web3.eth.getAccounts

Here is my code:

var web3 = new Web3();
web3.setProvider(TestRPC.provider());

web3.eth.getAccounts((err, acc) => {
    console.log(acc);
});

Here is what I get:

[ '0x871f46e97b6419ce887073a9ccb99b964d438bdd',
  '0x728ef897367608fd7ce8b9dbc66eb840d9cbc63c',
  '0x4f7aef45c0a6c311e15a16a766ac95673978886f',
  '0x92dce6468f51c35266c70b176c6771ac648eb305',
  '0xaf4381f1861c78d399dcdc3c0f36d6fff22086af',
  '0x11d9e50c259ffe93e9fd6f95967599387c4c1ee1',
  '0x55ef102990a7c9fe26d9756da1de372e91e3aaf8',
  '0xe06e79a7c975d1d94ad32ada38855ca701d9dd8a',
  '0x99a17f3c5e4ce7a684d1aa4a805b720ccde276b9',
  '0x513fd961555c0687c81a8465a9ea0a855a408457' ]

Here is what I have in the testrpc logs:

EthereumJS TestRPC v2.0.0

Available Accounts
==================
(0) 0x4e4134b36b3e7f8fca80a2fbfe6d54549e5f0f93

Private Keys
==================
(0) 81aa38abb2b5d5aa3bbc0c852423cca1118dc90ef1a83c18fc8010fb276ec378

But if I use the classic HTTP Provider, the account list is correct:

var web3 = new Web3();
web3.setProvider(new web3.providers.HttpProvider("http://127.0.0.1:8545"));

web3.eth.getAccounts((err, acc) => {
    console.log(acc);
});
[ '0x4e4134b36b3e7f8fca80a2fbfe6d54549e5f0f93' ]

But then nothing gets mined...
Any idea what's wrong?

Thanks,

persistent data

Hello,

is there a way to make the testrpc data persistent?
I'm especially interested in being able to reuse my existing contracts after restarting testrpc.

Thank you,

Apparently Wrong Event implementation

Following are the issues I see with Test RPC. Please correct me if I am wrong.

Currently when

  1. Event is watched it does not populate all the past events based on filter option.
  2. calling get does not fire watch
  3. calling get clears the event logs. 2nd call does not return anything.

testrpc crashes at launch with "Error: Cannot find module 'sha3'" on Linux

The only line in the error trace that doesn't reference node internals is:
at Object.<anonymous> (/usr/lib/node_modules/ethereumjs-testrpc/node_modules/keccakjs/index.js:1:80)
This is after having only used npm install -g ethererumjs-testrpc
I tried gulp as well on the same machine and it's working fine, which looks to isolate the issue to testrpc.

eth_call incorrect RPC return value

In [email protected] when using the call method (in this case using ether-pudding) the following error occurs:

Debug: internal, implementation, error
    BigNumber Error: Uncaught error: new BigNumber() not a base 16 number:
    at raise (/Users/nunofmn1/app/node_modules/bignumber.js/bignumber.js:1177:25)
    at /Users/nunofmn1/app/node_modules/bignumber.js/bignumber.js:1165:33
    at new BigNumber (/Users/nunofmn1/app/node_modules/bignumber.js/bignumber.js:212:28)
    at formatOutputString [as _outputFormatter] (/Users/nunofmn1/app/node_modules/web3/lib/solidity/formatters.js:217:19)
    at /Users/nunofmn1/app/node_modules/web3/lib/solidity/type.js:237:25
    at SolidityType.decode (/Users/nunofmn1/app/node_modules/web3/lib/solidity/type.js:238:11)
    at /Users/nunofmn1/appnode_modules/web3/lib/solidity/coder.js:219:29
    at Array.map (native)
    at SolidityCoder.decodeParams (/Users/nunofmn1/app/node_modules/web3/lib/solidity/coder.js:218:26)
    at SolidityFunction.unpackOutput (/Users/nunofmn1/app/node_modules/web3/lib/web3/function.js:90:24)
    at Object.callback (/Users/nunofmn1/app/node_modules/web3/lib/web3/function.js:118:30)
    at /Users/nunofmn1/Documents/app/node_modules/web3/lib/web3/method.js:142:25
    at /Users/nunofmn1/Documents/app/node_modules/web3/lib/web3/requestmanager.js:89:9
    at request.onreadystatechange (/Users/nunofmn1/app/node_modules/web3/lib/web3/httpprovider.js:114:13)
    at dispatchEvent (/Users/nunofmn1/app/node_modules/xmlhttprequest/lib/XMLHttpRequest.js:591:25)
    at setState (/Users/nunofmn1/app/node_modules/xmlhttprequest/lib/XMLHttpRequest.js:610:14)

With further debugging is possible to verify that the problem is in the formatOutputString function, and is related with the JSON returned by the testrpcclient:

{
  id: 2,
  jsonrpc: "2.0",
  result: "0x"
}

Which seems related with web3/web3.js#231.

Feature request: Mine a chosen amount blocks per transaction.

Some dapps watch for a certain amount of blocks before accepting a transaction as finalised.

Would be useful to have a feature/setting to allow testrpc to mine a certain amount of blocks for each tx. And set it upon running it. Something like:

testrpc --blockspertx 10

callback is not a function

getting an error from testrpc 1.2.1

╭─kumavis@xyzs-MacBook-Pro  ~/dev/sxsw-demo   
╰─$ curl -d '{"jsonrpc":"2.0","method":"eth_getBalance","params": ["0xa28d9923203601efb12fe777a9ab934d489e45c5"], "id":1}' -X POST http://139.196.191.70:8545 | jsonogram
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  1296    0  1188  100   108   2144    194 --:--:-- --:--:-- --:--:--  2144
├─ id: 1
├─ jsonrpc: 2.0
└─ error
   ├─ message: TypeError: callback is not a function
    at /usr/lib/node_modules/ethereumjs-testrpc/lib/blockchain.js:166:7
    at /usr/lib/node_modules/ethereumjs-testrpc/node_modules/ethereumjs-vm/lib/stateManager.js:63:5
    at Cache.getOrLoad (/usr/lib/node_modules/ethereumjs-testrpc/node_modules/ethereumjs-vm/lib/cache.js:75:5)
    at StateManager.proto.getAccount (/usr/lib/node_modules/ethereumjs-testrpc/node_modules/ethereumjs-vm/lib/stateManager.js:37:14)
    at StateManager.proto.getAccountBalance (/usr/lib/node_modules/ethereumjs-testrpc/node_modules/ethereumjs-vm/lib/stateManager.js:61:8)
    at Blockchain.getBalance (/usr/lib/node_modules/ethereumjs-testrpc/lib/blockchain.js:159:24)
    at Manager.eth_getBalance (/usr/lib/node_modules/ethereumjs-testrpc/lib/manager.js:96:19)
    at Manager.handleRequest (/usr/lib/node_modules/ethereumjs-testrpc/lib/manager.js:59:10)
    at next (/usr/lib/node_modules/ethereumjs-testrpc/node_modules/web3-provider-engine/index.js:93:18)
    at VmSubprovider.handleRequest (/usr/lib/node_modules/ethereumjs-testrpc/node_modules/web3-provider-engine/subproviders/vm.js:42:12)
   └─ code: -32000

Add a block lag feature

Sometimes you want to test your app under real blockchain-type conditions, where transactions succeed, but the change isn't seen for up to 15 seconds.

Developers should have an easy way to experience that lag in development, so they can build their UI's around it.

It would be really great if testrpc provided a flag for lagging the block addition, to help this process.

2.0.1 broken

See the following tracebacks. Probably comes from recent merge from eth-lightwallet. Downgrading to 2.0.0 fixes the issue.

Austins-MBP:MountainOfMoney Gross$ testrpc
/usr/local/lib/node_modules/ethereumjs-testrpc/node_modules/eth-lightwallet/node_modules/tweetnacl/nacl-fast.js:2152
       throw new TypeError('unexpected type ' + t + ', use Uint8Array');
             ^
TypeError: unexpected type [object Object], use Uint8Array
    at checkArrayTypes (/usr/local/lib/node_modules/ethereumjs-testrpc/node_modules/eth-lightwallet/node_modules/tweetnacl/nacl-fast.js:2152:14)
    at Object.nacl.secretbox (/usr/local/lib/node_modules/ethereumjs-testrpc/node_modules/eth-lightwallet/node_modules/tweetnacl/nacl-fast.js:2201:3)
    at Function.KeyStore._encryptString (/usr/local/lib/node_modules/ethereumjs-testrpc/node_modules/eth-lightwallet/lib/keystore.js:113:21)
    at new KeyStore (/usr/local/lib/node_modules/ethereumjs-testrpc/node_modules/eth-lightwallet/lib/keystore.js:91:29)
    at new Blockchain (/usr/local/lib/node_modules/ethereumjs-testrpc/lib/blockchain.js:45:19)
    at new Manager (/usr/local/lib/node_modules/ethereumjs-testrpc/lib/manager.js:14:21)
    at Object.Server.provider (/usr/local/lib/node_modules/ethereumjs-testrpc/lib/server.js:153:19)
    at Object.Server.server (/usr/local/lib/node_modules/ethereumjs-testrpc/lib/server.js:23:25)
    at Object.TestRPC.server (/usr/local/lib/node_modules/ethereumjs-testrpc/index.js:23:26)
    at Object.<anonymous> (/usr/local/lib/node_modules/ethereumjs-testrpc/bin/testrpc:42:22)
Austins-MBP:ethereumjs-testrpc Gross$ npm test

> [email protected] test /usr/local/lib/node_modules/ethereumjs-testrpc
> mocha ./test/**/*.js

/usr/local/lib/node_modules/ethereumjs-testrpc/node_modules/eth-lightwallet/node_modules/tweetnacl/nacl-fast.js:2152
       throw new TypeError('unexpected type ' + t + ', use Uint8Array');
             ^
TypeError: unexpected type [object Object], use Uint8Array
    at checkArrayTypes (/usr/local/lib/node_modules/ethereumjs-testrpc/node_modules/eth-lightwallet/node_modules/tweetnacl/nacl-fast.js:2152:14)
    at Object.nacl.secretbox (/usr/local/lib/node_modules/ethereumjs-testrpc/node_modules/eth-lightwallet/node_modules/tweetnacl/nacl-fast.js:2201:3)
    at Function.KeyStore._encryptString (/usr/local/lib/node_modules/ethereumjs-testrpc/node_modules/eth-lightwallet/lib/keystore.js:113:21)
    at new KeyStore (/usr/local/lib/node_modules/ethereumjs-testrpc/node_modules/eth-lightwallet/lib/keystore.js:91:29)
    at new Blockchain (/usr/local/lib/node_modules/ethereumjs-testrpc/lib/blockchain.js:45:19)
    at new Manager (/usr/local/lib/node_modules/ethereumjs-testrpc/lib/manager.js:14:21)
    at Object.Server.provider (/usr/local/lib/node_modules/ethereumjs-testrpc/lib/server.js:153:19)
    at Object.TestRPC.provider (/usr/local/lib/node_modules/ethereumjs-testrpc/index.js:27:28)
    at Suite.<anonymous> (/usr/local/lib/node_modules/ethereumjs-testrpc/test/requests.js:507:28)
    at context.describe.context.context (/usr/local/lib/node_modules/mocha/lib/interfaces/bdd.js:47:10)
    at Object.<anonymous> (/usr/local/lib/node_modules/ethereumjs-testrpc/test/requests.js:505:1)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Module.require (module.js:365:17)
    at require (module.js:384:17)
    at /usr/local/lib/node_modules/mocha/lib/mocha.js:219:27
    at Array.forEach (native)
    at Mocha.loadFiles (/usr/local/lib/node_modules/mocha/lib/mocha.js:216:14)
    at Mocha.run (/usr/local/lib/node_modules/mocha/lib/mocha.js:468:10)
    at Object.<anonymous> (/usr/local/lib/node_modules/mocha/bin/_mocha:403:18)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Function.Module.runMain (module.js:501:10)
    at startup (node.js:129:16)
    at node.js:814:3
npm ERR! Test failed.  See above for more details.

slow contract setup

have a contract deployment setup which takes about 20s with ethereumjs-testrpc but <1s with eth-testrpc
it basically chains 6 contracts by doing

Foo.new(...).then(function(newFoo) { return Bar.new(newFoo.address).then(function(newBar) { ...

I'm guessing there's one block between each deployment, but not sure why it's so much slower with ethereumjs-testrpc
wondering if I'm using promises incorrectly and there's a way to deploy all contracts sequentially in one block

Problem with the installation of the latest build

I have an issue when I try to install the latest build on windows using the latest version of node.js v5.6.0
it failed t the [email protected] install script 'npm run rebuild'
please find attached the log
I use the following version of node.js and rpm
node v5.6.0
npm v3.7.3

I am very new here so my error might be quite simple to resolve
thanks

npm-debug.txt

TypeError: unexpected type [object Object], use Uint8Array while running

I've upgraded to the latest version on OS X but it fails when I run testrpc:

       throw new TypeError('unexpected type ' + t + ', use Uint8Array');
             ^
TypeError: unexpected type [object Object], use Uint8Array
    at checkArrayTypes (/usr/local/lib/node_modules/ethereumjs-testrpc/node_modules/eth-lightwallet/node_modules/tweetnacl/nacl-fast.js:2152:14)
    at Object.nacl.secretbox (/usr/local/lib/node_modules/ethereumjs-testrpc/node_modules/eth-lightwallet/node_modules/tweetnacl/nacl-fast.js:2201:3)
    at Function.KeyStore._encryptString (/usr/local/lib/node_modules/ethereumjs-testrpc/node_modules/eth-lightwallet/lib/keystore.js:113:21)
    at new KeyStore (/usr/local/lib/node_modules/ethereumjs-testrpc/node_modules/eth-lightwallet/lib/keystore.js:91:29)
    at new Blockchain (/usr/local/lib/node_modules/ethereumjs-testrpc/lib/blockchain.js:45:19)
    at new Manager (/usr/local/lib/node_modules/ethereumjs-testrpc/lib/manager.js:14:21)
    at Object.Server.provider (/usr/local/lib/node_modules/ethereumjs-testrpc/lib/server.js:153:19)
    at Object.Server.server (/usr/local/lib/node_modules/ethereumjs-testrpc/lib/server.js:23:25)
    at Object.TestRPC.server (/usr/local/lib/node_modules/ethereumjs-testrpc/index.js:23:26)
    at Object.<anonymous> (/usr/local/lib/node_modules/ethereumjs-testrpc/bin/testrpc:42:22)

I have [email protected] and in install logs I see that it's using [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected]). The latest tweetnacl version is 0.14.3 but probably the old version is cached somewhere in dependencies.

I'm not deep in nodejs so I don't understand how to fix it :(

Valid estimateGas call crashes testrpc

I've been trying to use the newly released version of testrpc, but the behaviour of estimateGas has changed with the release compared to my original pull request. When an address without enough balance to fund the transaction tries to estimate the gas, testrpc crashes:

        var result = ethUtil.addHexPrefix(results.gasUsed.toString('hex'))
                                                         ^

TypeError: Cannot read property 'toString' of undefined
    at <snip>/testrpc/node_modules/web3-provider-engine/subproviders/vm.js:56:58

The value of results is:

{ error: [Error: sender doesn't have enough funds to send tx. The upfront cost is: 3141592 and the senders account only has: 0] }

In geth (which I am using as the arbiter of 'valid'), the call succeeds. It seems this is due to offloading the handling of estimateGas and ethCall into web3-provider-engine.

Further digging while writing this issue appears to suggest you are probably already aware of this (I presume you're the tim in ethereumjs/ethereumjs-monorepo#41, which is certainly related) but I've opened this anyway in case you're not aware of the crashing side of it.

initial accounts balance not respected?

passing an accounts param to the options passed in to testrpc provider does not seem to work
The doc mentions passing a 2d array but looking at the code it actually accept an object {balance:, secretKey:}
Either way the resulting balance is way off : 1.208925819614629174706176e+24 instead of 100 ether

Any idea?

Events don't work

I get the following error in a web3 watch() callback for an solidity event, where I'm listening on a specific event. The code works on geth.

[Error: Method not found]

I read in other in other simulators that events aren't supported but it doesn't say so explicitly in the README here.

If events aren't supported, what's the alternative to getting transaction logs? It appears that web3's default log gathering capability is via events.

Stack underflow while sending a transaction

I got the following error while sending a transaction:

Error: VM Exception while executing transaction: stack underflow

The same code succeeded with the Python testrpc. I don't have a good way for anyone to reproduce this issue yet.

Add flag to run in unauthenticated mode

Some users developing for clients (like MetaMask) that do the transaction signing have run into the confusing situation that they can either ask MetaMask to sign a transaction, OR just submit the transaction, which succeeds on TestRPC, since it runs in authenticated mode.

It would be nice to disable the authenticated accounts, so devs can enforce that they're correctly signing code.

INVALID_PARAMS eth_sendTransaction

VERSION: latest 1.0

was using truffle deploy; one get this error;

with normal geth at latest its fine to deploy

truffle deploy --verbose-rpc
Using environment development.
   > {
   >   "jsonrpc": "2.0",
   >   "method": "eth_accounts",
   >   "params": [],
   >   "id": 1
   > }
 <   {
 <     "id": 1,
 <     "jsonrpc": "2.0",
 <     "result": [
 <       "0x00691bf743f75a397cee603b6a91d22531d8a9eb",
 <       "0x006a7cdbcdd1e98a534ae5c5228766e10cc1afec"
 <     ]
 <   }
Checking sources...
Compiling ConvertLib.sol...
Compiling MetaCoin.sol...
Collecting dependencies...
   > {
   >   "jsonrpc": "2.0",
   >   "method": "eth_sendTransaction",
   >   "params": [
   >     {
   >       "from": "0x00691bf743f75a397cee603b6a91d22531d8a9eb",
   >       "gas": "0x2fefd8",
   >       "gasPrice": "0x174876e800",
   >       "data": "606060405260358060106000396000f365020191a6b35f50606060405260e060020a600035046396e4ee3d81146024575b6007565b602435600435026060908152602090f3"
   >     }
   >   ],
   >   "id": 2
   > }
 <   {
 <     "error": {
 <       "code": -32602,
 <       "data": null,
 <       "message": "INVALID_PARAMS: Invalid method parameters (invalid name and/or type) recognised"
 <     },
 <     "id": 2,
 <     "jsonrpc": "2.0"
 <   }
Error deploying MetaCoin:

INVALID_PARAMS: Invalid method parameters (invalid name and/or type) recognised

testrpc 2.0.0 - cannot find module 'memdown'

Trying to get testrpc (2.0.0) working on an ubuntu virtualbox, and getting this error when I run it:

mowliv@u4:~$ testrpc
module.js:341
    throw err;
    ^

Error: Cannot find module 'memdown'
    at Function.Module._resolveFilename (module.js:339:15)
    at Function.Module._load (module.js:290:25)
    at Module.require (module.js:367:17)
    at require (internal/module.js:16:19)
    at Object.<anonymous> (/usr/lib/node_modules/ethereumjs-testrpc/node_modules/merkle-patricia-tree/baseTrie.js:3:17)
    at Module._compile (module.js:413:34)
    at Object.Module._extensions..js (module.js:422:10)
    at Module.load (module.js:357:32)
    at Function.Module._load (module.js:314:12)
    at Module.require (module.js:367:17)

Have tried npm update -g and sudo npm install -g memdown but those didn't help. Maybe I'm being bitten by a major new (2.0.0) release?

nonce errors on any exception

If there's any exception such as insufficient gas, subsequent transactions fail with a bad nonce, even though I properly catch the exception in the code.

Error: the tx doesn't have the correct nonce. account has nonce of: 8 tx has nonce of: 7

Below is a patch to ethereum-pudding's test code to show the problem:

This is not reproducible using geth. Simulation != real world issue.

diff --git a/test/contracts.js b/test/contracts.js
index 76e430a..9e2d0e9 100644
--- a/test/contracts.js
+++ b/test/contracts.js
@@ -18,6 +18,7 @@ var binary = compiled.bytecode;
 // Setup
 var web3 = new Web3();
 web3.setProvider(TestRPC.provider());
+//web3.setProvider(new web3.providers.HttpProvider("http://localhost:8110"));
 Pudding.setWeb3(web3);

 var tests = function(contract_instantiator) {
@@ -109,6 +110,7 @@ var tests = function(contract_instantiator) {
       // BigNumber passed in a transaction.
       return example.setValue(new Pudding.BigNumber(25));
     }).then(function(tx) {
+      console.log(tx);
       return example.value.call();
     }).then(function(value) {
       assert.equal(value.valueOf(), 25, "Ending value should be twenty-five");
@@ -118,10 +120,31 @@ var tests = function(contract_instantiator) {
       assert.equal(parrot_value.valueOf(), 865, "Parrotted value should equal 865")
     }).then(done).catch(done);
   });
+
+  it("should throw when running out of gas", function(done) {
+    var example;
+    Example.new().then(function(instance) {
+      example = instance;
+      return example.value.call();
+    }).then(function(value) {
+      assert.equal(value.valueOf(), 1, "Starting value should be 1");
+      return example.setValue(5, {gas: 20000});
+    }).then(function(tx) {
+      return example.value.call();
+    }).then(function(value) {
+      assert.equal(value.valueOf(), 5, "Ending value should be five");
+    }).then(done).catch(function(err) {
+      console.log("properly caught out of gas error");
+      console.log(err);
+      done();
+    });
+  });
 };

 describe("Contract abstractions", function() {

+  this.timeout(40000);  // enough for stock real node e.g. geth
+
   describe("when using .whisk()", function() {
     tests(function(callback) {
       callback(null, Pudding.whisk({

eth_getFilterLogs returns empty array after eth_getTransactionReceipt return logs

Hi.
When I'm running big test suits it reproduced 90% of the time. Here is the testrpc log:

eth_newFilter
eth_sendTransaction

  Gas usage: 102749
  Block Number: 0x09

eth_getTransactionByHash
eth_getTransactionReceipt
eth_getFilterLogs

Every time there is an event caused by transaction, most of the time eth_getFilterLogs produces nothing, while eth_getTransactionReceipt before it clearly reports that logs are there.
If I run this test without other tests, it always works.

If this is not a bug, than what am I really interested in, is how to know that logs from transaction is already there, so I can check there was or there wasn't any logs?

If you think that there might be a race condition, than there is probably not, cause I'm specifically calling eth_getFilterLogs after I'm sure there is logs in receipt.

Manipulate timestamp

I need to test some contract calls against testrpc that have a time constraint (after "x" hours can see the posted value) so I would like to change the timestamp in order to test if I get the expected result.

Thanks

mining disabled

Hi,

I did not find any way to enable mining and mining is disabled by default:

$ curl -X POST --data '{"jsonrpc":"2.0","method":"eth_hashrate","params":[],"id":71}'  http://127.0.0.1:8545
{"id":71,"jsonrpc":"2.0","result":"0x0"}

How can one enable mining ?

Regards,

Wrong Blockhash in transaction receipt

I created a transaction by calling a function in a contract. The contract function writes an event. All these were done from web3 against TestRPC running at localhost. After the transaction is added to network, I call the following :
web3.eth.getTransactionReceipt(tx, function (err,objTx) {
if (objTx != null) {
console.log(objTx.log);
}
})
It returns the receipt with the event data in the log. But the blockhas in the transation receipt and the blockhash inside the log is different. Should be same.

blockHash: "0x4a9cfaee8eb83857eac751ec87b529a1557fdbaf7e665cf19267da1593ef9daa"
blockNumber: 60
contractAddress: null
cumulativeGasUsed: 182322
gasUsed: 182322
logs: Array[1]
0: Object
address: "0x4c5a0ef079f1b71227e3281f7e735e9261523e26"
blockHash: "0x9af250903bb2431be098e4bd77c1146730a8882d1801f298385a360f0c4c8d24"
blockNumber: 60
data: "0x000000000000000000000000083ce37b3f31d51821a3996ae4d4cad87635774200000000000000000000000000000000000000000000000000000000000001bc0000000000000000000000000000000000000000000000000000000000000036"
logIndex: 0
topics: Array[1]
transactionHash: "0x6b1790ade62f1213ccef43395dab3c6c897e6a73f71b2ecd71f9f8906f62b472"
transactionIndex: 0
type: "mined"
proto: Object
length: 1
proto: Array[0]
transactionHash: "0x6b1790ade62f1213ccef43395dab3c6c897e6a73f71b2ecd71f9f8906f62b472"
transactionIndex: 0

'from' is required for estimateGas call

Unlike geth, the 'from' field is required when making an estimateGas call. Without it, the following is returned:

"AssertionError: false == true
    at Object.exports.pubToAddress.exports.publicToAddress (/Users/alex/Projects/Colony/testrpc/node_modules/ethereumjs-util/index.js:301:3)
    at FakeTransaction.Transaction.getSenderAddress (/Users/alex/Projects/Colony/testrpc/node_modules/ethereumjs-tx/index.js:147:24)
    at populateCache (/Users/alex/Projects/Colony/testrpc/node_modules/ethereumjs-vm/lib/runTx.js:73:20)
    at /Users/alex/Projects/Colony/testrpc/node_modules/async/lib/async.js:718:13
    at iterate (/Users/alex/Projects/Colony/testrpc/node_modules/async/lib/async.js:262:13)
    at async.forEachOfSeries.async.eachOfSeries (/Users/alex/Projects/Colony/testrpc/node_modules/async/lib/async.js:281:9)
    at _parallel (/Users/alex/Projects/Colony/testrpc/node_modules/async/lib/async.js:717:9)
    at Object.async.series (/Users/alex/Projects/Colony/testrpc/node_modules/async/lib/async.js:739:9)
    at VM.module.exports [as runTx] (/Users/alex/Projects/Colony/testrpc/node_modules/ethereumjs-vm/lib/runTx.js:40:9)
    at VmSubprovider.runVm (/Users/alex/Projects/Colony/testrpc/node_modules/web3-provider-engine/subproviders/vm.js:111:6)

The workaround for eth_call can be seen at https://github.com/ethereumjs/testrpc/blob/master/lib/blockchain.js#L325-L326 , but as estimateGas is dealt with by web3-provider-engine, I don't think a similar fix can be applied here.

Run testrpc on 0.0.0.0 rather than localhost

Is there a way to run testrpc on 0.0.0.0 rather than localhost? I'm running the testrpc server on a docker container and would like to link it to another docker container. Thanks!

Intermittent failure when running truffle tests

I have two very similar tests for a pair of contracts that, when run using truffle, one of them intermittently fails. I have a MWE at https://github.com/area/testrpc_bug_reproduce

The tests 'never' fail (I looped them for an hour with no failures) when using the python based eth-testrpc, which is why I'm reporting this as a bug in testrpc rather than truffle.

Everything I've seen points to there being some sort of race condition, unfortunately.

  • Intermittent
  • More attempts are required to fail on lower-powered machines where the tests take longer.

I have put the output when using truffle test --verbose-rpc at https://gist.github.com/area/82654cad5db14932c48f for a passing pair of tests and then a run where the intermittent test fails.

EDIT: I've realised that I have the order of the tests reversed in that gist. https://gist.github.com/area/e67899bc16f61468231f has the output from the tests in the same order as they appear in the repository.

--debug doesn't work

If I try and run with the --debug flag, then on deployment (with truffle) I get

     Error deploying Contract:

     Error: VM Exception while executing transaction: ReferenceError: logger is not defined
         at /Users/user/.node/lib/node_modules/ethereumjs-testrpc/lib/blockchain.js:506:18

Error: the tx doesn't have the correct nonce. account has nonce of: 2 tx has nonce of: 1

I'm doing some experiments with lists and ran in to an error with js testrpc that does not happen when using geth.
Using the following contract:

contract haslist {
    address[] public List;
    uint256 public size = 0;
    function addElement(address element) {
        List[size]=element;
        size++;
    }
}

I call the function addElement through rpc with:

> listhandle = haslistContract.at("0x4875ec1a939f7518e8ec707e261806c4fd233b3a");
> web3.eth.defaultAccount = web3.eth.accounts[0];
'0x269c8f830dbb1fbf59d9a354b7f9f353ae4c3f58'
> listhandle.addElement('0x4875ec1a939f7518e8ec707e261806c4fd233b3a');
Error: VM Exception while executing transaction: invalid JUMP
    at Object.module.exports.InvalidResponse (/home/martin/node_modules/web3/lib/web3/errors.js:35:16)
    at RequestManager.send (/home/martin/node_modules/web3/lib/web3/requestmanager.js:61:22)
    at Eth.send [as sendTransaction] (/home/martin/node_modules/web3/lib/web3/method.js:145:58)
    at SolidityFunction.sendTransaction (/home/martin/node_modules/web3/lib/web3/function.js:133:26)
    at SolidityFunction.execute (/home/martin/node_modules/web3/lib/web3/function.js:219:37)
    at repl:1:12
    at REPLServer.defaultEval (repl.js:164:27)
    at bound (domain.js:250:14)
    at REPLServer.runBound [as eval] (domain.js:263:12)
    at REPLServer.<anonymous> (repl.js:393:12)
> listhandle.addElement('0x4875ec1a939f7518e8ec707e261806c4fd233b3a');
Error: the tx doesn't have the correct nonce. account has nonce of: 3 tx has nonce of: 2
    at Object.module.exports.InvalidResponse (/home/martin/node_modules/web3/lib/web3/errors.js:35:16)
    at RequestManager.send (/home/martin/node_modules/web3/lib/web3/requestmanager.js:61:22)
    at Eth.send [as sendTransaction] (/home/martin/node_modules/web3/lib/web3/method.js:145:58)
    at SolidityFunction.sendTransaction (/home/martin/node_modules/web3/lib/web3/function.js:133:26)
    at SolidityFunction.execute (/home/martin/node_modules/web3/lib/web3/function.js:219:37)
    at repl:1:12
    at REPLServer.defaultEval (repl.js:164:27)
    at bound (domain.js:250:14)
    at REPLServer.runBound [as eval] (domain.js:263:12)
    at REPLServer.<anonymous> (repl.js:393:12)

Behaviour on throw differs from geth

testrpc and geth behave in very different ways when encountering a throw in a contract, which is making writing tests that check invalid calls to contracts are correctly prevented in truffle difficult.

testrpc throws an error:

[Error: Error: VM Exception while executing transaction: invalid JUMP
    at /Users/user/.node/lib/node_modules/ethereumjs-testrpc/lib/blockchain.js:471:18
    at Object.async.eachSeries (/Users/user/.node/lib/node_modules/ethereumjs-testrpc/node_modules/async-eventemitter/node_modules/async/lib/async.js:130:20)
    at VM.AsyncEventEmitter.emit (/Users/user/.node/lib/node_modules/ethereumjs-testrpc/node_modules/async-eventemitter/lib/AsyncEventEmitter.js:42:9)
    at afterBlock (/Users/user/.node/lib/node_modules/ethereumjs-testrpc/node_modules/ethereumjs-vm/lib/runBlock.js:55:10)
    at /Users/user/.node/lib/node_modules/ethereumjs-testrpc/node_modules/ethereumjs-vm/lib/runBlock.js:179:9
    at /Users/user/.node/lib/node_modules/ethereumjs-testrpc/node_modules/ethereumjs-vm/lib/cache.js:137:7
    at /Users/user/.node/lib/node_modules/ethereumjs-testrpc/node_modules/async/lib/async.js:52:16
    at iterate (/Users/user/.node/lib/node_modules/ethereumjs-testrpc/node_modules/async/lib/async.js:260:24)
    at Object.async.forEachOfSeries.async.eachOfSeries (/Users/user/.node/lib/node_modules/ethereumjs-testrpc/node_modules/async/lib/async.js:281:9)
    at Object.async.forEachSeries.async.eachSeries (/Users/user/.node/lib/node_modules/ethereumjs-testrpc/node_modules/async/lib/async.js:214:22)]

throw is indeed meant to create an invalid jump error, but it should still create a transaction without erroring as geth does. From https://www.ethereum.org/token :

'throw' will cancel all contract execution, revert any changes that transaction could have made and the sender will lose all ether he sent on gas.

In order to get tests to pass in both testrpc and geth, currently a special catch in the promise chain is required deal with the possibility the tests might be running on testrpc. I does seem to be true that testrpc correctly spends all the gas bought by the key making the transaction - it's just throwing the VM error all the way up.

I can't figure out what the lines https://github.com/ethereumjs/testrpc/blob/master/lib/blockchain.js#L469-L473 are meant to be doing. I don't think an error should be thrown here, ultimately - a VM exception still produces a 'valid' transaction, right? Removing these lines gives me the behaviour I'd expect to see, I think, but there are no tests for 'invalid' transactions, so I'm certainly hesitant to do anything about it without properly understanding what's going on. I feel like I'm way out of my depth here...(!)

calls() don't work if not from a node address

For a call(), the "from" address is optional.

But testrpc fails when using another "from" address. Notably when using hookedweb3provider in a lightwallet.

/usr/local/lib/node_modules/ethereumjs-testrpc/lib/blockchain.js:469
  var privateKey = new Buffer(this.accounts[from].secretKey, 'hex');
                                                 ^
TypeError: Cannot read property 'secretKey' of undefined
    at Blockchain.processCall (/usr/local/lib/node_modules/ethereumjs-testrpc/lib/blockchain.js:469:50)
    at Blockchain.processNextAction (/usr/local/lib/node_modules/ethereumjs-testrpc/lib/blockchain.js:356:10)
    at Blockchain.queueAction (/usr/local/lib/node_modules/ethereumjs-testrpc/lib/blockchain.js:322:8)
    at Blockchain.queueCall (/usr/local/lib/node_modules/ethereumjs-testrpc/lib/blockchain.js:255:8)
    at Manager.eth_call (/usr/local/lib/node_modules/ethereumjs-testrpc/lib/manager.js:83:19)
    at wrapped (/usr/local/lib/node_modules/ethereumjs-testrpc/lib/server.js:39:8)
    at eval (eval at giveArity (/usr/local/lib/node_modules/ethereumjs-testrpc/lib/server.js:21:41), <anonymous>:1:29)
    at Method.execute (/usr/local/lib/node_modules/ethereumjs-testrpc/node_modules/jayson/lib/method.js:129:22)
    at /usr/local/lib/node_modules/ethereumjs-testrpc/node_modules/jayson/lib/server.js:290:12
    at maybeParse (/usr/local/lib/node_modules/ethereumjs-testrpc/node_modules/jayson/lib/server.js:407:5)
    at Server.call (/usr/local/lib/node_modules/ethereumjs-testrpc/node_modules/jayson/lib/server.js:235:3)

calls should be able to take an arbitrary address to use as tx.origin.

Add `net_version` method.

Over at Metamask, we're adding a feature to provide blockchain-explorer links for transactions.

To do this intelligently, we have to check what blockchain we're on.

The net_version method lets a web3 client ask what blockchain version is being used. Main net returns 1, the morden test-net returns 2, and testrpc throws an error:

├─ id: 1
├─ jsonrpc: 2.0
└─ error
   ├─ message: Error: RPC method net_version not supported.

I think it would be cool to support this method, and just return something, like maybe a large random number, or maybe the string testrpc. Something useful.

Thoughts?

TypeError: Cannot read property 'get' of undefined

I've been getting a lot of this error lately:

eth_getBalance
/usr/local/lib/node_modules/ethereumjs-testrpc/node_modules/merkle-patricia-tree/baseTrie.js:117
    db.get(key, {
      ^

TypeError: Cannot read property 'get' of undefined
    at dbGet (/usr/local/lib/node_modules/ethereumjs-testrpc/node_modules/merkle-patricia-tree/baseTrie.js:117:7)
    at /usr/local/lib/node_modules/ethereumjs-testrpc/node_modules/merkle-patricia-tree/util.js:64:5
    at /usr/local/lib/node_modules/ethereumjs-testrpc/node_modules/async/lib/async.js:181:20
    at iterate (/usr/local/lib/node_modules/ethereumjs-testrpc/node_modules/async/lib/async.js:262:13)
    at /usr/local/lib/node_modules/ethereumjs-testrpc/node_modules/async/lib/async.js:274:29
    at /usr/local/lib/node_modules/ethereumjs-testrpc/node_modules/async/lib/async.js:44:16
    at /usr/local/lib/node_modules/ethereumjs-testrpc/node_modules/merkle-patricia-tree/util.js:69:7
    at /usr/local/lib/node_modules/ethereumjs-testrpc/node_modules/merkle-patricia-tree/baseTrie.js:122:9
    at dispatchError (/usr/local/lib/node_modules/ethereumjs-testrpc/node_modules/merkle-patricia-tree/node_modules/levelup/lib/util.js:64:35)
    at /usr/local/lib/node_modules/ethereumjs-testrpc/node_modules/merkle-patricia-tree/node_modules/levelup/lib/levelup.js:222:14

This causes testrpc to crash.
I don't know exactly what causes it, because if I restart testrpc and truffle deploy and build my project again it doesn't necessarily happen again. I think it happens when I do a lot of calls at the same time
Seems non-deterministic.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.