Skip to content

Commit fd1c11a

Browse files
committed
feat: fully automated manual test
1 parent e67751f commit fd1c11a

File tree

4 files changed

+46
-19
lines changed

4 files changed

+46
-19
lines changed

test-manual/Makefile

Lines changed: 39 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,37 +7,59 @@ list:
77
@LC_ALL=C $(MAKE) -pRrq -f $(firstword $(MAKEFILE_LIST)) : 2>/dev/null | awk -v RS= -F: '/(^|\n)# Files(\n|$$)/,/(^|\n)# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' | sort | egrep -v -e '^[^[:alnum:]]' -e '^$@$$'
88

99
manual-test-laser:
10-
@echo "Preparing for laser test..."
10+
@echo "Checking for Helius API key"
1111
@if [ -z "$$HELIUS_API_KEY" ]; then \
1212
echo "Error: HELIUS_API_KEY environment variable not set"; \
1313
exit 1; \
1414
fi
15-
@echo "Extracting keypair path..."
15+
@echo
16+
@echo "## Extracting keypair path..."
1617
$(eval KEYPAIR_PATH := $(shell solana config get | grep "Keypair Path:" | cut -d: -f2 | xargs))
1718
@echo "Keypair path: $(KEYPAIR_PATH)"
18-
@echo "Extracting pubkey..."
19+
@echo
20+
@echo "## Airdropping 1 SOL to pubkey on devnet"
1921
$(eval PUBKEY := $(shell solana-keygen pubkey $(KEYPAIR_PATH)))
2022
@echo "Pubkey: $(PUBKEY)"
2123
@echo "Airdropping 1 SOL to $(PUBKEY)..."
2224
@solana airdrop 1 $(PUBKEY) --url devnet || true
23-
@echo "Creating validator config..."
25+
@echo
26+
@echo "## Creating validator config..."
2427
@echo "[accounts]" > /tmp/mb-test-laser.toml
2528
@echo "remote.url = \"https://devnet.helius-rpc.com/?api-key=$(HELIUS_API_KEY)\"" >> /tmp/mb-test-laser.toml
2629
@echo "remote.ws-url = [\"https://laserstream-devnet-ewr.helius-rpc.com?api-key=$(HELIUS_API_KEY)\"]" >> /tmp/mb-test-laser.toml
2730
@echo "" >> /tmp/mb-test-laser.toml
2831
@echo "[rpc]" >> /tmp/mb-test-laser.toml
2932
@echo "addr = \"0.0.0.0\"" >> /tmp/mb-test-laser.toml
30-
@echo "port = 8899" >> /tmp/mb-test-laser.toml
31-
@echo "Starting validator in background..."
32-
RUST_LOG=magicblock_chainlink=debug,magicblock_accounts=debug \
33-
cargo run --bin magicblock-validator -- \
34-
--config /tmp/mb-test-laser.toml --ephemeral \
35-
> /tmp/validator.log 2>&1 &
33+
@echo "port = 9988" >> /tmp/mb-test-laser.toml
34+
@echo
35+
@echo "## Starting validator in background..."
36+
RUST_LOG=warn,magicblock=info,magicblock_chainlink=debug,magicblock_accounts=debug \
37+
cargo run --bin magicblock-validator --manifest-path=$(DIR)../Cargo.toml \
38+
-- --ledger-resume-strategy-kind=reset \
39+
-- /tmp/mb-test-laser.toml \
40+
> /tmp/validator.log 2>&1 &
3641
@echo $$! > /tmp/validator.pid
37-
@sleep 3
38-
@echo "Running laser test..."
39-
cd helius-laser && KEYPAIR_PATH=$(KEYPAIR_PATH) RUST_LOG=info cargo run
40-
@echo "Validator logs:"
41-
@cat /tmp/validator.log || true
42-
@echo "Cleaning up validator..."
43-
@if [ -f /tmp/validator.pid ]; then kill $$(cat /tmp/validator.pid) 2>/dev/null || true; rm /tmp/validator.pid /tmp/validator.log; fi
42+
@echo
43+
@echo "### Waiting until validator listens on port 9988... via solana cluster-version"
44+
@until solana cluster-version --url http://127.0.0.1:9988 >/dev/null 2>&1; do \
45+
sleep 1; \
46+
done
47+
@echo
48+
@echo "## Running laser test..."
49+
KEYPAIR_PATH=$(KEYPAIR_PATH) \
50+
RUST_LOG=info \
51+
cargo run --bin helius-laser
52+
@echo
53+
@if [ $$? -ne 0 ]; then \
54+
echo "## Laser test failed, showing validator logs"; \
55+
cat /tmp/validator.log || true; \
56+
echo "⛔ TEST FAILED"; \
57+
else \
58+
echo "✅ TEST PASSED"; \
59+
fi
60+
@echo
61+
@if [ -f /tmp/validator.pid ]; then \
62+
echo "## Shutting down validator"; \
63+
kill $$(cat /tmp/validator.pid) 2>/dev/null || true; \
64+
rm /tmp/validator.pid /tmp/validator.log ; \
65+
fi

test-manual/helius-laser/src/main.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,13 +105,13 @@ async fn main() -> Result<()> {
105105
let rpc_endpoint =
106106
format!("https://devnet.helius-rpc.com/?api-key={}", helius_api_key);
107107

108-
info!("Connecting to Helius devnet and localhost:8899");
108+
info!("Connecting to Helius devnet and localhost:9988");
109109
let remote_rpc_client = RpcClient::new_with_commitment(
110110
rpc_endpoint,
111111
CommitmentConfig::confirmed(),
112112
);
113113
let local_rpc_client = RpcClient::new_with_commitment(
114-
"http://127.0.0.1:8899",
114+
"http://127.0.0.1:9988",
115115
CommitmentConfig::confirmed(),
116116
);
117117

test-manual/rustfmt-nightly.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
max_width = 80
2+
imports_granularity = "Crate"
3+
group_imports = "StdExternalCrate"

test-manual/rustfmt.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
max_width = 80
2+
edition = "2021"

0 commit comments

Comments
 (0)