Skip to content

Commit b168feb

Browse files
committed
make tests serial
1 parent bb1e536 commit b168feb

9 files changed

Lines changed: 136 additions & 614 deletions

File tree

.github/actions/setup/action.yml

Lines changed: 62 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,32 @@ description: Setup Rust, Solana CLI, and optionally Node.js for testing
33

44
inputs:
55
example:
6-
description: 'Example directory path'
6+
description: "Example directory path"
77
required: true
88
node-version:
9-
description: 'Node.js version to install (optional)'
9+
description: "Node.js version to install (optional)"
1010
required: false
11-
default: ''
11+
default: ""
12+
node-version-default:
13+
description: "Default Node.js version for Light CLI"
14+
required: false
15+
default: "22"
1216
solana-cli-version:
13-
description: 'Solana CLI version'
17+
description: "Solana CLI version"
1418
required: false
15-
default: '2.3.11'
19+
default: "2.3.11"
1620
rust-toolchain:
17-
description: 'Rust toolchain version'
21+
description: "Rust toolchain version"
22+
required: false
23+
default: "1.90.0"
24+
anchor-version:
25+
description: "Anchor CLI version (for TypeScript tests)"
26+
required: false
27+
default: "0.31.1"
28+
photon-indexer:
29+
description: "Install Photon indexer (required for TypeScript tests)"
1830
required: false
19-
default: '1.90.0'
31+
default: "false"
2032

2133
runs:
2234
using: composite
@@ -27,22 +39,58 @@ runs:
2739
toolchain: ${{ inputs.rust-toolchain }}
2840
cache-workspaces: ${{ inputs.example }}
2941

30-
- name: Install Solana CLI
31-
uses: heyAyushh/setup-solana@v5.5
42+
- name: Setup Node.js
43+
if: inputs.node-version != ''
44+
uses: actions/setup-node@v4
3245
with:
33-
solana-cli-version: ${{ inputs.solana-cli-version }}
46+
node-version: ${{ inputs.node-version }}
3447

35-
- name: Setup Node.js
48+
- name: Setup Node.js (for Light CLI)
49+
if: inputs.node-version == ''
3650
uses: actions/setup-node@v4
3751
with:
38-
node-version: ${{ inputs.node-version != '' && inputs.node-version || '22' }}
39-
cache: ${{ inputs.node-version != '' && 'npm' || '' }}
40-
cache-dependency-path: ${{ inputs.node-version != '' && format('{0}/package-lock.json', inputs.example) || '' }}
52+
node-version: ${{ inputs.node-version-default }}
53+
54+
- name: Cache Solana CLI tools
55+
uses: actions/cache@v4
56+
with:
57+
path: |
58+
~/.cache/solana/
59+
~/.local/share/solana/
60+
key: solana-cli-${{ runner.os }}-build-${{ inputs.solana-cli-version }}
61+
62+
- name: Install Solana CLI tools
63+
shell: bash
64+
run: |
65+
if [[ "${{ inputs.solana-cli-version }}" == 1* ]]; then
66+
cd $HOME
67+
wget -q https://github.com/solana-labs/solana/releases/download/v${{ inputs.solana-cli-version }}/solana-release-x86_64-unknown-linux-gnu.tar.bz2
68+
tar jxf solana-release-x86_64-unknown-linux-gnu.tar.bz2
69+
echo "$HOME/solana-release/bin" >> $GITHUB_PATH
70+
else
71+
sh -c "$(curl -sSfL https://release.anza.xyz/v${{ inputs.solana-cli-version }}/install)"
72+
echo "/home/runner/.local/share/solana/install/active_release/bin" >> $GITHUB_PATH
73+
fi
74+
75+
- name: Install Anchor CLI
76+
if: inputs.node-version != ''
77+
shell: bash
78+
run: |
79+
cargo install --git https://github.com/coral-xyz/anchor avm --locked --force
80+
avm install ${{ inputs.anchor-version }}
81+
avm use ${{ inputs.anchor-version }}
4182
4283
- name: Install Light CLI
4384
shell: bash
4485
run: npm install -g @lightprotocol/zk-compression-cli
4586

87+
- name: Install Photon indexer
88+
if: inputs.photon-indexer == 'true'
89+
shell: bash
90+
env:
91+
RUSTFLAGS: "-A dead-code"
92+
run: cargo install --git https://github.com/lightprotocol/photon.git --rev 49b7e7f0d668babbc4d65fe8a0a7236df76f75a8 --locked
93+
4694
- name: Generate keypair
4795
shell: bash
4896
run: solana-keygen new --no-bip39-passphrase

.github/workflows/typescript-tests.yml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,27 @@ jobs:
3737
node-version: ${{ env.NODE_VERSION }}
3838
solana-cli-version: ${{ env.SOLANA_CLI_VERSION }}
3939
rust-toolchain: ${{ env.RUST_TOOLCHAIN }}
40+
photon-indexer: 'true'
4041

