-
Notifications
You must be signed in to change notification settings - Fork 58
Expand file tree
/
Copy pathMakefile
More file actions
135 lines (116 loc) · 4.63 KB
/
Copy pathMakefile
File metadata and controls
135 lines (116 loc) · 4.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
## OrbitChain Makefile
## make build - Compile contracts
## make test - Run all tests
## make audit - Run cargo audit
## make deny - Check licenses
## make fmt - Format code
## make clippy - Lint code
.PHONY: build build-wasm build-tools test fmt lint clean optimize help e2e \
setup deploy-testnet deploy-sandbox sandbox-start audit deny fuzz
# Default target
build: build-wasm build-tools
@echo "✅ Build complete"
# Build WASM contract
build-wasm:
@echo "🔨 Building Soroban contract..."
cargo build -p orbitchain-core -p orbitchain-campaign -p orbitchain-token-bridge -p orbitchain-batch-donor -p orbitchain-common --target wasm32v1-none --release
@echo "✅ WASM contracts built successfully"
# Build CLI tools
build-tools:
@echo "🔨 Building CLI tools..."
cargo build -p orbitchain-tools
@echo "✅ CLI tools built successfully"
# Run tests
test:
@echo "🧪 Running tests..."
cargo test --workspace
@echo "✅ Tests passed"
# Format code
fmt:
@echo "🎨 Formatting code..."
cargo fmt --all
@echo "✅ Code formatted"
# Run linter
lint:
@echo "🔍 Running linter..."
cargo clippy --workspace -- -D warnings
@echo "✅ Linting passed"
# Clean build artifacts
clean:
@echo "🧹 Cleaning build artifacts..."
cargo clean
@echo "✅ Clean complete"
# Install soroban-cli and required Rust targets
setup:
@echo "🔧 Installing soroban-cli..."
cargo install --locked stellar-cli --features opt
@echo "🔧 Adding wasm32v1-none target..."
rustup target add wasm32v1-none
@echo "✅ Setup complete. Run 'make build' to compile contracts."
# Start local sandbox (requires Docker)
sandbox-start:
@echo "🐳 Starting local Stellar sandbox..."
docker run --rm -d \
--name stellar-sandbox \
-p 8000:8000 \
stellar/quickstart:testing \
--standalone \
--enable-soroban-rpc
@echo "✅ Sandbox running at http://localhost:8000"
@echo " RPC endpoint: http://localhost:8000/soroban/rpc"
# Deploy to local sandbox
deploy-sandbox: build-wasm
@echo "🚀 Deploying to local sandbox..."
bash scripts/deploy.sh sandbox
# Deploy to Stellar testnet
deploy-testnet: build-wasm
@echo "🚀 Deploying to testnet..."
bash scripts/deploy.sh testnet
# End-to-end sandbox lifecycle test: boots stellar/quickstart in Docker,
# deploys orbitchain-campaign, and walks init → donate → unlock → release
# with a real token transfer (issue #116). `bash e2e/run_e2e.sh futurenet`
# runs the same lifecycle against Futurenet without Docker.
e2e:
@echo "🧪 Running end-to-end sandbox lifecycle test..."
bash e2e/run_e2e.sh local
# Run cargo-audit for vulnerability scanning
audit:
@echo "🔒 Running security audit..."
cargo audit
@echo "✅ Security audit passed"
# Run cargo-deny for license compliance
deny:
@echo "📋 Checking license compliance..."
cargo deny check
@echo "✅ License check passed"
# Run cargo-fuzz smoke tests (60s each target)
fuzz:
@echo "🔬 Running fuzz smoke tests..."
@cd fuzz && cargo fuzz run fuzz_donate -- -max_total_time=60 || true
@cd fuzz && cargo fuzz run fuzz_initialize -- -max_total_time=60 || true
@cd fuzz && cargo fuzz run fuzz_release_milestone -- -max_total_time=60 || true
@cd fuzz && cargo fuzz run fuzz_claim_refund -- -max_total_time=60 || true
@echo "✅ Fuzz smoke tests complete"
# Optimize WASM binaries using wasm-opt (-Oz)
optimize: build
@echo "🔧 Optimizing WASM binaries with wasm-opt..."
@for wasm in target/wasm32v1-none/release/*.wasm; do before=$$(wc -c < "$$wasm"); wasm-opt -Oz "$$wasm" -o "$$wasm.opt" && mv "$$wasm.opt" "$$wasm"; after=$$(wc -c < "$$wasm"); echo " $$(basename $$wasm): $${before}B -> $${after}B"; done
@echo "✅ Optimization complete"
# Show help
help:
@echo "Available commands:"
@echo " make setup - Install soroban-cli and required Rust targets"
@echo " make build - Build WASM contract and CLI tools"
@echo " make build-wasm - Build Soroban WASM contract only"
@echo " make build-tools - Build CLI tools only"
@echo " make test - Run all tests"
@echo " make fmt - Format code"
@echo " make lint - Run linter"
@echo " make clean - Clean build artifacts"
@echo " make sandbox-start - Start local Stellar sandbox (requires Docker)"
@echo " make deploy-sandbox - Deploy contract to local sandbox"
@echo " make deploy-testnet - Deploy contract to Stellar testnet"
@echo " make e2e - End-to-end sandbox lifecycle test (Docker)"
@echo " make optimize - Optimize WASM with wasm-opt -Oz"
@echo " make fuzz - Run fuzz smoke tests (60s per target)"
@echo " make help - Show this help message"