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

Add --url option to the truffle exec command #5843

Closed
wants to merge 4 commits into from

Conversation

sukanyaparashar
Copy link
Contributor

PR description

This PR adds --url option to the truffle exec command that connects to a specified url. See #5701.

Testing instructions

To test this option, you can clone this Test Project with a simple storage contract and a test script.

  1. Run a ganache instance in a terminal.
  2. Run truffle compile inside a truffle project in a separate terminal.
  3. Run truffle exec test-script.js --url http://127.0.0.1:8545. It should execute the script and deploys a new instance of the contract and returns the value of the state variable that is set with a constructor.

Screenshot 2023-01-17 at 8 36 48 PM

Documentation

  • I thought about documentation and added the doc-change-required label to this PR if documentation updates are required.

@sukanyaparashar sukanyaparashar added enhancement doc-change-required Issue indicates a change to documentation is required labels Jan 18, 2023
@sukanyaparashar sukanyaparashar marked this pull request as draft January 18, 2023 04:27
Copy link
Contributor

@dongmingh dongmingh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Follow the test instructions, everything works as expected. In addition, I test the following scenarios:

  1. incorrect url
$ truffle exec test-script.js --url http://127.0.0.1:8544
> Something went wrong while attempting to connect to the network at http://127.0.0.1:8544. Check your network configuration.
CONNECTION ERROR: Couldn't connect to node http://127.0.0.1:8544.
Truffle (unbundled) (core: 5.7.0)
Node v16.18.1
  1. the script does not exit
$ truffle exec test.js --url http://127.0.0.1:8545                                                                1 ↵
Using network '127.0.0.1:8545'.

Error: ENOENT: no such file or directory, open '/Users/dongminghwang/work/trufflesuite/test/reprod/2023/01/18/add-url-to-exec/truffle-test-project/test.js'
    at Object.openSync (node:fs:590:3)
    at readFileSync (node:fs:458:35)
    at compile (/Users/dongminghwang/work/trufflesuite/truffle/packages/require/lib/typescript.ts:37:30)
    at file (/Users/dongminghwang/work/trufflesuite/truffle/packages/require/lib/index.ts:98:25)
    at exec (/Users/dongminghwang/work/trufflesuite/truffle/packages/require/lib/index.ts:133:16)
    at node:internal/util:364:7
    at new Promise (<anonymous>)
    at exec (node:internal/util:350:12)
    at Object.module.exports [as run] (/Users/dongminghwang/work/trufflesuite/truffle/packages/core/lib/commands/exec/run.js:56:31)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at runCommand (/Users/dongminghwang/work/trufflesuite/truffle/packages/core/lib/command-utils.js:201:10)
Truffle (unbundled) (core: 5.7.0)
Node v16.18.1
  1. the script does not call process.exit(),
    Truffle hangs
$ truffle exec test-script.js --url http://127.0.0.1:8545                                                         1 ↵
Using network '127.0.0.1:8545'.

The returned value is:  600

and ganache continue to display

eth_getBlockByNumber
eth_getBlockByNumber
eth_getBlockByNumber
eth_getBlockByNumber
eth_getBlockByNumber
eth_getBlockByNumber
eth_getBlockByNumber

Shall we consider to end the program?

@sukanyaparashar
Copy link
Contributor Author

sukanyaparashar commented Jan 24, 2023

This PR can be closed and the branch can also be deleted as I have opened a new one #5852 for this.

@cds-amal
Copy link
Member

This PR can be closed and the branch can also be deleted as I have opened a new one #5852

@cds-amal cds-amal closed this Jan 24, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
doc-change-required Issue indicates a change to documentation is required enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants