Skip to content

Use ganache for tests instead of Infura HTTP API #51

Merged
legobeat merged 2 commits intoMetaMask:mainfrom
legobeat:test-ganache
Dec 8, 2023
Merged

Use ganache for tests instead of Infura HTTP API #51
legobeat merged 2 commits intoMetaMask:mainfrom
legobeat:test-ganache

Conversation

@legobeat
Copy link
Copy Markdown
Contributor

@legobeat legobeat commented Nov 20, 2023

  • Use ganache instead of external Infura HTTP API endpoint for tests
    • Remove integration-test for Ethereum main-net chainstate
  • devDeps: bump typescript to ^4.8.4

Fixes unit CI tests currently failing on main.

Related

Blocking

- remove integration-test checking on-chain state
- pin ganache to 7.3.1 for Node.js v12 compatibility
const { MethodRegistry } = require('../dist');

const provider = new Eth.HttpProvider(`https://mainnet.infura.io/v3/${INFURA_PROJECT_ID}`);
const { provider } = Ganache.server();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It looks like we're just testing the parse method in these tests; we're not testing the lookup method, which actually makes us of the provider. So, could we just use a fake provider object here? That way we don't even need Ganache.

Copy link
Copy Markdown
Contributor Author

@legobeat legobeat Dec 5, 2023

Choose a reason for hiding this comment

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

Sure, but perhaps in a follow-up? Given that this is currently blocking doing any other changes in this repo.

Copy link
Copy Markdown

@NEllusion NEllusion Dec 7, 2023

Choose a reason for hiding this comment

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

@legobeat While I do love the idea of eliminating the need to make HTTP requests in tests, Ganache is going to be at its EOL on December 20th, and is no longer recommended in new projects.

Are we able to make this additional change here?

@legobeat legobeat requested review from a team, NEllusion, kumavis, mcmire and rekmarks December 5, 2023 02:43
Copy link
Copy Markdown

@NEllusion NEllusion left a comment

Choose a reason for hiding this comment

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

Spoke with Lego offline & agreed that making this change now is the best path forwards to unblock CI

@legobeat legobeat merged commit 7581c10 into MetaMask:main Dec 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use ganache for unit tests

3 participants