Skip to content

Commit

Permalink
test: use ganache for tests instead of Infura HTTP API
Browse files Browse the repository at this point in the history
- remove integration-test checking on-chain state
- pin ganache to 7.3.1 for Node.js v12 compatibility
  • Loading branch information
legobeat committed Nov 20, 2023
1 parent e507889 commit a7b3072
Show file tree
Hide file tree
Showing 5 changed files with 229 additions and 22 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/build-lint-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ on:
jobs:
build-lint-test:
name: Build, Lint, and Test
env:
INFURA_PROJECT_ID: ${{ secrets.INFURA_PROJECT_ID }}
runs-on: ubuntu-20.04
strategy:
matrix:
Expand Down
1 change: 0 additions & 1 deletion .infurarc.template

This file was deleted.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"eslint-plugin-import": "^2.22.0",
"eslint-plugin-json": "^2.1.2",
"eslint-plugin-node": "^11.1.0",
"ganache": "7.3.1",
"prettier": "2.2.1",
"rc": "^1.2.8",
"tape": "^5.1.1",
Expand Down
20 changes: 2 additions & 18 deletions test/index.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,12 @@
const test = require('tape');
const Eth = require('ethjs');

const { INFURA_PROJECT_ID } = require('rc')('infura', {
// eslint-disable-next-line node/no-process-env
INFURA_PROJECT_ID: process.env.INFURA_PROJECT_ID,
});
const Ganache = require('ganache');

const { MethodRegistry } = require('../dist');

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

test('connecting to main net contract', function (t) {
t.plan(1);

registry.lookup('0xa9059cbb')
.then((result) => {
t.equal(result, 'transfer(address,uint256)', 'finds correct value');
})
.catch((reason) => {
t.fail(reason.message);
});
});

test('parse signature', function (t) {
const sig = 'transfer(address,uint256)';
const parsed = registry.parse(sig);
Expand Down
Loading

0 comments on commit a7b3072

Please sign in to comment.