Error with `from` in tests
See original GitHub issue- I’ve asked for help in the Truffle Gitter before filing this issue.
Issue
When running tests with the {from: account}
is ignored in tests. I have debugged it through the SolidityFunction.prototype.sendTransaction
function where there are two options objects with the argument I pass in the test and the default options (I assume).
Regardless, the {from: account}
is ignored (see the github repo below).
More debugging. I updated the sendTransaction()
function with a console.log
:
SolidityFunction.prototype.execute = function () {
var transaction = !this._constant;
console.log('execute ------->', transaction, Array.prototype.slice.call(arguments))
// send transaction
if (transaction) {
return this.sendTransaction.apply(this, Array.prototype.slice.call(arguments));
}
// call
return this.call.apply(this, Array.prototype.slice.call(arguments));
};
This results in:
Notice the second {from}
options object. The first {from}
options object contains the address I am passing in while the second one contains the accounts[0]
address.
Steps to Reproduce
git clone https://github.com/auser/truffle-bug
npm install
In one terminal, run ganache
:
npm run ganache
In another, run the test:
./node_modules/.bin/truffle test --network development test/multisig/testMultiSig.js
Expected Behavior
I expect the msg.sender
address to be the address I pass in instead of the default account (accounts[0]
).
Actual Results
The msg.sender
value is the default account (accounts[0]
) instead of the address I pass in using the from
option.
Environment
- Operating System: OSX High Sierra
- Ethereum client: truffle test
- Truffle version (
truffle version
): Truffle v4.1.5 (core: 4.1.5) Solidity v0.4.21 (solc-js) - node version (
node --version
): v9.5.0 - npm version (
npm --version
): 5.8.0
Issue Analytics
- State:
- Created 5 years ago
- Comments:22 (9 by maintainers)
@cgewecke okay, I created a branch called
simplification
(https://github.com/auser/truffle-bug/tree/simplification) that reproduces the behavior.The contract method:
The javascript test:
In addition, I’m using the local truffle version from the repo (
./node_modules/.bin/truffle test --network development test/multisig/testMultiSig.js
)And the issue occurs on my globally installed truffle (
truffle test --network development test/multisig/testMultiSig.js
):FYI: I’m not trying to find a shortcut here, hence why I created a repo to demonstrate the issue. I wanted a way to demonstrate the issue in a reproducible way.
@emmonspired No, I’m not sure what’s going on here. If you discover something please report. It’s possible there’s a compatibility issue between
chai-bignumber
(at some version) and truffle. Zeppelin is using them in combination without any obvious issues. They’re at: