Skip to content

Commit bf7961e

Browse files
committed
fix tron ci test waiting for contract deployment
1 parent 0324fff commit bf7961e

40 files changed

Lines changed: 57115 additions & 6 deletions
Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
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+
- '.github/workflows/tron-smart-contracts.yml'
11+
push:
12+
branches:
13+
- master
14+
paths:
15+
- 'packages/smart-contracts/tron/**'
16+
- 'packages/smart-contracts/tronbox-config.js'
17+
workflow_dispatch:
18+
19+
jobs:
20+
tron-compile-check:
21+
name: Tron Contract Compilation Check
22+
runs-on: ubuntu-latest
23+
24+
steps:
25+
- name: Checkout repository
26+
uses: actions/checkout@v4
27+
28+
- name: Setup Node.js
29+
uses: actions/setup-node@v4
30+
with:
31+
node-version: '22'
32+
cache: 'yarn'
33+
34+
- name: Install TronBox globally
35+
run: npm install -g tronbox
36+
37+
- name: Install dependencies
38+
run: yarn install --frozen-lockfile
39+
40+
- name: Compile Tron contracts
41+
working-directory: packages/smart-contracts
42+
run: yarn tron:compile
43+
44+
- name: Verify build artifacts exist
45+
working-directory: packages/smart-contracts
46+
run: |
47+
echo "Checking build artifacts..."
48+
ls -la tron-build/
49+
50+
# Verify key contracts were compiled
51+
if [ ! -f "tron-build/ERC20FeeProxy.json" ]; then
52+
echo "ERROR: ERC20FeeProxy.json not found!"
53+
exit 1
54+
fi
55+
56+
if [ ! -f "tron-build/TestTRC20.json" ]; then
57+
echo "ERROR: TestTRC20.json not found!"
58+
exit 1
59+
fi
60+
61+
echo "✅ All required artifacts present"
62+
63+
tron-tests:
64+
name: Tron Contract Tests
65+
runs-on: ubuntu-latest
66+
needs: tron-compile-check
67+
68+
steps:
69+
- name: Checkout repository
70+
uses: actions/checkout@v4
71+
72+
- name: Set up QEMU for ARM64 emulation
73+
uses: docker/setup-qemu-action@v3
74+
with:
75+
platforms: arm64
76+
77+
- name: Setup Node.js
78+
uses: actions/setup-node@v4
79+
with:
80+
node-version: '22'
81+
cache: 'yarn'
82+
83+
- name: Install TronBox globally
84+
run: npm install -g tronbox
85+
86+
- name: Install dependencies
87+
run: yarn install --frozen-lockfile
88+
89+
- name: Start Tron Runtime Environment (ARM64 via QEMU)
90+
run: |
91+
docker run -d --name tron-tre \
92+
--platform linux/arm64 \
93+
-p 9090:9090 \
94+
tronbox/tre
95+
96+
echo "Waiting for Tron node to start (ARM64 emulation may be slow)..."
97+
sleep 30
98+
99+
- name: Wait for Tron node to be ready
100+
run: |
101+
echo "Waiting for Tron node..."
102+
for i in {1..90}; do
103+
if curl -s http://localhost:9090/wallet/getnowblock > /dev/null 2>&1; then
104+
echo "Tron node is ready!"
105+
exit 0
106+
fi
107+
echo "Attempt $i/90 - Tron node not ready yet..."
108+
sleep 5
109+
done
110+
echo "Tron node failed to start"
111+
docker logs tron-tre
112+
exit 1
113+
114+
- name: Compile Tron contracts
115+
working-directory: packages/smart-contracts
116+
run: yarn tron:compile
117+
118+
- name: Wait for blockchain to stabilize
119+
run: |
120+
echo "Waiting for blockchain to produce more blocks..."
121+
sleep 30
122+
123+
- name: Run Tron tests
124+
working-directory: packages/smart-contracts
125+
run: yarn tron:test
126+
env:
127+
CI: true
128+
129+
- name: Stop Tron container
130+
if: always()
131+
run: docker stop tron-tre || true
132+
133+
- name: Upload test artifacts
134+
if: failure()
135+
uses: actions/upload-artifact@v4
136+
with:
137+
name: tron-test-logs
138+
path: |
139+
packages/smart-contracts/tron-build/
140+
retention-days: 7
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
export const chainId = 'nile';
2+
3+
// Nile is Tron's test network
4+
export const testnet = true;
5+
6+
// Test tokens on Nile testnet
7+
// Note: These are testnet token addresses, not mainnet
8+
export const currencies = {
9+
// Add testnet token addresses as needed
10+
};
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,20 @@
11
export const chainId = 'tron';
2+
3+
// Tron mainnet configuration
4+
export const testnet = false;
5+
6+
// Common TRC20 tokens on Tron
7+
export const currencies = {
8+
// USDT-TRC20 - the most widely used stablecoin on Tron
9+
TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t: {
10+
name: 'Tether USD',
11+
symbol: 'USDT',
12+
decimals: 6,
13+
},
14+
// USDC on Tron
15+
TEkxiTehnzSmSe2XqrBj4w32RUN966rdz8: {
16+
name: 'USD Coin',
17+
symbol: 'USDC',
18+
decimals: 6,
19+
},
20+
};

