Skip to content

Commit 93de112

Browse files
committed
feat(private-rpc): Enhance integration testing support and permissions configuration
- Updated the private RPC initialization command to include an integration test flag. - Added a new permissions configuration file specifically for integration tests, allowing all addresses for testing purposes. - Modified the permissions loading logic to switch between the standard and integration test permissions files based on the new flag.
1 parent f21aaa5 commit 93de112

File tree

4 files changed

+58
-3
lines changed

4 files changed

+58
-3
lines changed

core/tests/ts-integration/tests/prividium.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ describe('Tests for the private rpc', () => {
7272
}
7373

7474
beforeAll(async () => {
75-
const initCommand = `zkstack private-rpc init --verbose --dev --chain ${chainName} --docker-network-host`;
75+
const initCommand = `zkstack private-rpc init --verbose --dev --chain ${chainName} --docker-network-host --integration-test`;
7676
const runCommand = `zkstack private-rpc run --verbose --chain ${chainName}`;
7777

7878
await executeCommandWithLogs(initCommand, await logsPath('private-rpc-init.log'));
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Integration test permissions - allows all addresses for testing
2+
# This file is used specifically for integration tests
3+
whitelisted_wallets: "all"
4+
5+
groups:
6+
- name: "group1"
7+
members:
8+
- "0xeaAFbF6Fc352B0598e34f4F282939720D9cf0f59"
9+
- name: "group2"
10+
members:
11+
- "0x71e6dDfE9074786Fd8e986C53f78D25450d614D5"
12+
contracts:
13+
- address: "0xBE06E7e23AA92a6B0523A0E7cBb43690De7af8DB"
14+
methods:
15+
- signature: "function number() (uint256)"
16+
read:
17+
type: "public"
18+
write:
19+
type: "public"
20+
- signature: "function owner() (address)"
21+
read:
22+
type: "group"
23+
groups: ["group1"]
24+
write:
25+
type: "group"
26+
groups: ["group1"]
27+
- signature: "function fromGroup1Address() public"
28+
read:
29+
type: "group"
30+
groups: ["group1"]
31+
write:
32+
type: "group"
33+
groups: ["group1"]
34+
- signature: "function fromGroup2Address() public"
35+
read:
36+
type: "group"
37+
groups: ["group2"]
38+
write:
39+
type: "group"
40+
groups: ["group2"]
41+
- signature: "function hiTo(address) public"
42+
read:
43+
type: "checkArgument"
44+
argIndex: 0
45+
write:
46+
type: "checkArgument"
47+
argIndex: 0

private-rpc/example-permissions.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
# Example: whitelisted_wallets: "all"
33

44
# To restrict access to specific wallets, provide a non-empty list of addresses.
5-
whitelisted_wallets: "all"
5+
whitelisted_wallets:
6+
- "0x742d35Cc6634C0532925a3b8D69C7F16F6d34d2c" # Example wallet address
67

78
groups:
89
- name: "group1"

zkstack_cli/crates/zkstack/src/commands/private_rpc/mod.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ pub struct PrivateRpcCommandInitArgs {
3434
/// Initializes private proxy with network host mode. This is useful for environments that don't support host.docker.internal.
3535
#[clap(long)]
3636
pub docker_network_host: bool,
37+
/// Use test permissions file for integration tests
38+
#[clap(long)]
39+
pub integration_test: bool,
3740
}
3841

3942
#[derive(Subcommand, Debug)]
@@ -164,7 +167,11 @@ pub async fn init(shell: &Shell, args: PrivateRpcCommandInitArgs) -> anyhow::Res
164167

165168
initialize_private_rpc_database(shell, &chain_config, &db_config).await?;
166169

167-
let src_permissions_path = "example-permissions.yaml";
170+
let src_permissions_path = if args.integration_test {
171+
"private-rpc/example-permissions-test.yaml"
172+
} else {
173+
"private-rpc/example-permissions.yaml"
174+
};
168175
let dst_permissions_dir = ecosystem_path
169176
.join("chains")
170177
.join(chain_name.clone())

0 commit comments

Comments
 (0)