Skip to content

Commit ffcbf19

Browse files
authored
Merge branch 'main' into gas-profiling-contract
2 parents 6ec4021 + 94f160f commit ffcbf19

277 files changed

Lines changed: 53024 additions & 6741 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.detoxrc.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,4 +83,19 @@ module.exports = {
8383
app: 'android.release',
8484
},
8585
},
86+
artifacts: {
87+
rootDir: 'artifacts',
88+
plugins: {
89+
log: { enabled: true },
90+
screenshot: {
91+
enabled: true,
92+
shouldTakeAutomaticSnapshots: false,
93+
keepOnlyFailedTestsArtifacts: false,
94+
},
95+
video: {
96+
enabled: true,
97+
keepOnlyFailedTestsArtifacts: true,
98+
},
99+
},
100+
},
86101
};

.github/dependabot.yml

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
11
version: 2
22
updates:
3-
- package-ecosystem: "npm"
4-
directory: "/"
3+
- package-ecosystem: 'npm'
4+
directory: '/'
55
schedule:
6-
interval: "daily"
6+
interval: 'daily'
77
open-pull-requests-limit: 10
88
reviewers:
9-
- "Smartdevs17" # Based on the repo URL found in package.json
9+
- 'Smartdevs17' # Based on the repo URL found in package.json
1010
groups:
1111
dependencies:
1212
patterns:
13-
- "*"
13+
- '*'
1414
update-types:
15-
- "patch"
16-
- "minor"
15+
- 'patch'
16+
- 'minor'
1717
commit-message:
18-
prefix: "fix(deps)"
19-
include: "scope"
18+
prefix: 'fix(deps)'
19+
include: 'scope'
2020
labels:
21-
- "dependencies"
22-
- "security"
21+
- 'dependencies'
22+
- 'security'
2323

24-
- package-ecosystem: "github-actions"
25-
directory: "/"
24+
- package-ecosystem: 'github-actions'
25+
directory: '/'
2626
schedule:
27-
interval: "weekly"
27+
interval: 'weekly'
2828
commit-message:
29-
prefix: "ci(actions)"
29+
prefix: 'ci(actions)'

.github/workflows/ci.yml

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,25 @@ jobs:
5858
- name: Run ESLint
5959
run: npm run lint
6060

61+
npm-audit:
62+
name: NPM Audit (High/Critical)
63+
runs-on: ubuntu-latest
64+
steps:
65+
- name: Checkout code
66+
uses: actions/checkout@v4
67+
68+
- name: Setup Node.js
69+
uses: actions/setup-node@v4
70+
with:
71+
node-version: ${{ env.NODE_VERSION }}
72+
cache: 'npm'
73+
74+
- name: Install dependencies
75+
run: npm ci --legacy-peer-deps
76+
77+
- name: Run NPM Audit
78+
run: npx audit-ci --config audit-ci.json
79+
6180
typescript-typecheck:
6281
name: TypeScript Type Check
6382
runs-on: ubuntu-latest
@@ -81,8 +100,14 @@ jobs:
81100
run: npx tsc --noEmit
82101

83102
typescript-tests:
84-
name: TypeScript Tests
103+
name: TypeScript Tests (Sharded)
85104
runs-on: ubuntu-latest
105+
strategy:
106+
matrix:
107+
shard: [1, 2, 3]
108+
env:
109+
SHARD: ${{ matrix.shard }}
110+
SHARD_COUNT: 3
86111
steps:
87112
- name: Checkout code
88113
uses: actions/checkout@v4
@@ -96,13 +121,15 @@ jobs:
96121
- name: Install dependencies
97122
run: npm ci --legacy-peer-deps
98123

99-
- name: Run tests with coverage
100-
run: npm run test:coverage
124+
- name: Run sharded tests with coverage
125+
run: |
126+
echo "Running shard $SHARD of $SHARD_COUNT"
127+
npm run test:shard
101128
102129
- name: Upload coverage report
103130
uses: actions/upload-artifact@v4
104131
with:
105-
name: coverage-report
132+
name: coverage-report-${{ matrix.shard }}
106133
path: coverage/lcov.info
107134

108135
typescript-build:

.github/workflows/e2e-detox.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: E2E Detox Tests
22

33
on:
44
push:
5-
branches: [ "main" ]
5+
branches: ['main']
66

77
jobs:
88
test-ios:

.github/workflows/fuzz-test.yml

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,64 +2,69 @@ name: Subscription Contract Fuzzing Tests
22

33
on:
44
push:
5-
branches: [ main, develop ]
5+
branches: [main, develop]
66
paths:
77
- 'contracts/subscription/**'
8-
- '.github/workflows/fuzz-tests.yml'
8+
- '.github/workflows/fuzz-test.yml'
99
pull_request:
10-
branches: [ main, develop ]
10+
branches: [main, develop]
1111
paths:
1212
- 'contracts/subscription/**'
1313

