Skip to content

Commit 3bf92cb

Browse files
fix: ci/cd tests (#76)
* fix: ci/cd tests * fix: ci/cd tests * fix: ci/cd tests * fix: ci/cd tests * fix: ci/cd tests * fix: ci/cd tests * fix: ci/cd tests - Wrap ephemeral-validator in a pty (python3) so its mandatory ratatui/crossterm TUI sees a controlling terminal; without one it silently exits 0 before binding port 7799, both in CI and when invoked from a non-tty bg job. - Move test endpoint env vars (PROVIDER_ENDPOINT, EPHEMERAL_PROVIDER_ENDPOINT, TEE_PROVIDER_ENDPOINT, ROUTER_ENDPOINT, WS variants) to the workflow step so the test runner doesn't fall back to devnet defaults. Tests read these directly; setting them inside fullstack-test.sh leaked project conventions into the script. - Set anchor-counter Anchor.toml cluster to "localnet" so the merge of main into this branch keeps localnet (was reverting to "devnet" via 3-way merge). - Commit private-/public-counter program keypairs and update .gitignore so deploy doesn't fail with DeclaredProgramIdMismatch on fresh clones; declare_id!() values now match the committed keypairs (no anchor keys sync needed). - fullstack-test.sh: wait for the upstream validator to be producing slots (commitment=processed) before starting ephemeral-validator; portable sed -E for slot extraction (BSD vs GNU); harden the kill of anchor's pre-flight validator with SIGTERM->SIGKILL and a port-free poll; honor --provider.cluster override from the anchor CLI; print mb-test-validator log on ephemeral failure with ANSI codes stripped. - Workflow: set kernel inotify limits ahead of time, raise nofile via prlimit in the same step as anchor test (prlimit on $$ doesn't propagate across GitHub Actions step shells). * fix: ci/cd tests - Tests construct wsEndpoint by replacing http:// → ws:// while keeping the RPC port. Solana convention uses RPC on port N and WS on N+1, so http://127.0.0.1:8899 was producing ws://127.0.0.1:8899 instead of ws://127.0.0.1:8900, leading to TransactionExpiredTimeoutError when sendAndConfirm couldn't subscribe for confirmation. - Honor explicit WS_ENDPOINT / EPHEMERAL_WS_ENDPOINT / TEE_WS_ENDPOINT env vars and fall back to undefined (web3.js auto-derive, which correctly bumps the port). - Workflow: pass the matching WS env vars so localnet runs subscribe to the right port. * fix: public counter
1 parent 55e0453 commit 3bf92cb

12 files changed

Lines changed: 175 additions & 100 deletions

File tree

‎.github/workflows/test-examples.yml‎

Lines changed: 9 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -49,48 +49,22 @@ jobs:
4949
solana config set --url localhost
5050
solana-keygen new --no-bip39-passphrase --silent --outfile ~/.config/solana/id.json
5151
52-
- name: Start Solana Test Validator
52+
- name: Configure Validator Limits
5353
run: |
54-
mb-test-validator \
55-
--ledger ./my-ledger-1 \
56-
--reset &
57-
58-
# Wait for validator to be ready
59-
timeout 30 bash -c 'until solana cluster-version --url http://localhost:8899 >/dev/null 2>&1; do sleep 1; done'
60-
61-
- name: Start MagicBlock Ephemeral Validator
62-
run: |
63-
# Magic voodoo to increase resource limits
64-
sudo prlimit --pid $$ --nofile=1048576:1048576
6554
sudo sysctl fs.inotify.max_user_instances=1280
6655
sudo sysctl fs.inotify.max_user_watches=655360
67-
RUST_LOG=info ephemeral-validator \
68-
--remotes "http://localhost:8899" \
69-
--remotes "ws://localhost:8900" \
70-
-l "7799" \
71-
--lifecycle ephemeral \
72-
> /tmp/ephemeral-validator.log 2>&1 &
73-
74-
# Wait for validator to be ready
75-
timeout 60 bash -c 'until curl -s http://localhost:7799 >/dev/null 2>&1; do sleep 1; done' || {
76-
echo "ephemeral-validator did not become ready within 60 seconds"
77-
echo "=== Last 100 lines of validator log ==="
78-
tail -100 /tmp/ephemeral-validator.log || true
79-
exit 1
80-
}
56+
8157
- name: Test anchor-counter
58+
env:
59+
PROVIDER_ENDPOINT: http://127.0.0.1:8899
60+
WS_ENDPOINT: ws://127.0.0.1:8900
61+
EPHEMERAL_PROVIDER_ENDPOINT: http://127.0.0.1:7799
62+
EPHEMERAL_WS_ENDPOINT: ws://127.0.0.1:7800
8263
run: |
64+
sudo prlimit --pid $$ --nofile=1048576:1048576
8365
cd anchor-counter
84-
anchor build && anchor deploy --provider.cluster localnet
8566
yarn install
86-
EPHEMERAL_PROVIDER_ENDPOINT="http://localhost:7799" \
87-
EPHEMERAL_WS_ENDPOINT="ws://localhost:7800" \
88-
PROVIDER_ENDPOINT=http://localhost:8899 \
89-
WS_ENDPOINT=http://localhost:8900 \
90-
anchor test \
91-
--provider.cluster localnet \
92-
--skip-local-validator \
93-
--skip-deploy
67+
anchor test --provider.cluster localnet
9468
9569
# - name: Test anchor-minter
9670
# run: |

