Skip to content

Commit

Permalink
test: fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
danijelTxFusion committed Dec 19, 2023
1 parent a761751 commit e7eae37
Show file tree
Hide file tree
Showing 21 changed files with 1,736 additions and 404 deletions.
36 changes: 0 additions & 36 deletions .github/workflows/npm.publish.yml

This file was deleted.

37 changes: 37 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Run tests
on:
workflow_dispatch:
pull_request:
branch: ethers-v5
types: [ opened, reopened, synchronize ]

permissions:
contents: read # for checkout

jobs:
test:
name: Test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: "lts/*"
- name: Install dependencies
run: yarn install
- name: Run local-setup
run: |
git clone https://github.com/matter-labs/local-setup.git
pushd local-setup
docker-compose up -d
popd
- name: Wait for local-setup to be ready
run: yarn test:wait
- name: Prepare environment
run: yarn test:prepare
- name: Run tests
run: yarn test
47 changes: 47 additions & 0 deletions .github/workflows/validate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Validate
on:
pull_request:
types: [ opened, reopened, synchronize ]

permissions:
contents: read # for checkout

jobs:
lint:
name: Check code format
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: "lts/*"
- name: Install dependencies
run: yarn install
- name: Prepare environment
run: yarn lint:check
commits:
name: Check commits
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: "lts/*"
- name: Install dependencies
run: npm install -g @commitlint/cli @commitlint/config-conventional
- name: Configure
run: |
echo 'module.exports = {"extends": ["@commitlint/config-conventional"]}' > commitlint.config.js
- name: Validate
run: |
git fetch
npx commitlint \
--from ${{ github.event.pull_request.head.sha }}~${{ github.event.pull_request.commits }} \
--to ${{ github.event.pull_request.head.sha }} \
--verbose
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
build
node_modules
tests/token.json
coverage

.idea
8 changes: 8 additions & 0 deletions .nycrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"report-dir": "./coverage",
"reporter": ["lcov", "text"],
"clean": true,
"all": true,
"include": ["src/*"],
"exclude": ["tests/*", "typechain/*"]
}
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"@types/chai": "^4.2.19",
"@types/mocha": "^8.2.2",
"@types/node": "^16.0.0",
"c8": "^8.0.1",
"chai": "^4.3.4",
"ethers": "~5.7.0",
"mocha": "10.1.0",
Expand All @@ -46,7 +47,10 @@
"ethers": "~5.7.0"
},
"scripts": {
"test": "mocha -r ts-node/register --bail tests/setup.test.ts tests/unit/*.test.ts tests/integration/*.test.ts",
"test:prepare": "cd tests/setup/ && ./setup.sh && cd ../..",
"test:coverage": "c8 -c .nycrc mocha -r ts-node/register tests/unit/*.test.ts tests/integration/*.test.ts",
"test:wait": "ts-node tests/wait.ts",
"test": "mocha -r ts-node/register tests/unit/*.test.ts tests/integration/*.test.ts",
"build": "tsc && cp -f typechain/*.d.ts build/typechain && ncp ./abi ./build/abi",
"lint": "prettier . --write",
"lint:check": "prettier . --check",
Expand Down
106 changes: 0 additions & 106 deletions src/calldata.ts

This file was deleted.

8 changes: 4 additions & 4 deletions src/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {
TransactionStatus,
Fee,
Network as ZkSyncNetwork,
RawBlockTransaction
RawBlockTransaction,
} from "./types";
import {
CONTRACT_DEPLOYER,
Expand Down Expand Up @@ -400,7 +400,7 @@ export class Provider extends ethers.providers.JsonRpcProvider {
if (l2WethToken != ethers.constants.AddressZero) {
return l2WethToken;
}
} catch (e) { }
} catch (e) {}
const l2Erc20Bridge = IL2BridgeFactory.connect(bridgeAddresses.erc20L2, this);
return await l2Erc20Bridge.l2TokenAddress(token);
}
Expand All @@ -418,7 +418,7 @@ export class Provider extends ethers.providers.JsonRpcProvider {
if (l1WethToken != ethers.constants.AddressZero) {
return l1WethToken;
}
} catch (e) { }
} catch (e) {}
const erc20Bridge = IL2BridgeFactory.connect(bridgeAddresses.erc20L2, this);
return await erc20Bridge.l1TokenAddress(token);
}
Expand Down Expand Up @@ -663,7 +663,7 @@ export class Provider extends ethers.providers.JsonRpcProvider {
let l1WethToken = ethers.constants.AddressZero;
try {
l1WethToken = await l2WethBridge.l1TokenAddress(tx.token);
} catch (e) { }
} catch (e) {}
tx.bridgeAddress =
l1WethToken != ethers.constants.AddressZero
? bridgeAddresses.wethL2
Expand Down
4 changes: 2 additions & 2 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ export interface RawBlockTransaction {
max_fee_per_gas: BigInt;
max_priority_fee_per_gas: BigInt;
gas_per_pubdata_limit: BigInt;
},
};
initiatorAddress: Address;
signature: Uint8Array;
transactionType: string;
Expand All @@ -266,7 +266,7 @@ export interface RawBlockTransaction {
paymaster: Address;
paymasterInput: Uint8Array;
};
}
};
};
execute: {
calldata: string;
Expand Down
Loading

0 comments on commit e7eae37

Please sign in to comment.