Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions packages/contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@
"test:e2e": "scripts/e2e",
"test:gas": "RUN_EVM=true REPORT_GAS=true scripts/test",
"test:coverage": "scripts/coverage",
"test:coverage:file": "scripts/test-coverage-file",
"test:upgrade": "scripts/upgrade",
"lint": "yarn lint:ts && yarn lint:sol",
"lint:ts": "eslint '**/*.{js,ts}' --fix",
Expand All @@ -103,16 +104,17 @@
},
"lint-staged": {
"contracts/**/*.sol": [
"yarn lint:sol"
"prettier --write",
"solhint --fix --noPrompt --config node_modules/solhint-graph-config/index.js"
],
"**/*.ts": [
"yarn lint:ts"
"eslint --fix"
],
"**/*.js": [
"yarn lint:ts"
"eslint --fix"
],
"**/*.json": [
"yarn lint:ts"
"eslint --fix"
]
},
"repository": {
Expand Down
23 changes: 23 additions & 0 deletions packages/contracts/scripts/test-coverage-file
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env bash

set -eo pipefail

# Check if a test file was provided
if [ $# -eq 0 ]; then
echo "Error: You must provide a test file path"
echo "Usage: ./scripts/test-coverage-file test/unit/rewards/rewards.test.ts"
exit 1
fi

# Build contracts first to ensure tests run against latest code
echo "Building contracts before running coverage..."
yarn build

echo "{}" > addresses-local.json
Copy link

Copilot AI May 15, 2025

Choose a reason for hiding this comment

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

[nitpick] Consider adding cleanup of the 'addresses-local.json' file after test execution to avoid leaving residual files or accidental commits.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@tmigone I think leaving the file is a designed feature of how other scripts work, so I am not going to change this unless you suggest I should.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

it should be safe to remove after the tests run. But it's been a while since I looked at this branch so there might be something I'm not remembering, if you find an issue with removing it then let's leave it 🫤


echo "Running coverage for test file: $1"
DISABLE_SECURE_ACCOUNTS=true \
L1_GRAPH_CONFIG=config/graph.hardhat.yml \
L2_GRAPH_CONFIG=config/graph.arbitrum-hardhat.yml \
ADDRESS_BOOK=addresses-local.json \
npx hardhat coverage --testfiles "$1"