4142
- name: Install dependencies
4243
working-directory: ${{ matrix.example }}
4344
run: npm install
4445

46+
- name: Build and sync program ID
47+
working-directory: ${{ matrix.example }}
48+
run: anchor build
49+
4550
- name: Test sbf
4651
working-directory: ${{ matrix.example }}
4752
run: cargo test-sbf
4853

54+
- name: Start test validator
55+
working-directory: ${{ matrix.example }}
56+
run: |
57+
PROGRAM_ID=$(grep -A 1 "\[programs.localnet\]" Anchor.toml | grep "counter" | sed 's/.*"\(.*\)".*/\1/')
58+
light test-validator --sbf-program "$PROGRAM_ID" ./target/deploy/counter.so &
59+
sleep 10
60+
4961
- name: Run TypeScript tests
5062
working-directory: ${{ matrix.example }}
51-
run: npm test
63+
run: anchor test --skip-local-validator --skip-build --skip-deploy

account-comparison/programs/account-comparison/tests/test_compressed_account.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ async fn test_create_compressed_account() {
1818
let name = "Heinrich".to_string();
1919

2020
let config = ProgramTestConfig::new(
21-
false, // TODO: enable once cli with new prover server is released
21+
true,
2222
Some(vec![("account_comparison", account_comparison::ID)]),
2323
);
2424
let mut rpc = LightProgramTest::new(config).await.unwrap();

counter/anchor/tests/test.ts

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import {
1414
Rpc,
1515
sleep,
1616
} from "@lightprotocol/stateless.js";
17+
import { assert } from "chai";
1718

1819
const path = require("path");
1920
const os = require("os");
@@ -85,10 +86,7 @@ describe("test-anchor", () => {
8586
await sleep(2000);
8687

8788
counterAccount = await rpc.getCompressedAccount(bn(address.toBytes()));
88-
counter = coder.types.decode(
89-
"CounterAccount",
90-
counterAccount.data.data
91-
);
89+
counter = coder.types.decode("CounterAccount", counterAccount.data.data);
9290
console.log("counter account ", counterAccount);
9391
console.log("des counter ", counter);
9492

@@ -103,11 +101,17 @@ describe("test-anchor", () => {
103101

104102
// Wait for indexer to catch up.
105103
await sleep(2000);
106-
107-
const deletedCounterAccount = await rpc.getCompressedAccount(
108-
bn(address.toBytes())
109-
);
110-
console.log("deletedCounterAccount ", deletedCounterAccount);
104+
let should_have_failed = false;
105+
try {
106+
const deletedCounterAccount = await rpc.getCompressedAccount(
107+
bn(address.toBytes())
108+
);
109+
console.log("deletedCounterAccount ", deletedCounterAccount);
110+
} catch (e) {
111+
should_have_failed = true;
112+
}
113+
// TODO: assert is Null after next update.
114+
assert.isTrue(should_have_failed);
111115
});
112116
});
113117

create-and-update/Cargo.lock

Lines changed: 41 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

create-and-update/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,4 @@ light-program-test = "0.15.0"
2323
light-client = "0.15.0"
2424
tokio = "1.43.0"
2525
solana-sdk = "2.2"
26+
serial_test = "3.2.0"

create-and-update/tests/test.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,13 @@ use light_sdk::{
1313
address::v1::derive_address,
1414
instruction::{account_meta::CompressedAccountMeta, PackedAccounts, SystemAccountMetaConfig},
1515
};
16+
use serial_test::serial;
1617
use solana_sdk::{
1718
instruction::Instruction,
1819
signature::{Keypair, Signature, Signer},
1920
};
2021

22+
#[serial]
2123
#[tokio::test]
2224
async fn test_create_compressed_account() {
2325
let config = ProgramTestConfig::new(
@@ -61,6 +63,7 @@ async fn test_create_compressed_account() {
6163
assert_eq!(account_data.message, "Hello, World!");
6264
}
6365

66+
#[serial]
6467
#[tokio::test]
6568
async fn test_create_and_update() {
6669
let config = ProgramTestConfig::new(

create-and-update/tests/test_create_two_accounts.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,13 @@ use light_sdk::{
1010
address::v1::derive_address,
1111
instruction::{PackedAccounts, SystemAccountMetaConfig},
1212
};
13+
use serial_test::serial;
1314
use solana_sdk::{
1415
instruction::Instruction,
1516
signature::{Keypair, Signature, Signer},
1617
};
1718

19+
#[serial]
1820
#[tokio::test]
1921
async fn test_create_two_accounts() {
2022
let config = ProgramTestConfig::new(

0 commit comments

Comments
 (0)