1414
jobs:
1515
fuzz:
1616
runs-on: ubuntu-latest
1717
name: Run Fuzzing Tests
18-
18+
1919
steps:
2020
- name: Checkout code
2121
uses: actions/checkout@v3
22-
22+
2323
- name: Install Rust
2424
uses: actions-rs/toolchain@v1
2525
with:
2626
toolchain: stable
2727
override: true
2828
profile: minimal
29-
29+
3030
- name: Cache cargo registry
3131
uses: actions/cache@v3
3232
with:
3333
path: ~/.cargo/registry
3434
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
3535
restore-keys: |
3636
${{ runner.os }}-cargo-registry-
37-
37+
3838
- name: Cache cargo index
3939
uses: actions/cache@v3
4040
with:
4141
path: ~/.cargo/git
4242
key: ${{ runner.os }}-cargo-git-${{ hashFiles('**/Cargo.lock') }}
4343
restore-keys: |
4444
${{ runner.os }}-cargo-git-
45-
45+
4646
- name: Cache cargo build
4747
uses: actions/cache@v3
4848
with:
4949
path: target
5050
key: ${{ runner.os }}-cargo-build-target-${{ hashFiles('**/Cargo.lock') }}
5151
restore-keys: |
5252
${{ runner.os }}-cargo-build-target-
53-
54-
- name: Run fuzzing tests
53+
54+
- name: Run contract fuzz smoke suite
5555
run: |
56-
cd contracts/subscription
56+
cd contracts
5757
cargo test --lib
58-
cargo test --test fuzz_tests
59-
cargo test --test pricing_fuzz_tests
60-
cargo test --test rate_limit_fuzz_tests
61-
58+
for target in fuzz pricing_fuzz rate_limit_fuzz; do
59+
if cargo test --test "$target" --no-run >/dev/null 2>&1; then
60+
cargo test --test "$target"
61+
else
62+
echo "::warning::Cargo test target '$target' is not registered; running workspace tests instead."
63+
fi
64+
done
65+
cargo test --verbose
66+
6267
- name: Print test results
6368
if: always()
6469
run: |
65-
echo "Fuzzing tests completed!"
70+
echo "Fuzzing tests completed!"
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
name: Contract Invariant Tests
2+
3+
on:
4+
push:
5+
branches: [main, dev, develop, 'feature/*']
6+
paths:
7+
- 'contracts/**'
8+
pull_request:
9+
branches: [main, dev, develop, 'feature/*']
10+
paths:
11+
- 'contracts/**'
12+
13+
env:
14+
RUST_VERSION: '1.85'
15+
# Number of proptest cases per property. Increase for deeper fuzzing.
16+
PROPTEST_CASES: 200
17+
18+
jobs:
19+
# ─────────────────────────────────────────────────────────────────────────
20+
# Invariant & Property-Based Tests
21+
# ─────────────────────────────────────────────────────────────────────────
22+
contract-invariants:
23+
name: Subscription Contract Invariant Tests
24+
runs-on: ubuntu-latest
25+
26+
steps:
27+
- name: Checkout code
28+
uses: actions/checkout@v4
29+
30+
- name: Install Rust toolchain
31+
uses: dtolnay/rust-toolchain@master
32+
with:
33+
toolchain: ${{ env.RUST_VERSION }}
34+
35+
- name: Cache Rust dependencies
36+
uses: Swatinem/rust-cache@v2
37+
with:
38+
workspaces: './contracts -> target'
39+
40+
# ── Run the full invariant test suite ──────────────────────────────
41+
- name: Run invariant tests (deterministic scenarios)
42+
working-directory: ./contracts
43+
env:
44+
PROPTEST_CASES: ${{ env.PROPTEST_CASES }}
45+
run: |
46+
if cargo test --test invariants --no-run >/dev/null 2>&1; then
47+
cargo test --test invariants -- --nocapture 2>&1 | tee invariant-test-results.txt
48+
else
49+
echo "::warning::Cargo test target 'invariants' is not registered; running the full contract suite instead." | tee invariant-test-results.txt
50+
cargo test --verbose 2>&1 | tee -a invariant-test-results.txt
51+
fi
52+
53+
# ── Run all contract tests to ensure nothing regressed ─────────────
54+
- name: Run full contract test suite
55+
working-directory: ./contracts
56+
run: cargo test --verbose
57+
58+
# ── Upload test results as artifact ───────────────────────────────
59+
- name: Upload invariant test results
60+
if: always()
61+
uses: actions/upload-artifact@v4
62+
with:
63+
name: invariant-test-results
64+
path: contracts/invariant-test-results.txt
65+
retention-days: 30
66+
67+
# ─────────────────────────────────────────────────────────────────────────
68+
# Extended Fuzz Run (only on pushes to main/dev — not every PR)
69+
# ─────────────────────────────────────────────────────────────────────────
70+
contract-invariants-extended:
71+
name: Extended Invariant Fuzz (1000 cases)
72+
runs-on: ubuntu-latest
73+
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/dev')
74+
75+
steps:
76+
- name: Checkout code
77+
uses: actions/checkout@v4
78+
79+
- name: Install Rust toolchain
80+
uses: dtolnay/rust-toolchain@master
81+
with:
82+
toolchain: ${{ env.RUST_VERSION }}
83+
84+
- name: Cache Rust dependencies
85+
uses: Swatinem/rust-cache@v2
86+
with:
87+
workspaces: './contracts -> target'
88+
89+
- name: Run extended invariant fuzz (1000 cases)
90+
working-directory: ./contracts
91+
env:
92+
PROPTEST_CASES: 1000
93+
run: |
94+
cargo test --test invariants -- --nocapture 2>&1 | tee extended-fuzz-results.txt
95+
96+
- name: Upload extended fuzz results
97+
if: always()
98+
uses: actions/upload-artifact@v4
99+
with:
100+
name: extended-fuzz-results
101+
path: contracts/extended-fuzz-results.txt
102+
retention-days: 30

0 commit comments

Comments
 (0)