Skip to content

Commit b200f8a

Browse files
committed
chore: run tests with zksyncos server
1 parent ae7ad11 commit b200f8a

File tree

46 files changed

+2304
-394
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+2304
-394
lines changed

.github/workflows/ci-rust.yml

Lines changed: 107 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -87,27 +87,112 @@ jobs:
8787
run: forge build
8888
working-directory: packages/erc4337-contracts
8989

90-
- name: Verify ERC-4337 contract ABIs exist
90+
- name: Run clippy
91+
run: |
92+
rustup component add clippy --toolchain stable
93+
rustup component add --toolchain 1.91.0-x86_64-unknown-linux-gnu clippy
94+
cargo clippy --all-targets -- -D warnings
95+
working-directory: packages/sdk-platforms/rust/zksync-sso-erc4337
96+
97+
- name: Install cargo-nextest
98+
uses: taiki-e/install-action@nextest
99+
100+
- name: Run rust tests with nextest
101+
env:
102+
SSO_ZKSYNC_OS_PRINT_LOGS: "false"
103+
run: cargo nextest run --profile ci --all-features
104+
working-directory: packages/sdk-platforms/rust/zksync-sso-erc4337
105+
106+
rust-sdk-erc4337-zksync-os:
107+
name: Rust 4337 SDK (zksync-os)
108+
runs-on: ubuntu-latest
109+
strategy:
110+
matrix:
111+
config:
112+
- debug
113+
steps:
114+
- uses: actions/checkout@v4
115+
with:
116+
submodules: recursive
117+
118+
- name: Run sccache-cache
119+
uses: mozilla-actions/sccache-action@v0.0.4
120+
121+
- name: Install Rust
122+
run: |
123+
rustup update stable && rustup default stable
124+
rustup toolchain install nightly
125+
126+
- name: Run rustfmt
127+
run: |
128+
rustup component add rustfmt --toolchain nightly
129+
cargo +nightly fmt --all -- --check
130+
working-directory: packages/sdk-platforms/rust/zksync-sso-erc4337
131+
132+
- name: Install Foundry
133+
uses: foundry-rs/foundry-toolchain@v1.4.0
134+
with:
135+
# zksync-os-server's zkos-l1-state.json doesn't work on latest version of anvil
136+
version: v1.5.1
137+
138+
- name: Install dependencies
139+
run: forge soldeer install
140+
working-directory: packages/erc4337-contracts
141+
142+
- name: Install Node.js 22 via nvm
143+
run: |
144+
export NVM_DIR="$HOME/.nvm"
145+
mkdir -p "$NVM_DIR"
146+
curl -fsSL https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
147+
. "$NVM_DIR/nvm.sh"
148+
nvm install 22
149+
nvm use 22
150+
node -v
151+
npm install -g yarn
152+
# Expose Node.js bin dir to subsequent steps
153+
echo "$(dirname $(nvm which 22))" >> $GITHUB_PATH
154+
155+
- name: Configure pnpm store dir
156+
run: echo "PNPM_STORE_DIR=$HOME/.pnpm-store" >> $GITHUB_ENV
157+
158+
- name: Cache pnpm store
159+
uses: actions/cache@v4
160+
with:
161+
path: ~/.pnpm-store
162+
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('packages/erc4337-contracts/pnpm-lock.yaml') }}
163+
restore-keys: |
164+
${{ runner.os }}-pnpm-store-
165+
166+
- name: Enable corepack and activate pnpm from contracts package.json
167+
run: |
168+
corepack enable
169+
corepack prepare "$(node -p "require('./package.json').packageManager")" --activate
170+
pnpm -v
171+
working-directory: packages/erc4337-contracts
172+
173+
- name: Install dependencies
174+
run: pnpm install --frozen-lockfile
175+
working-directory: packages/erc4337-contracts
176+
177+
- name: Build ERC-4337 contracts
178+
run: forge build
179+
working-directory: packages/erc4337-contracts
180+
181+
- name: Clone zksync-os dependencies
91182
run: |
92183
set -euo pipefail
93-
missing=()
94-
files=(
95-
"out/IERC7579Account.sol/IERC7579Account.json"
96-
"out/EntryPoint.sol/EntryPoint.json"
97-
)
98-
for f in "${files[@]}"; do
99-
if [ ! -f "$f" ]; then
100-
missing+=("$f")
101-
fi
102-
done
103-
if [ ${#missing[@]} -gt 0 ]; then
104-
echo "Missing expected ABI JSON files:" >&2
105-
for m in "${missing[@]}"; do echo " - $m" >&2; done
106-
echo "\nAvailable JSON files under out/:" >&2
107-
find out -maxdepth 2 -type f -name '*.json' | sort || true
108-
exit 1
184+
cd packages/sdk-platforms/rust/zksync-sso-erc4337
185+
if [ ! -d account-abstraction ]; then
186+
git clone https://github.com/eth-infinitism/account-abstraction
109187
fi
110-
working-directory: packages/erc4337-contracts
188+
if [ ! -d zksync-os-server ]; then
189+
git clone https://github.com/matter-labs/zksync-os-server
190+
fi
191+
192+
- name: Build zksync-os-server
193+
run: |
194+
cd packages/sdk-platforms/rust/zksync-sso-erc4337/zksync-os-server
195+
cargo build --release --bin zksync-os-server
111196
112197
- name: Run clippy
113198
run: |
@@ -119,7 +204,10 @@ jobs:
119204
- name: Install cargo-nextest
120205
uses: taiki-e/install-action@nextest
121206

122-
- name: Run rust tests with nextest
207+
- name: Run rust tests with nextest (zksync-os)
208+
env:
209+
SSO_TEST_NODE_BACKEND: zksyncos
210+
SSO_ZKSYNC_OS_PRINT_LOGS: "false"
123211
run: cargo nextest run --profile ci --all-features
124212
working-directory: packages/sdk-platforms/rust/zksync-sso-erc4337
125213

@@ -153,28 +241,6 @@ jobs:
153241
run: forge build
154242
working-directory: packages/erc4337-contracts
155243

156-
- name: Verify ERC-4337 contract ABIs exist
157-
run: |
158-
set -euo pipefail
159-
missing=()
160-
files=(
161-
"out/IERC7579Account.sol/IERC7579Account.json"
162-
"out/EntryPoint.sol/EntryPoint.json"
163-
)
164-
for f in "${files[@]}"; do
165-
if [ ! -f "$f" ]; then
166-
missing+=("$f")
167-
fi
168-
done
169-
if [ ${#missing[@]} -gt 0 ]; then
170-
echo "Missing expected ABI JSON files:" >&2
171-
for m in "${missing[@]}"; do echo " - $m" >&2; done
172-
echo "\nAvailable JSON files under out/:" >&2
173-
find out -maxdepth 2 -type f -name '*.json' | sort || true
174-
exit 1
175-
fi
176-
working-directory: packages/erc4337-contracts
177-
178244
- name: Build WASM module (web target)
179245
run: wasm-pack build --target web
180246
working-directory: packages/sdk-platforms/rust/zksync-sso-erc4337/crates/zksync-sso-erc4337-ffi-web
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
#Cargo.lock
1+
zksync-os-server
2+
account-abstraction

packages/sdk-platforms/rust/zksync-sso-erc4337/Cargo.lock

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

packages/sdk-platforms/rust/zksync-sso-erc4337/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,3 +97,5 @@ tempfile = "3"
9797
strip-ansi-escapes = "0.2"
9898
libc = "0.2"
9999

100+
# Misc
101+
ureq = "2.10"

packages/sdk-platforms/rust/zksync-sso-erc4337/crates/zksync-sso-erc4337-core/Cargo.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ base64.workspace = true
4949
libc = { workspace = true, optional = true }
5050
strip-ansi-escapes = { workspace = true, optional = true }
5151
tempfile = { workspace = true, optional = true }
52+
zksync-sso-zksyncos-node = { path = "../zksync-sso-zksyncos-node", optional = true }
5253

5354
# Explicitly add getrandom v0.2 with js feature for WASM (used by rand 0.8 from alloy)
5455
[target.'cfg(target_arch = "wasm32")'.dependencies]
@@ -60,7 +61,7 @@ web-sys = { version = "0.3", features = ["Window"] }
6061
[features]
6162
default = ["tokio-runtime"]
6263
tokio-runtime = ["tokio"]
63-
test-utilities = ["libc", "strip-ansi-escapes", "tempfile"]
64+
test-utilities = ["libc", "strip-ansi-escapes", "tempfile", "zksync-sso-zksyncos-node"]
6465

6566
[dev-dependencies]
6667
# Alloy
@@ -77,3 +78,4 @@ tempfile.workspace = true
7778
strip-ansi-escapes.workspace = true
7879
libc.workspace = true
7980
wiremock.workspace = true
81+
zksync-sso-zksyncos-node = { path = "../zksync-sso-zksyncos-node" }

packages/sdk-platforms/rust/zksync-sso-erc4337/crates/zksync-sso-erc4337-core/src/erc4337/account/erc7579/module/add.rs

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,8 @@ mod tests {
122122
signer::create_eoa_signer,
123123
},
124124
utils::alloy_utilities::test_utilities::{
125-
TestInfraConfig,
126-
start_anvil_and_deploy_contracts_and_start_bundler_with_config,
125+
config::TestInfraConfig,
126+
start_node_and_deploy_contracts_and_start_bundler_with_config,
127127
},
128128
};
129129
use alloy::primitives::address;
@@ -139,18 +139,14 @@ mod tests {
139139
bundler,
140140
bundler_client,
141141
) = {
142-
let signer_private_key = "0x2a871d0798f97d79848a013d4936a73bf4cc922c825d33c1cf7073dff6d409c6".to_string();
143-
let config = TestInfraConfig {
144-
signer_private_key: signer_private_key.clone(),
145-
};
146-
start_anvil_and_deploy_contracts_and_start_bundler_with_config(
142+
let config = TestInfraConfig::rich_wallet_9();
143+
start_node_and_deploy_contracts_and_start_bundler_with_config(
147144
&config,
148145
)
149146
.await?
150147
};
151148

152-
let entry_point_address =
153-
address!("0x4337084D9E255Ff0702461CF8895CE9E3b5Ff108");
149+
let entry_point_address = contracts.entry_point;
154150

155151
let factory_address = contracts.account_factory;
156152
let eoa_validator_address = contracts.eoa_validator;
@@ -239,18 +235,14 @@ mod tests {
239235
bundler,
240236
bundler_client,
241237
) = {
242-
let signer_private_key = "0x2a871d0798f97d79848a013d4936a73bf4cc922c825d33c1cf7073dff6d409c6".to_string();
243-
let config = TestInfraConfig {
244-
signer_private_key: signer_private_key.clone(),
245-
};
246-
start_anvil_and_deploy_contracts_and_start_bundler_with_config(
238+
let config = TestInfraConfig::rich_wallet_9();
239+
start_node_and_deploy_contracts_and_start_bundler_with_config(
247240
&config,
248241
)
249242
.await?
250243
};
251244

252-
let entry_point_address =
253-
address!("0x4337084D9E255Ff0702461CF8895CE9E3b5Ff108");
245+
let entry_point_address = contracts.entry_point;
254246

255247
let factory_address = contracts.account_factory;
256248
let eoa_validator_address = contracts.eoa_validator;

0 commit comments

Comments
 (0)