Some checks failed
Contract Performance Benchmarks / benchmark-gas-usage (push) Successful in 1m14s
Contract Performance Benchmarks / benchmark-execution-time (push) Successful in 59s
Contract Performance Benchmarks / benchmark-throughput (push) Successful in 59s
Cross-Chain Functionality Tests / test-cross-chain-sync (push) Successful in 1s
Cross-Chain Functionality Tests / test-cross-chain-transactions (push) Successful in 1s
Cross-Chain Functionality Tests / test-cross-chain-bridge (push) Has been skipped
Cross-Chain Functionality Tests / test-multi-chain-consensus (push) Successful in 2s
Cross-Chain Functionality Tests / aggregate-results (push) Has been skipped
Cross-Node Transaction Testing / transaction-test (push) Successful in 10s
Deploy to Testnet / deploy-testnet (push) Successful in 1m0s
Multi-Node Stress Testing / stress-test (push) Successful in 2s
Node Failover Simulation / failover-test (push) Successful in 1s
Smart Contract Tests / test-solidity (map[name:aitbc-contracts path:contracts]) (push) Failing after 1m1s
Smart Contract Tests / test-solidity (map[name:aitbc-token path:packages/solidity/aitbc-token]) (push) Successful in 9s
Smart Contract Tests / test-foundry (push) Failing after 5s
Smart Contract Tests / lint-solidity (push) Successful in 14s
Smart Contract Tests / deploy-contracts (push) Successful in 1m10s
Contract Performance Benchmarks / compare-benchmarks (push) Successful in 1s
Deploy to Testnet / notify-deployment (push) Successful in 2s
- Add forge install OpenZeppelin/openzeppelin-contracts to workflow - Fix TreasuryManager verification - use treasuryToken() instead of token()
257 lines
7.9 KiB
YAML
257 lines
7.9 KiB
YAML
name: Smart Contract Tests
|
|
|
|
on:
|
|
push:
|
|
branches: [main, develop]
|
|
paths:
|
|
- 'packages/solidity/**'
|
|
- 'apps/zk-circuits/**'
|
|
- 'contracts/**'
|
|
- '.gitea/workflows/smart-contract-tests.yml'
|
|
pull_request:
|
|
branches: [main, develop]
|
|
workflow_dispatch:
|
|
|
|
concurrency:
|
|
group: smart-contract-tests-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
test-solidity:
|
|
runs-on: debian
|
|
timeout-minutes: 15
|
|
|
|
strategy:
|
|
matrix:
|
|
project:
|
|
- name: "aitbc-token"
|
|
path: "packages/solidity/aitbc-token"
|
|
- name: "aitbc-contracts"
|
|
path: "contracts"
|
|
|
|
steps:
|
|
- name: Clone repository
|
|
run: |
|
|
WORKSPACE="/var/lib/aitbc-workspaces/solidity-${{ matrix.project.name }}"
|
|
rm -rf "$WORKSPACE"
|
|
mkdir -p "$WORKSPACE"
|
|
cd "$WORKSPACE"
|
|
git clone --depth 1 http://gitea.bubuit.net:3000/oib/aitbc.git repo
|
|
|
|
- name: Initialize job logging
|
|
run: |
|
|
cd "/var/lib/aitbc-workspaces/solidity-${{ matrix.project.name }}/repo"
|
|
bash scripts/ci/setup-job-logging.sh
|
|
|
|
- name: Setup and test
|
|
run: |
|
|
WORKSPACE="/var/lib/aitbc-workspaces/solidity-${{ matrix.project.name }}"
|
|
cd "$WORKSPACE/repo/${{ matrix.project.path }}"
|
|
echo "=== Testing ${{ matrix.project.name }} ==="
|
|
|
|
# Ensure standard directories exist
|
|
mkdir -p /var/lib/aitbc/data /var/lib/aitbc/keystore /etc/aitbc /var/log/aitbc
|
|
|
|
if [[ ! -f "package.json" ]]; then
|
|
echo "⚠️ No package.json, skipping"
|
|
exit 0
|
|
fi
|
|
|
|
echo "Node: $(node --version), npm: $(npm --version)"
|
|
|
|
# Install
|
|
npm install --legacy-peer-deps
|
|
|
|
# Compile
|
|
if [[ -f "hardhat.config.js" ]] || [[ -f "hardhat.config.ts" ]]; then
|
|
npx hardhat compile
|
|
echo "✅ Compiled"
|
|
npx hardhat test
|
|
echo "✅ Tests passed"
|
|
elif [[ -f "foundry.toml" ]]; then
|
|
forge build
|
|
echo "✅ Compiled"
|
|
forge test
|
|
echo "✅ Tests passed"
|
|
else
|
|
if node -e "const pkg=require('./package.json'); process.exit(pkg.scripts && pkg.scripts.compile ? 0 : 1)"; then
|
|
npm run compile
|
|
echo "✅ Compiled"
|
|
elif node -e "const pkg=require('./package.json'); process.exit(pkg.scripts && pkg.scripts.build ? 0 : 1)"; then
|
|
npm run build
|
|
echo "✅ Compiled"
|
|
else
|
|
echo "❌ No compile or build script found"
|
|
exit 1
|
|
fi
|
|
|
|
if node -e "const pkg=require('./package.json'); process.exit(pkg.scripts && pkg.scripts.test ? 0 : 1)"; then
|
|
npm test
|
|
echo "✅ Tests passed"
|
|
else
|
|
echo "❌ No test script found"
|
|
exit 1
|
|
fi
|
|
fi
|
|
|
|
echo "✅ ${{ matrix.project.name }} completed"
|
|
|
|
test-foundry:
|
|
runs-on: debian
|
|
timeout-minutes: 20
|
|
|
|
steps:
|
|
- name: Clone repository
|
|
run: |
|
|
WORKSPACE="/var/lib/aitbc-workspaces/foundry"
|
|
rm -rf "$WORKSPACE"
|
|
mkdir -p "$WORKSPACE"
|
|
cd "$WORKSPACE"
|
|
git clone --depth 1 http://gitea.bubuit.net:3000/oib/aitbc.git repo
|
|
|
|
- name: Initialize job logging
|
|
run: |
|
|
cd /var/lib/aitbc-workspaces/foundry/repo
|
|
bash scripts/ci/setup-job-logging.sh
|
|
|
|
- name: Install Foundry
|
|
run: |
|
|
if ! command -v forge &> /dev/null; then
|
|
curl -L https://foundry.paradigm.xyz | bash
|
|
export PATH="$HOME/.foundry/bin:$PATH"
|
|
foundryup
|
|
export PATH="$HOME/.foundry/bin:$PATH"
|
|
fi
|
|
forge --version
|
|
|
|
- name: Test contracts with Foundry
|
|
run: |
|
|
export PATH="$HOME/.foundry/bin:$PATH"
|
|
cd /var/lib/aitbc-workspaces/foundry/repo/contracts
|
|
|
|
# Ensure standard directories exist
|
|
mkdir -p /var/lib/aitbc/data /var/lib/aitbc/keystore /etc/aitbc /var/log/aitbc
|
|
|
|
echo "=== Running Foundry Tests ==="
|
|
|
|
# Install OpenZeppelin dependencies
|
|
forge install OpenZeppelin/openzeppelin-contracts --no-commit
|
|
echo "✅ OpenZeppelin dependencies installed"
|
|
|
|
# Build contracts
|
|
forge build
|
|
echo "✅ Foundry build completed"
|
|
|
|
# Run tests
|
|
forge test
|
|
echo "✅ Foundry tests passed"
|
|
|
|
# Run fuzz tests
|
|
forge test --match-path "test/fuzz/**/*.t.sol"
|
|
echo "✅ Foundry fuzz tests passed"
|
|
|
|
- name: Cleanup
|
|
if: always()
|
|
run: rm -rf "/var/lib/aitbc-workspaces/foundry"
|
|
|
|
lint-solidity:
|
|
runs-on: debian
|
|
timeout-minutes: 10
|
|
|
|
steps:
|
|
- name: Clone repository
|
|
run: |
|
|
WORKSPACE="/var/lib/aitbc-workspaces/solidity-lint"
|
|
rm -rf "$WORKSPACE"
|
|
mkdir -p "$WORKSPACE"
|
|
cd "$WORKSPACE"
|
|
git clone --depth 1 http://gitea.bubuit.net:3000/oib/aitbc.git repo
|
|
|
|
- name: Initialize job logging
|
|
run: |
|
|
cd /var/lib/aitbc-workspaces/solidity-lint/repo
|
|
bash scripts/ci/setup-job-logging.sh
|
|
|
|
- name: Lint contracts
|
|
run: |
|
|
cd /var/lib/aitbc-workspaces/solidity-lint/repo
|
|
|
|
# Ensure standard directories exist
|
|
mkdir -p /var/lib/aitbc/data /var/lib/aitbc/keystore /etc/aitbc /var/log/aitbc
|
|
|
|
for project in packages/solidity/aitbc-token contracts; do
|
|
if [[ -d "$project" ]] && [[ -f "$project/package.json" ]]; then
|
|
echo "=== Linting $project ==="
|
|
cd "$project"
|
|
npm install --legacy-peer-deps
|
|
|
|
if node -e "const pkg=require('./package.json'); process.exit(pkg.scripts && pkg.scripts.lint ? 0 : 1)"; then
|
|
npm run lint
|
|
echo "✅ Lint passed"
|
|
else
|
|
echo "⚠️ No lint script for $project, skipping"
|
|
fi
|
|
cd /var/lib/aitbc-workspaces/solidity-lint/repo
|
|
fi
|
|
done
|
|
|
|
echo "✅ Solidity linting completed"
|
|
|
|
- name: Cleanup
|
|
if: always()
|
|
run: rm -rf /var/lib/aitbc-workspaces/solidity-lint
|
|
|
|
deploy-contracts:
|
|
runs-on: debian
|
|
timeout-minutes: 15
|
|
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop'
|
|
|
|
steps:
|
|
- name: Clone repository
|
|
run: |
|
|
WORKSPACE="/var/lib/aitbc-workspaces/deployment"
|
|
rm -rf "$WORKSPACE"
|
|
mkdir -p "$WORKSPACE"
|
|
cd "$WORKSPACE"
|
|
git clone --depth 1 http://gitea.bubuit.net:3000/oib/aitbc.git repo
|
|
|
|
- name: Initialize job logging
|
|
run: |
|
|
cd /var/lib/aitbc-workspaces/deployment/repo
|
|
bash scripts/ci/setup-job-logging.sh
|
|
|
|
- name: Deploy contracts to localhost
|
|
run: |
|
|
cd /var/lib/aitbc-workspaces/deployment/repo/contracts
|
|
|
|
# Ensure standard directories exist
|
|
mkdir -p /var/lib/aitbc/data /var/lib/aitbc/keystore /etc/aitbc /var/log/aitbc
|
|
|
|
echo "=== Deploying Contracts to Localhost ==="
|
|
|
|
# Install dependencies
|
|
npm install --legacy-peer-deps
|
|
|
|
# Compile contracts
|
|
npx hardhat compile
|
|
|
|
# Start local node in background
|
|
npx hardhat node &
|
|
NODE_PID=$!
|
|
sleep 10
|
|
|
|
# Deploy contracts
|
|
npx hardhat run scripts/deploy-automation.js --network localhost
|
|
echo "✅ Contracts deployed successfully"
|
|
|
|
# Verify deployment
|
|
DEPLOYMENT_FILE="deployments-localhost.json" npx hardhat run scripts/verify-deployment.js --network localhost
|
|
echo "✅ Deployment verified"
|
|
|
|
# Cleanup
|
|
kill $NODE_PID 2>/dev/null || true
|
|
|
|
- name: Cleanup
|
|
if: always()
|
|
run: rm -rf /var/lib/aitbc-workspaces/deployment
|