packages/currency/src/chains/declarative/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { CurrencyTypes } from '@requestnetwork/types';
22

33
import * as TronDefinition from './data/tron';
4+
import * as NileDefinition from './data/nile';
45
import * as SolanaDefinition from './data/solana';
56
import * as StarknetDefinition from './data/starknet';
67
import * as TonDefinition from './data/ton';
@@ -11,6 +12,7 @@ export type DeclarativeChain = CurrencyTypes.Chain;
1112

1213
export const chains: Record<CurrencyTypes.DeclarativeChainName, DeclarativeChain> = {
1314
tron: TronDefinition,
15+
nile: NileDefinition,
1416
solana: SolanaDefinition,
1517
starknet: StarknetDefinition,
1618
ton: TonDefinition,
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import BtcChains from './btc/BtcChains';
22
import EvmChains from './evm/EvmChains';
33
import NearChains from './near/NearChains';
4+
import TronChains from './tron/TronChains';
45
import DeclarativeChains from './declarative/DeclarativeChains';
56
import { isSameChain } from './utils';
67

7-
export { BtcChains, EvmChains, NearChains, DeclarativeChains, isSameChain };
8+
export { BtcChains, EvmChains, NearChains, TronChains, DeclarativeChains, isSameChain };
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { ChainsAbstract } from '../ChainsAbstract';
2+
import { CurrencyTypes, RequestLogicTypes } from '@requestnetwork/types';
3+
import { TronChain, chains } from './index';
4+
5+
class TronChains extends ChainsAbstract<CurrencyTypes.TronChainName, TronChain, string> {}
6+
export default new TronChains(chains, RequestLogicTypes.CURRENCY.ETH);
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { CurrencyTypes } from '@requestnetwork/types';
2+
3+
import * as TronDefinition from '../declarative/data/tron';
4+
import * as NileDefinition from '../declarative/data/nile';
5+
6+
export type TronChain = CurrencyTypes.Chain;
7+
8+
export const chains: Record<CurrencyTypes.TronChainName, TronChain> = {
9+
tron: TronDefinition,
10+
nile: NileDefinition,
11+
};

packages/payment-processor/src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ export * from './payment/encoder-approval';
2828
export * as Escrow from './payment/erc20-escrow-payment';
2929
export * from './payment/prepared-transaction';
3030
export * from './payment/utils-near';
31+
export * from './payment/utils-tron';
32+
export * from './payment/tron-fee-proxy';
3133
export * from './payment/single-request-forwarder';
3234
export * from './payment/erc20-recurring-payment-proxy';
3335
export * from './payment/erc20-commerce-escrow-wrapper';

0 commit comments

Comments
 (0)