|
| 1 | +name: Tron Smart Contracts Tests |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + branches: |
| 6 | + - master |
| 7 | + paths: |
| 8 | + - 'packages/smart-contracts/tron/**' |
| 9 | + - 'packages/smart-contracts/tronbox-config.js' |
| 10 | + - 'packages/smart-contracts/src/lib/artifacts/ERC20FeeProxy/**' |
| 11 | + - 'packages/payment-processor/src/payment/*tron*' |
| 12 | + - 'packages/payment-processor/test/payment/*tron*' |
| 13 | + - 'packages/currency/src/chains/tron/**' |
| 14 | + - '.github/workflows/tron-smart-contracts.yml' |
| 15 | + push: |
| 16 | + branches: |
| 17 | + - master |
| 18 | + paths: |
| 19 | + - 'packages/smart-contracts/tron/**' |
| 20 | + - 'packages/smart-contracts/tronbox-config.js' |
| 21 | + - 'packages/smart-contracts/src/lib/artifacts/ERC20FeeProxy/**' |
| 22 | + - 'packages/payment-processor/src/payment/*tron*' |
| 23 | + - 'packages/payment-processor/test/payment/*tron*' |
| 24 | + - 'packages/currency/src/chains/tron/**' |
| 25 | + workflow_dispatch: |
| 26 | + |
| 27 | +jobs: |
| 28 | + tron-compile-check: |
| 29 | + name: Tron Contract Compilation Check |
| 30 | + runs-on: ubuntu-latest |
| 31 | + |
| 32 | + steps: |
| 33 | + - name: Checkout repository |
| 34 | + uses: actions/checkout@v4 |
| 35 | + |
| 36 | + - name: Setup Node.js |
| 37 | + uses: actions/setup-node@v4 |
| 38 | + with: |
| 39 | + node-version: '22' |
| 40 | + cache: 'yarn' |
| 41 | + |
| 42 | + - name: Install TronBox globally |
| 43 | + run: npm install -g tronbox |
| 44 | + |
| 45 | + - name: Install dependencies |
| 46 | + run: yarn install --frozen-lockfile |
| 47 | + |
| 48 | + - name: Compile Tron contracts |
| 49 | + working-directory: packages/smart-contracts |
| 50 | + run: yarn tron:compile |
| 51 | + |
| 52 | + - name: Verify build artifacts exist |
| 53 | + working-directory: packages/smart-contracts |
| 54 | + run: | |
| 55 | + echo "Checking build artifacts..." |
| 56 | + ls -la tron-build/ |
| 57 | +
|
| 58 | + # Verify key contracts were compiled |
| 59 | + for contract in ERC20FeeProxy TestTRC20 BadTRC20 TRC20True TRC20NoReturn TRC20False TRC20Revert; do |
| 60 | + if [ ! -f "tron-build/${contract}.json" ]; then |
| 61 | + echo "ERROR: ${contract}.json not found!" |
| 62 | + exit 1 |
| 63 | + fi |
| 64 | + echo "✓ ${contract}.json exists" |
| 65 | + done |
| 66 | +
|
| 67 | + echo "✅ All required artifacts present" |
| 68 | +
|
| 69 | + - name: Verify contract ABI structure |
| 70 | + working-directory: packages/smart-contracts |
| 71 | + run: | |
| 72 | + echo "Verifying ERC20FeeProxy ABI..." |
| 73 | +
|
| 74 | + # Check that the compiled contract has the expected functions |
| 75 | + for func in transferFromWithReferenceAndFee; do |
| 76 | + if ! grep -q "$func" tron-build/ERC20FeeProxy.json; then |
| 77 | + echo "ERROR: ERC20FeeProxy missing $func function!" |
| 78 | + exit 1 |
| 79 | + fi |
| 80 | + echo "✓ ERC20FeeProxy has $func" |
| 81 | + done |
| 82 | +
|
| 83 | + # Verify TestTRC20 has standard ERC20 functions |
| 84 | + for func in transfer approve transferFrom balanceOf allowance; do |
| 85 | + if ! grep -q "$func" tron-build/TestTRC20.json; then |
| 86 | + echo "ERROR: TestTRC20 missing $func function!" |
| 87 | + exit 1 |
| 88 | + fi |
| 89 | + echo "✓ TestTRC20 has $func" |
| 90 | + done |
| 91 | +
|
| 92 | + echo "✅ Contract ABI structure verified" |
| 93 | +
|
| 94 | + - name: Verify deployment files are valid JSON |
| 95 | + working-directory: packages/smart-contracts |
| 96 | + run: | |
| 97 | + echo "Validating deployment files..." |
| 98 | +
|
| 99 | + for network in nile mainnet; do |
| 100 | + file="tron/deployments/${network}.json" |
| 101 | + if [ -f "$file" ]; then |
| 102 | + if ! python3 -m json.tool "$file" > /dev/null 2>&1; then |
| 103 | + echo "ERROR: $file is not valid JSON!" |
| 104 | + exit 1 |
| 105 | + fi |
| 106 | + |
| 107 | + # Verify required fields |
| 108 | + if ! grep -q '"ERC20FeeProxy"' "$file"; then |
| 109 | + echo "ERROR: $file missing ERC20FeeProxy entry!" |
| 110 | + exit 1 |
| 111 | + fi |
| 112 | + |
| 113 | + if ! grep -q '"address"' "$file"; then |
| 114 | + echo "ERROR: $file missing address field!" |
| 115 | + exit 1 |
| 116 | + fi |
| 117 | + |
| 118 | + echo "✓ $file is valid" |
| 119 | + fi |
| 120 | + done |
| 121 | +
|
| 122 | + echo "✅ Deployment files validated" |
| 123 | +
|
| 124 | + tron-payment-processor-tests: |
| 125 | + name: Tron Payment Processor Unit Tests |
| 126 | + runs-on: ubuntu-latest |
| 127 | + |
| 128 | + steps: |
| 129 | + - name: Checkout repository |
| 130 | + uses: actions/checkout@v4 |
| 131 | + |
| 132 | + - name: Setup Node.js |
| 133 | + uses: actions/setup-node@v4 |
| 134 | + with: |
| 135 | + node-version: '22' |
| 136 | + cache: 'yarn' |
| 137 | + |
| 138 | + - name: Install dependencies |
| 139 | + run: yarn install --frozen-lockfile |
| 140 | + |
| 141 | + - name: Build dependencies |
| 142 | + run: | |
| 143 | + yarn workspace @requestnetwork/types build |
| 144 | + yarn workspace @requestnetwork/utils build |
| 145 | + yarn workspace @requestnetwork/currency build |
| 146 | + yarn workspace @requestnetwork/smart-contracts build |
| 147 | + yarn workspace @requestnetwork/payment-detection build |
| 148 | +
|
| 149 | + - name: Run Tron payment processor tests |
| 150 | + working-directory: packages/payment-processor |
| 151 | + run: yarn test -- --testPathPattern="tron" --passWithNoTests |
| 152 | + |
| 153 | + tron-artifact-registry-check: |
| 154 | + name: Tron Artifact Registry Check |
| 155 | + runs-on: ubuntu-latest |
| 156 | + |
| 157 | + steps: |
| 158 | + - name: Checkout repository |
| 159 | + uses: actions/checkout@v4 |
| 160 | + |
| 161 | + - name: Setup Node.js |
| 162 | + uses: actions/setup-node@v4 |
| 163 | + with: |
| 164 | + node-version: '22' |
| 165 | + cache: 'yarn' |
| 166 | + |
| 167 | + - name: Install dependencies |
| 168 | + run: yarn install --frozen-lockfile |
| 169 | + |
| 170 | + - name: Build smart-contracts package |
| 171 | + run: | |
| 172 | + yarn workspace @requestnetwork/types build |
| 173 | + yarn workspace @requestnetwork/utils build |
| 174 | + yarn workspace @requestnetwork/currency build |
| 175 | + yarn workspace @requestnetwork/smart-contracts build |
| 176 | +
|
| 177 | + - name: Verify Tron addresses in artifact registry |
| 178 | + run: | |
| 179 | + echo "Checking Tron addresses in artifact registry..." |
| 180 | +
|
| 181 | + # Check that nile address is registered |
| 182 | + if ! grep -q "THK5rNmrvCujhmrXa5DB1dASepwXTr9cJs" packages/smart-contracts/src/lib/artifacts/ERC20FeeProxy/index.ts; then |
| 183 | + echo "ERROR: Nile testnet address not found in artifact registry!" |
| 184 | + exit 1 |
| 185 | + fi |
| 186 | + echo "✓ Nile address registered" |
| 187 | +
|
| 188 | + # Check that mainnet address is registered |
| 189 | + if ! grep -q "TCUDPYnS9dH3WvFEaE7wN7vnDa51J4R4fd" packages/smart-contracts/src/lib/artifacts/ERC20FeeProxy/index.ts; then |
| 190 | + echo "ERROR: Mainnet address not found in artifact registry!" |
| 191 | + exit 1 |
| 192 | + fi |
| 193 | + echo "✓ Mainnet address registered" |
| 194 | +
|
| 195 | + echo "✅ Tron addresses verified in artifact registry" |
| 196 | +
|
| 197 | +# Note: Full integration tests require a Tron node and are skipped in CI. |
| 198 | +# Run integration tests locally with: |
| 199 | +# docker run -d --name tron-tre -p 9090:9090 tronbox/tre # On ARM64 machine |
| 200 | +# yarn tron:test |
| 201 | +# Or run against Nile testnet: |
| 202 | +# TRON_PRIVATE_KEY=your_key yarn tron:test:nile |
0 commit comments