‎.gitignore‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
**/.next/
1111
**/.env
1212
**/tsconfig.tsbuildinfo
13-
!/anchor-counter/target/deploy/anchor_counter-keypair.json
13+
!/anchor-counter/target/deploy/
14+
/anchor-counter/target/deploy/*
15+
!/anchor-counter/target/deploy/*-keypair.json
1416
!/bolt-counter/target/deploy/counter-keypair.json
1517
!/bolt-counter/target/deploy/increase-keypair.json
1618

‎anchor-counter/.gitignore‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
**/.next/
1111
**/.env
1212
**/magicblock-test-storage
13-
!/anchor-counter/target/deploy/anchor_counter-keypair.json
13+
!target/deploy/
14+
target/deploy/*
15+
!target/deploy/*-keypair.json
1416
!/bolt-counter/target/deploy/counter-keypair.json
1517
!/bolt-counter/target/deploy/increase-keypair.json
1618

‎anchor-counter/Anchor.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ skip-lint = false
99
url = "https://api.apr.dev"
1010

1111
[provider]
12-
cluster = "devnet"
12+
cluster = "localnet"
1313
wallet = "~/.config/solana/id.json"
1414

1515
[scripts]

‎anchor-counter/programs/private-counter/src/lib.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use ephemeral_rollups_sdk::consts::PERMISSION_PROGRAM_ID;
99
use ephemeral_rollups_sdk::cpi::DelegateConfig;
1010
use ephemeral_rollups_sdk::ephem::MagicIntentBundleBuilder;
1111

12-
declare_id!("91L33vBqfNaNfieqNCoqpxGZ2xVyJ29N3VcErR6LoepZ");
12+
declare_id!("7Y2rYVGqRY31m7ogMHjmtdRMUjeWakoJ6iVx12i6voCY");
1313

1414
pub const COUNTER_SEED: &[u8] = b"counter";
1515

‎anchor-counter/programs/public-counter/src/lib.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use ephemeral_rollups_sdk::anchor::{commit, delegate, ephemeral};
33
use ephemeral_rollups_sdk::cpi::DelegateConfig;
44
use ephemeral_rollups_sdk::ephem::MagicIntentBundleBuilder;
55

6-
declare_id!("9RPwaXayVZHna1BYuRS4cLPJZuNGU1uS5V3heXB7v6Qi");
6+
declare_id!("A4D1N6zdiwtAFr7mQcHkNbk2yXmDcpvovvU5D27kZoGv");
77

88
pub const COUNTER_SEED: &[u8] = b"counter";
99

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[119,46,244,54,52,50,191,114,206,197,170,24,175,166,19,3,6,17,59,122,49,186,70,124,216,43,13,202,198,181,103,214,97,25,57,34,18,212,173,207,238,164,136,58,10,45,107,233,195,189,65,84,182,242,104,176,149,52,246,45,128,129,82,141]
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
[106,108,44,14,228,142,138,192,251,141,149,227,72,172,124,173,42,3,203,113,154,21,153,82,212,199,168,15,115,100,198,39,134,139,128,19,183,247,83,39,234,34,183,10,57,232,90,108,188,49,31,188,22,201,57,242,183,210,9,200,162,251,250,195]

‎anchor-counter/tests/private-counter.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ import * as nacl from "tweetnacl";
77

88
const COUNTER_SEED = "counter";
99

10-
describe.only("private-counter", () => {
10+
describe("private-counter", () => {
1111
console.log("private-counter.ts");
1212

1313
let provider = new anchor.AnchorProvider(
1414
new anchor.web3.Connection(process.env.PROVIDER_ENDPOINT || "https://api.devnet.solana.com", {
15-
wsEndpoint: process.env.PROVIDER_ENDPOINT?.replace(/^https:\/\//, "wss://").replace(/^http:\/\//, "ws://") || undefined,
15+
wsEndpoint: process.env.WS_ENDPOINT || undefined,
1616
commitment: "confirmed",
1717
}),
1818
anchor.Wallet.local(),
@@ -27,7 +27,7 @@ describe.only("private-counter", () => {
2727

2828
let providerEphemeralRollup = new anchor.AnchorProvider(
2929
new anchor.web3.Connection(ephemeralRpcEndpoint, {
30-
wsEndpoint: process.env.TEE_PROVIDER_ENDPOINT?.replace(/^https:\/\//, "wss://").replace(/^http:\/\//, "ws://") || undefined,
30+
wsEndpoint: process.env.TEE_WS_ENDPOINT || undefined,
3131
commitment: "confirmed",
3232
}),
3333
anchor.Wallet.local(),

‎anchor-counter/tests/public-counter.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ import { GetCommitmentSignature } from "@magicblock-labs/ephemeral-rollups-sdk";
66

77
const COUNTER_SEED = "counter";
88

9-
describe("public-counter", () => {
9+
describe.only("public-counter", () => {
1010
console.log("public-counter.ts");
1111

1212
const provider = new anchor.AnchorProvider(
1313
new anchor.web3.Connection(
1414
process.env.PROVIDER_ENDPOINT || "https://api.devnet.solana.com",
1515
{
16-
wsEndpoint: process.env.PROVIDER_ENDPOINT?.replace(/^https:\/\//, "wss://").replace(/^http:\/\//, "ws://") || undefined,
16+
wsEndpoint: process.env.WS_ENDPOINT || undefined,
1717
commitment: "confirmed",
1818
},
1919
),
@@ -27,7 +27,7 @@ describe("public-counter", () => {
2727
"https://devnet-as.magicblock.app/",
2828
{
2929
wsEndpoint:
30-
process.env.EPHEMERAL_PROVIDER_ENDPOINT?.replace(/^https:\/\//, "wss://").replace(/^http:\/\//, "ws://") || "wss://devnet-as.magicblock.app/",
30+
process.env.EPHEMERAL_WS_ENDPOINT || "wss://devnet-as.magicblock.app/",
3131
commitment: "confirmed",
3232
},
3333
),

0 commit comments

Comments
 (0)