mirror of
https://github.com/luxfi/erc-3643.git
synced 2026-10-30 16:58:28 +00:00
* ✨ integrate foundry alongside hardhat for dual testing framework - Add foundry.toml configuration - Reorganize test structure: test/forge/ and test/hardhat/ - Add Foundry scripts to package.json (build:forge, test:forge, coverage:forge) - Update hardhat.config.ts with evmVersion for compatibility - Add GitHub workflows and coverage scripts from template - Add Husky hooks (pre-commit, post-checkout, post-merge) - Add .vscode/settings.json for better IDE support - Disable coverage checks until tests are migrated (commented with TODO) This migration is based on TokenySolutions/contracts-template and enables gradual migration of tests from Hardhat (TypeScript) to Foundry (Solidity). Related to: BT-1418 * ✅ trex factory tests * ⚰️ remove trex suit * feat(forge): reorganize Foundry test structure and sync GitHub workflows - Move TREXFactorySetup to helpers folder - Rename TREXSuite.t.sol to TREXFactory.t.sol - Update fixture to inherit from Test for proper Foundry pattern - Transfer ownership to deployer address to match Hardhat behavior - Sync GitHub workflows with package.json scripts - Update test.yml to use npm run build and npm run test - Update push_checking.yml to use unified npm run lint - Update forge_coverage.sh to use npm run coverage * fix(ci): install Foundry and skip husky in push_checking workflow - Add Foundry installation step before npm ci - Set HUSKY=0 to skip husky setup in CI environment - Fixes 'forge: not found' error during npm prepare script * 🔧 keep hardhat settings * ✅ create addressess directly * ✅ removed test_StandardAddressesSet * ✅ fix lint * 💡 removed title natspecs * ✅ migrated trex factort tests * ✅ added test module multicall * ✅ migrate agent role test * ✅ migrate claim topics registry * ✅ migrated trusted issuer registry * ✅ migrate identity registry storage * ✅ migrated identity registry tests * ✅ migrated implementation authority test * ✅ migrated token agen restrictions * ✅ migrated token information test * ✅ migrated token recover * ✅ migrated token permit * ✅ migrated token transfer * ✅ migrated utilities upgrade * ✅ migrated freeze check * ✅ migrated compliance check in utilities test * ✅ migrated eligibility check * ✅ migrated transfer check in utilities * ✅ migrated compliance test * ✅ migrated gateway tests * 🔥 removed already defined events * 🗑️ imported Initializable error from openzeppelin * ➕ added already defined events and errors * ✅ added base test token * ✅ used idFactory * ♻️ refactored compliance test * ⚰️ remoced useless vm.prank * 🔧 deleted hardhat configurations * 💚 fixed ci * refactor: remove 100% coverage requirement from forge_coverage.sh - Remove strict 100% coverage checks that were causing workflow failures - Script now only generates and displays coverage report without failing - Aligns with previous behavior where coverage was informational only * ✅ resolve getVerifiedDetails * ✅ applied _getEligibility and remove via-ir from foundry.toml * ✅ cover tokena and token permit * ✅ cover compliance * ✅ cover identity registry * ✅ increased trex gateway coverage * ✅ increase coverage for trex factory * ✅ increased AbstractModuleUpgradeable.sol coverage * ⚰️ removed abstract module * 🔧 updted generate coverage * ✅ coverage 100% identity registry * ✅ coverage 100% trex gate way * ✅ coverage trex factory * ✅ coverage 100% AbstractModuleUpgradeable by test module * ✅ coverage IAFactory.sol * ✅ coverage 100% for implementation authority * ✅ coverage 1005 abstract proxy * ✅ coverage 100% claim topic registry * ✅ coverage 100% identity registry storage * ✅ coverage 100% modular compliance proxy * ✅ coverage trusted issuer registry proxy * ✅ coverage 100% identity registry * ✅ coverage 100% token proxy * 🚨 resolve linter in token information * ✅ coverage 100% roles * 🚨 resolve linter * 🔧 added no coverage for test, _testContracts and utils * ✅ coverage 100% for token.sol * ✅ coverage 100% for modular compliance * ✅ coverage 100% trusted issuer registry * 🔧 restore package.json * ✅ coverage 100% for utlity checker * 🚨 fix linter
78 lines
3.6 KiB
Bash
Executable File
78 lines
3.6 KiB
Bash
Executable File
#!/bin/bash
|
||
echo "🔍 Generating coverage reports..."
|
||
|
||
# Ensure coverage directory exists
|
||
mkdir -p coverage
|
||
|
||
# Generate coverage with LCOV report (exclude test files and test contracts)
|
||
forge coverage --report summary --report lcov --no-match-coverage "(^test/|_testContracts/|utils/)"
|
||
|
||
# Move lcov.info to coverage folder if it exists in root
|
||
if [ -f lcov.info ]; then
|
||
mv lcov.info coverage/lcov.info
|
||
echo "✅ Moved lcov.info to coverage folder"
|
||
elif [ -f coverage/lcov.info ]; then
|
||
echo "ℹ️ lcov.info already in coverage folder"
|
||
else
|
||
echo "⚠️ lcov.info not found - coverage may have failed"
|
||
exit 1
|
||
fi
|
||
|
||
# Generate HTML report from LCOV if genhtml is available
|
||
if command -v genhtml &> /dev/null; then
|
||
echo "📄 Generating HTML report..."
|
||
# Generate HTML report with branch coverage and function coverage
|
||
genhtml coverage/lcov.info -o coverage/lcov-report --branch-coverage --ignore-errors inconsistent > /dev/null 2>&1
|
||
if [ -f coverage/lcov-report/index.html ]; then
|
||
# Extract statements coverage from forge summary and inject into HTML report headers
|
||
echo "📊 Adding statements coverage to report headers..."
|
||
|
||
# Get statements coverage data for Token.sol (format: "100.00% (234/234)")
|
||
STATEMENTS_LINE=$(forge coverage --report summary --no-match-coverage "(^test/|_testContracts/|utils/)" 2>&1 | grep "Token.sol")
|
||
if [ ! -z "$STATEMENTS_LINE" ]; then
|
||
# Extract: percentage, total, hit from the statements column (4th column)
|
||
STATEMENTS_PCT=$(echo "$STATEMENTS_LINE" | awk -F'|' '{print $4}' | awk '{print $1}' | tr -d ' ')
|
||
STATEMENTS_TOTAL=$(echo "$STATEMENTS_LINE" | awk -F'|' '{print $4}' | grep -o '[0-9]*/' | tr -d '/')
|
||
STATEMENTS_HIT=$(echo "$STATEMENTS_LINE" | awk -F'|' '{print $4}' | grep -o '/[0-9]*' | tr -d '/')
|
||
|
||
# Add statements row to header in all HTML files
|
||
find coverage/lcov-report -name "*.html" -type f | while read htmlfile; do
|
||
# Insert statements row after Functions row in header section (using BSD sed syntax for macOS)
|
||
STATEMENTS_ROW=" <tr>\\
|
||
<td></td>\\
|
||
<td></td>\\
|
||
<td></td>\\
|
||
<td class=\"headerItem\">Statements:</td>\\
|
||
<td class=\"headerCovTableEntryHi\">${STATEMENTS_PCT}</td>\\
|
||
<td class=\"headerCovTableEntry\">${STATEMENTS_TOTAL}</td>\\
|
||
<td class=\"headerCovTableEntry\">${STATEMENTS_HIT}</td>\\
|
||
</tr>"
|
||
# Use awk to insert after Functions row
|
||
awk -v stmt_row="$STATEMENTS_ROW" '
|
||
/<td class="headerItem">Functions:<\/td>/ {found=1}
|
||
found && /<\/tr>/ && !inserted {
|
||
print
|
||
print stmt_row
|
||
inserted=1
|
||
found=0
|
||
next
|
||
}
|
||
{print}
|
||
' "$htmlfile" > "$htmlfile.tmp" && mv "$htmlfile.tmp" "$htmlfile" 2>/dev/null || true
|
||
done
|
||
echo " ✅ Statements coverage added: ${STATEMENTS_PCT} (${STATEMENTS_HIT}/${STATEMENTS_TOTAL})"
|
||
fi
|
||
|
||
echo "✅ HTML report generated successfully!"
|
||
echo "📊 View HTML report: open coverage/lcov-report/index.html"
|
||
else
|
||
echo "⚠️ HTML report generation failed (but LCOV file is available)"
|
||
fi
|
||
else
|
||
echo "⚠️ genhtml not found - install with: brew install lcov"
|
||
echo " LCOV file available at: coverage/lcov.info"
|
||
fi
|
||
|
||
echo ""
|
||
echo "✅ Coverage reports generated!"
|