Skip to content

Commit 40ae7d7

Browse files
authored
feat: 4337 sdk ci improvements (#198)
1 parent 002b0ca commit 40ae7d7

File tree

24 files changed

+1270
-995
lines changed

24 files changed

+1270
-995
lines changed

.github/workflows/ci-rust.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,11 @@ jobs:
198198
cargo clippy --all-targets -- -D warnings
199199
working-directory: packages/sdk-platforms/rust/zksync-sso-erc4337
200200

201-
- name: Run rust tests
202-
run: cargo test
201+
- name: Install cargo-nextest
202+
uses: taiki-e/install-action@nextest
203+
204+
- name: Run rust tests with nextest
205+
run: cargo nextest run --profile ci --all-features
203206
working-directory: packages/sdk-platforms/rust/zksync-sso-erc4337
204207

205208
rust-sdk-erc4337-wasm:

.github/workflows/scripts/install-anvil-zksync.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
set -euo pipefail
44

55
REPO_URL="https://github.com/matter-labs/anvil-zksync.git"
6-
RELEASE_VERSION="v0.6.3"
6+
RELEASE_VERSION="v0.6.11"
77

88
# Detect platform
99
if [[ "$OSTYPE" == "darwin"* ]]; then
@@ -39,4 +39,4 @@ if command -v anvil-zksync >/dev/null 2>&1; then
3939
else
4040
echo "Error: anvil-zksync not found in PATH" >&2
4141
exit 1
42-
fi
42+
fi
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
[profile.default]
2+
# Show test output for failing tests
3+
failure-output = "immediate"
4+
# Show test output for successful tests
5+
success-output = "never"
6+
# Show test output while tests are running
7+
status-level = "pass"
8+
# Number of retries for failed tests
9+
retries = 0
10+
# Run all tests sequentially (no parallel execution)
11+
test-threads = 1
12+
13+
[profile.ci]
14+
# In CI, show output for all tests
15+
failure-output = "immediate-final"
16+
success-output = "never"
17+
status-level = "pass"
18+
# Enable JUnit output for CI
19+
# The path is relative to the workspace root
20+
# Run all tests sequentially in CI as well
21+
test-threads = 1

packages/sdk-platforms/rust/zksync-sso-erc4337/crates/zksync-sso-erc4337-core/src/erc4337.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ pub mod signature;
88
pub mod signer;
99
pub mod transaction;
1010
pub mod user_operation;
11+
pub mod utils;

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

Lines changed: 40 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -68,44 +68,48 @@ fn add_module_call_data(
6868
#[cfg(test)]
6969
mod tests {
7070
use super::*;
71-
use crate::erc4337::account::modular_smart_account::{
72-
deploy::{EOASigners, deploy_account},
73-
signature::{eoa_signature, stub_signature_eoa},
71+
use crate::{
72+
erc4337::account::modular_smart_account::{
73+
deploy::{EOASigners, deploy_account},
74+
signature::{eoa_signature, stub_signature_eoa},
75+
},
76+
utils::alloy_utilities::test_utilities::{
77+
TestInfraConfig,
78+
start_anvil_and_deploy_contracts_and_start_bundler_with_config,
79+
},
7480
};
7581
use alloy::{
7682
primitives::{FixedBytes, U256, address},
77-
providers::ProviderBuilder,
7883
rpc::types::TransactionRequest,
79-
signers::local::PrivateKeySigner,
8084
};
81-
use std::{str::FromStr, sync::Arc};
85+
use std::sync::Arc;
8286

8387
#[tokio::test]
84-
#[ignore = "needs local infrastructure to be running"]
8588
async fn test_add_module() -> eyre::Result<()> {
86-
let rpc_url = "http://localhost:8545".parse()?;
87-
88-
let factory_address =
89-
address!("0x679FFF51F11C3f6CaC9F2243f9D14Cb1255F65A3");
89+
let (
90+
_,
91+
anvil_instance,
92+
provider,
93+
contracts,
94+
signer_private_key,
95+
bundler,
96+
bundler_client,
97+
) = {
98+
let signer_private_key = "0x2a871d0798f97d79848a013d4936a73bf4cc922c825d33c1cf7073dff6d409c6".to_string();
99+
let config = TestInfraConfig {
100+
signer_private_key: signer_private_key.clone(),
101+
};
102+
start_anvil_and_deploy_contracts_and_start_bundler_with_config(
103+
&config,
104+
)
105+
.await?
106+
};
90107

91108
let entry_point_address =
92109
address!("0x4337084D9E255Ff0702461CF8895CE9E3b5Ff108");
93110

94-
let eoa_validator_address =
95-
address!("0x00427eDF0c3c3bd42188ab4C907759942Abebd93");
96-
97-
let signer_private_key = "0x2a871d0798f97d79848a013d4936a73bf4cc922c825d33c1cf7073dff6d409c6";
98-
99-
let provider = {
100-
let signer = PrivateKeySigner::from_str(signer_private_key)?;
101-
let alloy_signer = signer.clone();
102-
let ethereum_wallet =
103-
alloy::network::EthereumWallet::new(alloy_signer.clone());
104-
105-
ProviderBuilder::new()
106-
.wallet(ethereum_wallet.clone())
107-
.connect_http(rpc_url)
108-
};
111+
let factory_address = contracts.account_factory;
112+
let eoa_validator_address = contracts.eoa_validator;
109113

110114
let signers =
111115
vec![address!("0xa0Ee7A142d267C1f36714E4a8F75612F20a79720")];
@@ -143,22 +147,16 @@ mod tests {
143147
.value(U256::from(10000000000000000000u64));
144148
_ = provider.send_transaction(fund_tx).await?.get_receipt().await?;
145149
}
146-
147-
let module_address =
148-
address!("0xF3F924c9bADF6891D3676cfe9bF72e2C78527E17"); // WebAuthn Module Address
149-
150-
let bundler_client = {
151-
use crate::erc4337::bundler::config::BundlerConfig;
152-
let bundler_url = "http://localhost:4337".to_string();
153-
let config = BundlerConfig::new(bundler_url);
154-
BundlerClient::new(config)
155-
};
150+
let module_address = contracts.webauthn_validator;
156151

157152
let stub_sig = stub_signature_eoa(eoa_validator_address)?;
158153

159-
let signature_provider = Arc::new(move |hash: FixedBytes<32>| {
160-
eoa_signature(signer_private_key, eoa_validator_address, hash)
161-
});
154+
let signature_provider = {
155+
let signer_private_key = signer_private_key.clone();
156+
Arc::new(move |hash: FixedBytes<32>| {
157+
eoa_signature(&signer_private_key, eoa_validator_address, hash)
158+
})
159+
};
162160

163161
let signer =
164162
Signer { provider: signature_provider, stub_signature: stub_sig };
@@ -185,6 +183,9 @@ mod tests {
185183
"is_web_authn_module is not installed"
186184
);
187185

186+
drop(anvil_instance);
187+
drop(bundler);
188+
188189
Ok(())
189190
}
190191
}

packages/sdk-platforms/rust/zksync-sso-erc4337/crates/zksync-sso-erc4337-core/src/erc4337/account/is_deployed.rs

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -15,42 +15,3 @@ where
1515

1616
Ok(false)
1717
}
18-
19-
#[cfg(test)]
20-
mod tests {
21-
use super::*;
22-
use alloy::{node_bindings::Anvil, providers::ProviderBuilder};
23-
24-
#[tokio::test]
25-
#[ignore = "implementation not complete"]
26-
async fn test_is_smart_account_deployed() -> eyre::Result<()> {
27-
let anvil = Anvil::new().spawn();
28-
let anvil_url = anvil.endpoint_url();
29-
30-
let provider = ProviderBuilder::new().connect_http(anvil_url);
31-
32-
// Test with a known address (anvil's first default account - EOA)
33-
let eoa_address =
34-
"0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266".parse::<Address>()?;
35-
36-
// Test that EOA is not deployed as smart contract
37-
let is_eoa_deployed =
38-
is_smart_account_deployed(&provider, eoa_address).await?;
39-
eyre::ensure!(
40-
!is_eoa_deployed,
41-
"EOA should not be detected as deployed smart contract"
42-
);
43-
44-
// Test with a non-existent address
45-
let non_existent =
46-
"0x0000000000000000000000000000000000000123".parse::<Address>()?;
47-
let is_non_existent_deployed =
48-
is_smart_account_deployed(&provider, non_existent).await?;
49-
eyre::ensure!(
50-
!is_non_existent_deployed,
51-
"Non-existent address should not be deployed"
52-
);
53-
54-
Ok(())
55-
}
56-
}

0 commit comments

Comments
 (0)