Skip to content

Commit 87350cd

Browse files
durbin
1 parent e87aa5b commit 87350cd

29 files changed

+6132
-193
lines changed

.env.test.example

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Test Environment Configuration for SaintDurbin Integration Tests
2+
# Copy this file to .env.test and update values as needed
3+
4+
# Contract Configuration
5+
SAINT_DURBIN_ADDRESS=0x0000000000000000000000000000000000000000
6+
EMERGENCY_OPERATOR=0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266
7+
DRAIN_SS58_ADDRESS=0x0000000000000000000000000000000000000000000000000000000000000001
8+
9+
# Network Configuration
10+
RPC_URL=http://127.0.0.1:9944
11+
CHAIN_ENDPOINT=ws://127.0.0.1:9944
12+
13+
# Test Account Keys (DO NOT USE IN PRODUCTION)
14+
# Alice - Deployer
15+
PRIVATE_KEY=0x5fb92d6e98884f76de468fa3f6278f8807c48bebc13595d45af5bdc4da702133
16+
# Bob - Test Account 1
17+
TEST_PRIVATE_KEY_1=0x8075991ce870b93a8870eca0c0f91913d12f47948ca0fd25b49c6fa7cdbeee8b
18+
# Charlie - Test Account 2
19+
TEST_PRIVATE_KEY_2=0x0b6e18cafb6ed99687ec547bd28139cafdd2bffe70e6b688025de6b445aa5c5b
20+
21+
# Validator Configuration
22+
VALIDATOR_HOTKEY=0x0000000000000000000000000000000000000000000000000000000000000002
23+
VALIDATOR_UID=0
24+
THIS_SS58_PUBLIC_KEY=0x0000000000000000000000000000000000000000000000000000000000000003
25+
NETUID=0
26+
27+
# Mock Services
28+
# (No external services required)
29+
30+
# Test Configuration
31+
NODE_ENV=test
32+
LOG_LEVEL=debug

.github/workflows/distribute-yields.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323

2424
- name: Install dependencies
2525
run: |
26-
cd script
26+
cd scriptr
2727
npm install
2828
2929
- name: Run distribution
Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
name: SaintDurbin Integration Tests
2+
3+
on:
4+
push:
5+
branches: [ main, develop ]
6+
pull_request:
7+
branches: [ main, develop ]
8+
9+
jobs:
10+
foundry-tests:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
15+
- name: Install Foundry
16+
uses: foundry-rs/foundry-toolchain@v1
17+
with:
18+
version: nightly
19+
20+
- name: Run Foundry tests
21+
run: forge test -vvv
22+
23+
- name: Check contract compilation
24+
run: forge build --sizes
25+
26+
javascript-integration-tests:
27+
runs-on: ubuntu-latest
28+
needs: foundry-tests
29+
steps:
30+
- name: Checkout code
31+
uses: actions/checkout@v4
32+
with:
33+
submodules: recursive
34+
35+
- name: Set up Node.js
36+
uses: actions/setup-node@v4
37+
with:
38+
node-version: '20'
39+
cache: 'npm'
40+
cache-dependency-path: 'scripts/package-lock.json'
41+
42+
- name: Install Rust toolchain
43+
uses: dtolnay/rust-toolchain@stable
44+
with:
45+
toolchain: stable
46+
components: rustfmt, clippy
47+
48+
- name: Install Foundry
49+
uses: foundry-rs/foundry-toolchain@v1
50+
with:
51+
version: nightly
52+
53+
- name: Cache Cargo dependencies
54+
uses: actions/cache@v3
55+
with:
56+
path: |
57+
~/.cargo/bin/
58+
~/.cargo/registry/index/
59+
~/.cargo/registry/cache/
60+
~/.cargo/git/db/
61+
subtensor_chain/target/
62+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}-${{ hashFiles('subtensor_chain/Cargo.lock') }}
63+
restore-keys: |
64+
${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}-
65+
${{ runner.os }}-cargo-
66+
67+
- name: Install system dependencies
68+
run: |
69+
sudo apt-get update
70+
sudo apt-get install -y build-essential clang libclang-dev libssl-dev pkg-config protobuf-compiler
71+
72+
- name: Setup test environment
73+
run: |
74+
# Create test environment file
75+
cat > .env.test << EOF
76+
SAINT_DURBIN_ADDRESS=0x0000000000000000000000000000000000000000
77+
PRIVATE_KEY=0x5fb92d6e98884f76de468fa3f6278f8807c48bebc13595d45af5bdc4da702133
78+
RPC_URL=http://127.0.0.1:9944
79+
CHAIN_ENDPOINT=ws://127.0.0.1:9944
80+
EOF
81+
82+
# Make integration test script executable
83+
chmod +x ./run-integration-tests.sh
84+
85+
- name: Install JavaScript dependencies
86+
working-directory: scripts
87+
run: |
88+
npm ci || npm install
89+
npm install --save-dev mocha chai sinon @polkadot/api
90+
91+
- name: Run unit tests only
92+
working-directory: scripts
93+
run: npm test
94+
env:
95+
NODE_ENV: test
96+
97+
# Note: Full integration tests with local chain would run here
98+
# but are commented out as they require significant setup time
99+
# - name: Run Integration Test Script
100+
# run: ./run-integration-tests.sh
101+
# timeout-minutes: 30
102+
103+
contract-security:
104+
runs-on: ubuntu-latest
105+
steps:
106+
- uses: actions/checkout@v4
107+
108+
- name: Install Foundry
109+
uses: foundry-rs/foundry-toolchain@v1
110+
with:
111+
version: nightly
112+
113+
- name: Run Slither
114+
uses: crytic/slither-action@v0.3.0
115+
continue-on-error: true
116+
with:
117+
target: 'src/'
118+
slither-args: '--compile-force-framework foundry'
119+
120+
- name: Run Aderyn
121+
shell: bash
122+
run: |
123+
# Install aderyn
124+
cargo install aderyn
125+
# Run security analysis
126+
aderyn . || true
127+
128+
deployment-test:
129+
runs-on: ubuntu-latest
130+
needs: [foundry-tests, javascript-integration-tests]
131+
steps:
132+
- uses: actions/checkout@v4
133+
134+
- name: Install Foundry
135+
uses: foundry-rs/foundry-toolchain@v1
136+
with:
137+
version: nightly
138+
139+
- name: Test deployment script
140+
run: |
141+
# Test that deployment script compiles and dry-runs successfully
142+
forge script script/DeploySaintDurbin.s.sol:DeploySaintDurbin --fork-url ${{ secrets.BITTENSOR_RPC_URL || 'http://127.0.0.1:9944' }}
143+
env:
144+
EMERGENCY_OPERATOR: "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266"
145+
DRAIN_SS58_ADDRESS: "0x0000000000000000000000000000000000000000000000000000000000000001"
146+
VALIDATOR_HOTKEY: "0x0000000000000000000000000000000000000000000000000000000000000002"
147+
VALIDATOR_UID: "0"
148+
THIS_SS58_PUBLIC_KEY: "0x0000000000000000000000000000000000000000000000000000000000000003"
149+
NETUID: "0"

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,6 @@ Thumbs.db
3636
lcov.info
3737
coverage/
3838

39-
lib/
39+
lib/
40+
41+
subtensor*

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "subtensor_chain"]
2+
path = subtensor_chain
3+
url = https://github.com/opentensor/subtensor.git

0 commit comments

Comments
 (0)