Open cipaterson opened 2 years ago
Thanks @cipaterson for opening this! On investigation it seems like this might have something to do with the difference in how web3 handles when gas estimation fails versus how hdwallet-provider does? web3 might allow it to fail and try to run the tx anyways - some relevant code can be found here in contract. There will need to be some more investigation.
Issue
When using HDWalletProvider in the truffle-config.js file, the tests are not working as expected. When a call reverts, the promise doesn't fail as expected but is resolved with the reverted transaction As soon as the development network is not user HDWalletProvider the tests will be successful
Steps to Reproduce
git clone https://github.com/cipaterson/HDWalletProviderIssue cd HDWalletProviderIssue npm install ganache -m "ahead nasty leopard trick demise trap ten spoil festival comic unlock shallow" truffle test # Will fail truffle test --network dev # will succeed
Expected Behavior
~/HDWalletProviderIssue master !1 ?1 > truffle test --network dev 7s 18:38:07 Using network 'dev'.
Compiling your contracts...
Contract: Stacking Test Suite Owner: Test to attach tokens owner 0x64729B74061b020Adfd7Bbc5148C4f3CD516044E user1 0x842d479e85a854A74a736Ba6E2cC888b9C68b887 catch ✔ should reject for not owner caller
1 passing (69ms)
Actual Results
~/HDWalletProviderIssue master !1 ?1 > truffle test 57s 18:37:52 Using network 'development'.
Compiling your contracts...
Contract: Stacking Test Suite Owner: Test to attach tokens owner 0x64729B74061b020Adfd7Bbc5148C4f3CD516044E user1 0x842d479e85a854A74a736Ba6E2cC888b9C68b887 resolve 1) should reject for not owner caller
0 passing (99ms) 1 failing
1) Contract: Stacking Test Suite Owner: Test to attach tokens should reject for not owner caller: AssertionError: Expected an exception but none was received at expectException (node_modules/@openzeppelin/test-helpers/src/expectRevert.js:25:10) at runNextTicks (node:internal/process/task_queues:61:5) at listOnTimeout (node:internal/timers:528:9) at processTimers (node:internal/timers:502:7) at expectRevert (node_modules/@openzeppelin/test-helpers/src/expectRevert.js:75:3) at Context. (test/test.js:27:13)
Environment
npm --version
): 8.5.0