Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

SendTransaction generate multiple errors when sent from a locked account #259

Closed
ccowell opened this issue Dec 13, 2018 · 1 comment
Closed

Comments

@ccowell
Copy link
Contributor

ccowell commented Dec 13, 2018

Sending a transaction in secure mode (when all accounts are locked) generates multiple error events.

Expected Behavior

Expecting a single error noting that the account is locked.

Current Behavior

Currently seeing two very different error objects reporting the account is locked.

Possible Solution

Use try/catch and async/await with sendTransaction in secure mode.

Steps to Reproduce (for bugs)

Execute the following code and monitor err in the callback.

var web3 = new Web3();
    web3.setProvider(
      Ganache.provider({
        mnemonic: mnemonic,
        secure: true
      })
    );

    web3.eth.sendTransaction(
      {
        from: expectedAddress,
        to: "0x1234567890123456789012345678901234567890", // doesn't need to exist
        value: web3.utils.toWei(1, "ether"),
        gasLimit: 90000
      },
      function(**err**, tx) {
        if (!**err**) {
          return done(
            new Error("We expected the account to be locked, which should throw an error when sending a transaction")
          );
        }

        /* checking for "**signer account is locked**"  but have to resort to this. */
        assert(
          err.message.toLowerCase().indexOf("could not unlock signer account") >= 0,
          "Expected error message containing \"could not unlock signer account\" " +
            "(case insensitive check). Received the following error message, instead. " +
            `"${err.message}"`
        );
      }

Context

Ensuring that I can not send a transaction from a locked account.

ccowell added a commit that referenced this issue Dec 13, 2018
Immediately bubble up errors during Ganache calls
@davidmurdoch
Copy link
Member

Fixed!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants