From 635d4754e073e070a3b705a3f538c333fb212aac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrzej=20Bro=C5=84ski?= Date: Tue, 23 Jul 2024 15:29:01 +0200 Subject: [PATCH 1/9] Allow to provide custom deposit WASM path to CLI. --- kairos-cli/src/client.rs | 11 +--------- kairos-cli/src/commands/deposit.rs | 32 +++++++++++++++++++++++++++++- 2 files changed, 32 insertions(+), 11 deletions(-) diff --git a/kairos-cli/src/client.rs b/kairos-cli/src/client.rs index 3c0d5f3c..6d723279 100644 --- a/kairos-cli/src/client.rs +++ b/kairos-cli/src/client.rs @@ -8,8 +8,6 @@ use kairos_server::PublicKey; use reqwest::Url; use serde::{Deserialize, Serialize}; use std::fmt; -use std::fs; -use std::path::Path; // max amount allowed to be used on gas fees pub const MAX_GAS_FEE_PAYMENT_AMOUNT: u64 = 1_000_000_000_000; @@ -49,19 +47,12 @@ impl From for KairosClientError { pub fn deposit( base_url: &Url, + deposit_session_wasm_bytes: &[u8], depositor_secret_key: &SecretKey, contract_hash: &ContractHash, amount: impl Into, recipient: casper_client_types::PublicKey, ) -> Result { - let deposit_session_wasm_path = - Path::new(env!("PATH_TO_SESSION_BINARIES")).join("deposit-session-optimized.wasm"); - let deposit_session_wasm_bytes = fs::read(&deposit_session_wasm_path).unwrap_or_else(|err| { - panic!( - "Failed to read the deposit session wasm as bytes from file: {:?}.\n{}", - deposit_session_wasm_path, err - ) - }); let deposit_session = ExecutableDeployItem::new_module_bytes( deposit_session_wasm_bytes.into(), runtime_args! { diff --git a/kairos-cli/src/commands/deposit.rs b/kairos-cli/src/commands/deposit.rs index cd72f23b..02a07029 100644 --- a/kairos-cli/src/commands/deposit.rs +++ b/kairos-cli/src/commands/deposit.rs @@ -1,9 +1,12 @@ +use std::fs; +use std::path::PathBuf; + use crate::client; use crate::common::args::{AmountArg, ContractHashArg, PrivateKeyPathArg, RecipientArg}; use crate::error::CliError; use casper_client_types::{crypto::SecretKey, ContractHash}; -use clap::Parser; +use clap::{Args as ClapArgs, Parser}; use hex::FromHex; use reqwest::Url; @@ -19,6 +22,8 @@ pub struct Args { contract_hash: ContractHashArg, #[clap(flatten)] recipient: RecipientArg, + #[clap(flatten)] + session_path: SessionPathArg, } pub fn run(args: Args, kairos_server_address: Url) -> Result { @@ -38,8 +43,21 @@ pub fn run(args: Args, kairos_server_address: Url) -> Result { None => client::contract_hash(&kairos_server_address)?, }; + let deposit_session_wasm: Vec = match args.session_path.field { + Some(deposit_session_wasm_path) => { + fs::read(&deposit_session_wasm_path).unwrap_or_else(|err| { + panic!( + "Failed to read the deposit session wasm as bytes from file: {:?}.\n{}", + deposit_session_wasm_path, err + ) + }) + } + None => panic!("No deposit session available!"), + }; + client::deposit( &kairos_server_address, + &deposit_session_wasm, &depositor_secret_key, &contract_hash, amount, @@ -59,3 +77,15 @@ pub fn run(args: Args, kairos_server_address: Url) -> Result { output }) } + +#[derive(ClapArgs, Debug)] +pub struct SessionPathArg { + #[arg( + id = "session-path", + long, + short = 's', + value_name = "PATH", + help = "Path to the custom WASM session code for deposit" + )] + pub field: Option, +} From 7098d87b0713ebbc75acfaa07feda8daf35251a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrzej=20Bro=C5=84ski?= Date: Tue, 23 Jul 2024 15:30:15 +0200 Subject: [PATCH 2/9] Use hardcoded env to provide built-in session code. --- kairos-cli/build.rs | 20 ++++++++++++++++++++ kairos-cli/src/commands/deposit.rs | 5 ++++- 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 kairos-cli/build.rs diff --git a/kairos-cli/build.rs b/kairos-cli/build.rs new file mode 100644 index 00000000..64c6a5fb --- /dev/null +++ b/kairos-cli/build.rs @@ -0,0 +1,20 @@ +use std::env; +use std::fs; +use std::path::Path; + +fn main() { + // Path + let session_binaries_dir = env::var("PATH_TO_SESSION_BINARIES") + .expect("PATH_TO_SESSION_BINARIES environment variable is not set"); + + // Get the output directory set by Cargo. + let out_dir = env::var("OUT_DIR").expect("OUT_DIR not set"); + let source_path = Path::new(&session_binaries_dir).join("deposit-session-optimized.wasm"); + let dest_path = Path::new(&out_dir).join("deposit-session-optimized.wasm"); + + // Copy the file from the source to the destination + fs::copy(&source_path, &dest_path).expect("Failed to copy WASM file"); + + // Print out a message to re-run this script if the source file changes. + println!("cargo:rerun-if-changed={}", source_path.display()); +} diff --git a/kairos-cli/src/commands/deposit.rs b/kairos-cli/src/commands/deposit.rs index 02a07029..c7bbd894 100644 --- a/kairos-cli/src/commands/deposit.rs +++ b/kairos-cli/src/commands/deposit.rs @@ -12,6 +12,9 @@ use reqwest::Url; use kairos_crypto::error::CryptoError; +const DEFAULT_DEPOSIT_SESSION_WASM: &[u8] = + include_bytes!(concat!(env!("OUT_DIR"), "/deposit-session-optimized.wasm")); + #[derive(Parser, Debug)] pub struct Args { #[clap(flatten)] @@ -52,7 +55,7 @@ pub fn run(args: Args, kairos_server_address: Url) -> Result { ) }) } - None => panic!("No deposit session available!"), + None => DEFAULT_DEPOSIT_SESSION_WASM.to_vec(), }; client::deposit( From 652999245477cf8be21121e2b91d8354a94f1419 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrzej=20Bro=C5=84ski?= Date: Tue, 23 Jul 2024 15:44:20 +0200 Subject: [PATCH 3/9] Fix clippy error. --- kairos-cli/build.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kairos-cli/build.rs b/kairos-cli/build.rs index 64c6a5fb..3bce4324 100644 --- a/kairos-cli/build.rs +++ b/kairos-cli/build.rs @@ -13,7 +13,7 @@ fn main() { let dest_path = Path::new(&out_dir).join("deposit-session-optimized.wasm"); // Copy the file from the source to the destination - fs::copy(&source_path, &dest_path).expect("Failed to copy WASM file"); + fs::copy(&source_path, dest_path).expect("Failed to copy WASM file"); // Print out a message to re-run this script if the source file changes. println!("cargo:rerun-if-changed={}", source_path.display()); From 260c4a56c987982f870000ea0c0b2c396f3b1d79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marijan=20Petri=C4=8Devi=C4=87?= Date: Thu, 25 Jul 2024 11:09:24 +0200 Subject: [PATCH 4/9] risc0: 1.0.2 -> 1.0.3 --- Cargo.lock | 14 +++++++------- flake.lock | 6 +++--- kairos-contracts/Cargo.lock | 4 ++-- kairos-prover/Cargo.lock | 16 ++++++++-------- .../kairos-prover-risc0-server/Cargo.toml | 2 +- .../kairos-verifier-risc0-lib/Cargo.toml | 2 +- kairos-prover/methods/Cargo.toml | 2 +- kairos-prover/profiling/Cargo.toml | 2 +- 8 files changed, 24 insertions(+), 24 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 758f6dfa..d21a69cd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1361,9 +1361,9 @@ dependencies = [ [[package]] name = "crypto-mac" -version = "0.10.1" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bff07008ec701e8028e2ceb8f83f0e4274ee62bd2dbdc4fefff2e9a91824081a" +checksum = "4857fd85a0c34b3c3297875b747c1e02e06b6a0ea32dd892d8192b9ce0813ea6" dependencies = [ "generic-array", "subtle", @@ -2338,7 +2338,7 @@ version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c1441c6b1e930e2817404b5046f1f989899143a12bf92de603b69f4e0aee1e15" dependencies = [ - "crypto-mac 0.10.1", + "crypto-mac 0.10.0", "digest 0.9.0", ] @@ -4024,9 +4024,9 @@ dependencies = [ [[package]] name = "risc0-zkvm" -version = "1.0.2" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee208f125812335658abaa87243502b7066a3dfcbd646bdc5d2820c0cd8a797b" +checksum = "6ca4ee3b38d873affc146e48c741e5a70533f5ccb1e3b186d8d671459c51d1ba" dependencies = [ "anyhow", "bytemuck", @@ -4555,9 +4555,9 @@ dependencies = [ [[package]] name = "subtle" -version = "2.4.1" +version = "2.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6bdef32e8150c2a081110b42772ffe7d7c9032b606bc226c8260fd97e0976601" +checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292" [[package]] name = "syn" diff --git a/flake.lock b/flake.lock index ecd80a9c..20cae6bf 100644 --- a/flake.lock +++ b/flake.lock @@ -177,11 +177,11 @@ }, "nixpkgs_2": { "locked": { - "lastModified": 1721116560, - "narHash": "sha256-++TYlGMAJM1Q+0nMVaWBSEvEUjRs7ZGiNQOpqbQApCU=", + "lastModified": 1721782431, + "narHash": "sha256-UNDpwjYxNXQet/g3mgRLsQ9zxrbm9j2JEvP4ijF3AWs=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "9355fa86e6f27422963132c2c9aeedb0fb963d93", + "rev": "4f02464258baaf54992debfd010a7a3662a25536", "type": "github" }, "original": { diff --git a/kairos-contracts/Cargo.lock b/kairos-contracts/Cargo.lock index 79656ebb..e1afce59 100644 --- a/kairos-contracts/Cargo.lock +++ b/kairos-contracts/Cargo.lock @@ -1170,9 +1170,9 @@ dependencies = [ [[package]] name = "risc0-zkvm" -version = "1.0.2" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee208f125812335658abaa87243502b7066a3dfcbd646bdc5d2820c0cd8a797b" +checksum = "6ca4ee3b38d873affc146e48c741e5a70533f5ccb1e3b186d8d671459c51d1ba" dependencies = [ "anyhow", "bytemuck", diff --git a/kairos-prover/Cargo.lock b/kairos-prover/Cargo.lock index 6e8372fa..dc7be5ef 100644 --- a/kairos-prover/Cargo.lock +++ b/kairos-prover/Cargo.lock @@ -2843,9 +2843,9 @@ dependencies = [ [[package]] name = "risc0-binfmt" -version = "1.0.2" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7388047ead80fcb19fe4d3f289d0eeb70b5c4d77c37534002273361ef47c8ba7" +checksum = "b3432b33880fd2bb3fcff4f7f4764f782852e839a849f72f1b36ba021e6f15d0" dependencies = [ "anyhow", "elf", @@ -2910,9 +2910,9 @@ dependencies = [ [[package]] name = "risc0-circuit-rv32im" -version = "1.0.2" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "64a8cca9ebcd1aac8373904e798ec8b8c076cd75a25fc391c120d7ee37121170" +checksum = "8fce940ee68935e3fbe224033fb8dc8447d23dcc7558aaa8bb8c21bc1de73bdf" dependencies = [ "anyhow", "bytemuck", @@ -2962,9 +2962,9 @@ dependencies = [ [[package]] name = "risc0-groth16" -version = "1.0.2" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d28893ca55db739e90656c1a1625f69634cdc204be46c3c52b73d64221c6e129" +checksum = "7fa298da93c2a8ea3c92bde5b2e12cbad3c4291bc4a5a70af5f1fd64a12353a5" dependencies = [ "anyhow", "ark-bn254", @@ -3029,9 +3029,9 @@ dependencies = [ [[package]] name = "risc0-zkvm" -version = "1.0.2" +version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ee208f125812335658abaa87243502b7066a3dfcbd646bdc5d2820c0cd8a797b" +checksum = "6ca4ee3b38d873affc146e48c741e5a70533f5ccb1e3b186d8d671459c51d1ba" dependencies = [ "addr2line", "anyhow", diff --git a/kairos-prover/kairos-prover-risc0-server/Cargo.toml b/kairos-prover/kairos-prover-risc0-server/Cargo.toml index fceb4e92..a1357bf8 100644 --- a/kairos-prover/kairos-prover-risc0-server/Cargo.toml +++ b/kairos-prover/kairos-prover-risc0-server/Cargo.toml @@ -14,7 +14,7 @@ metal = [ "risc0-zkvm/metal", "disable-dev-mode" ] [dependencies] methods = { path = "../methods" } -risc0-zkvm = { version="=1.0.2", default-features=false } +risc0-zkvm = { version="=1.0.3", default-features=false } tracing = "0.1" tracing-subscriber = { version = "0.3", features = ["env-filter"] } diff --git a/kairos-prover/kairos-verifier-risc0-lib/Cargo.toml b/kairos-prover/kairos-verifier-risc0-lib/Cargo.toml index a20d989b..fbfdc71c 100644 --- a/kairos-prover/kairos-verifier-risc0-lib/Cargo.toml +++ b/kairos-prover/kairos-verifier-risc0-lib/Cargo.toml @@ -11,6 +11,6 @@ disable-dev-mode = [ "risc0-zkvm/disable-dev-mode" ] [dependencies] -risc0-zkvm = { version = "=1.0.2", default-features = false, optional = true } +risc0-zkvm = { version = "=1.0.3", default-features = false, optional = true } kairos-circuit-logic = { path = "../kairos-circuit-logic", features = ["serde", "borsh"], default-features = false, optional = true } borsh = { version = "1", default-features = false, optional = true } diff --git a/kairos-prover/methods/Cargo.toml b/kairos-prover/methods/Cargo.toml index aa2f3020..a92baa66 100644 --- a/kairos-prover/methods/Cargo.toml +++ b/kairos-prover/methods/Cargo.toml @@ -5,5 +5,5 @@ edition.workspace = true license.workspace = true [build-dependencies] -risc0-binfmt = "=1.0.2" +risc0-binfmt = "=1.0.3" kairos-verifier-risc0-lib = { path = "../kairos-verifier-risc0-lib", default-features = false } diff --git a/kairos-prover/profiling/Cargo.toml b/kairos-prover/profiling/Cargo.toml index 9b50735a..80120049 100644 --- a/kairos-prover/profiling/Cargo.toml +++ b/kairos-prover/profiling/Cargo.toml @@ -6,7 +6,7 @@ license.workspace = true [dependencies] methods = { path = "../methods" } -risc0-zkvm = "=1.0.2" +risc0-zkvm = "=1.0.3" tracing = "0.1" tracing-subscriber = { version = "0.3", features = ["env-filter"] } From 583df8e0d901a832226dfa45d68a9497edd9167a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marijan=20Petri=C4=8Devi=C4=87?= Date: Thu, 25 Jul 2024 12:01:28 +0200 Subject: [PATCH 5/9] kairos-data: query case-insensitive sender/recipient. fixes #167 --- kairos-data/src/transaction.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kairos-data/src/transaction.rs b/kairos-data/src/transaction.rs index 34204a03..9f0e8a39 100644 --- a/kairos-data/src/transaction.rs +++ b/kairos-data/src/transaction.rs @@ -51,7 +51,7 @@ pub async fn get( let mut query = transactions::table.into_boxed::(); if let Some(sender) = filter.sender { - query = query.filter(transactions::public_key.eq(sender)); + query = query.filter(transactions::public_key.eq(sender.to_lowercase())); } if let Some(min_timestamp) = filter.min_timestamp { query = query.filter(transactions::timestamp.ge(min_timestamp)); @@ -66,7 +66,7 @@ pub async fn get( query = query.filter(transactions::amount.le(BigDecimal::from(max_amount))); } if let Some(recipient) = filter.recipient { - query = query.filter(transactions::recipient.eq(recipient)); + query = query.filter(transactions::recipient.eq(recipient.to_lowercase())); } if let Some(transaction_type) = filter.transaction_type { query = query.filter(transactions::trx.eq(transaction_type)); From 8c68f90280831032dc81a25fe3f60c6145ba1d75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marijan=20Petri=C4=8Devi=C4=87?= Date: Thu, 25 Jul 2024 12:05:47 +0200 Subject: [PATCH 6/9] kairos-cli: make short args distinct, fixes #166 --- kairos-cli/src/commands/fetch.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/kairos-cli/src/commands/fetch.rs b/kairos-cli/src/commands/fetch.rs index 9d146c48..25cd6108 100644 --- a/kairos-cli/src/commands/fetch.rs +++ b/kairos-cli/src/commands/fetch.rs @@ -11,17 +11,17 @@ use chrono::NaiveDateTime; pub struct Args { #[arg(long, short, value_name = "PUBLIC_KEY_HEX")] sender: Option, - #[arg(long, short, value_name = "ISO8601_TIMESTAMP")] + #[arg(long, short = 't', value_name = "ISO8601_TIMESTAMP")] min_timestamp: Option, - #[arg(long, short, value_name = "ISO8601_TIMESTAMP")] + #[arg(long, short = 'T', value_name = "ISO8601_TIMESTAMP")] max_timestamp: Option, - #[arg(long, short, value_name = "NUM_MOTES")] + #[arg(long, short = 'm', value_name = "NUM_MOTES")] min_amount: Option, - #[arg(long, short, value_name = "NUM_MOTES")] + #[arg(long, short = 'M', value_name = "NUM_MOTES")] max_amount: Option, #[arg(long, short, value_name = "PUBLIC_KEY_HEX")] recipient: Option, - #[arg(long, short, value_name = "TRANSACTION_TYPE", value_enum)] + #[arg(long, short = 'x', value_name = "TRANSACTION_TYPE", value_enum)] transaction_type: Option, } From 10a3f78591865da07a8976701ab6254317888f81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrzej=20Bro=C5=84ski?= Date: Thu, 25 Jul 2024 15:23:33 +0200 Subject: [PATCH 7/9] Move compile-time `CCTL_CHAINSPEC` and `CCTL_CONFIG` to runtime. --- kairos-cli/src/commands/run_cctl.rs | 8 ++++---- kairos-test-utils/src/cctl.rs | 14 ++++++++++---- ...test_cctl_deploys_a_contract_successfully.rs | 8 ++++---- .../test_cctl_network_starts_and_terminates.rs | 17 +++++++++++------ 4 files changed, 29 insertions(+), 18 deletions(-) diff --git a/kairos-cli/src/commands/run_cctl.rs b/kairos-cli/src/commands/run_cctl.rs index 23d95510..b15a9c2b 100644 --- a/kairos-cli/src/commands/run_cctl.rs +++ b/kairos-cli/src/commands/run_cctl.rs @@ -1,4 +1,4 @@ -use std::path::{Path, PathBuf}; +use std::path::PathBuf; use casper_client_types::{runtime_args, RuntimeArgs}; use kairos_test_utils::cctl::{CCTLNetwork, DeployableContract}; @@ -16,10 +16,10 @@ pub fn run() -> Result { path: contract_wasm_path, }; println!("Deploying contract..."); - let chainspec_path = Path::new(env!("CCTL_CHAINSPEC")); - let config_path = Path::new(env!("CCTL_CONFIG")); + let chainspec_path = PathBuf::from(std::env::var("CCTL_CHAINSPEC").unwrap()); + let config_path = PathBuf::from(std::env::var("CCTL_CONFIG").unwrap()); - let network = CCTLNetwork::run(None, Some(contract_to_deploy), Some(chainspec_path), Some(config_path)) + let network = CCTLNetwork::run(None, Some(contract_to_deploy), Some(chainspec_path.as_path()), Some(config_path.as_path())) .await .unwrap(); diff --git a/kairos-test-utils/src/cctl.rs b/kairos-test-utils/src/cctl.rs index 86d08fb2..acb30abb 100644 --- a/kairos-test-utils/src/cctl.rs +++ b/kairos-test-utils/src/cctl.rs @@ -76,8 +76,14 @@ impl CCTLNetwork { chainspec_path: Option<&Path>, config_path: Option<&Path>, ) -> anyhow::Result { - let chainspec_path = chainspec_path.unwrap_or_else(|| Path::new(env!("CCTL_CHAINSPEC"))); - let config_path = config_path.unwrap_or_else(|| Path::new(env!("CCTL_CONFIG"))); + let chainspec_path: String = chainspec_path + .map(|p| p.to_str().unwrap().to_owned()) + .ok_or_else(|| std::env::var("CCTL_CHAINSPEC")) + .unwrap(); + let config_path: String = config_path + .map(|p| p.to_str().unwrap().to_owned()) + .ok_or_else(|| std::env::var("CCTL_CONFIG")) + .unwrap(); let working_dir = working_dir .map(|dir| { @@ -92,9 +98,9 @@ impl CCTLNetwork { let mut setup_command = Command::new("cctl-infra-net-setup"); setup_command.env("CCTL_ASSETS", &assets_dir); - setup_command.arg(format!("chainspec={}", chainspec_path.to_str().unwrap())); + setup_command.arg(format!("chainspec={}", chainspec_path)); - setup_command.arg(format!("config={}", config_path.to_str().unwrap())); + setup_command.arg(format!("config={}", config_path)); tracing::info!("Setting up network configuration"); let output = setup_command diff --git a/kairos-test-utils/tests/test_cctl_deploys_a_contract_successfully.rs b/kairos-test-utils/tests/test_cctl_deploys_a_contract_successfully.rs index 441130b9..cf56d8c3 100644 --- a/kairos-test-utils/tests/test_cctl_deploys_a_contract_successfully.rs +++ b/kairos-test-utils/tests/test_cctl_deploys_a_contract_successfully.rs @@ -30,14 +30,14 @@ async fn test_cctl_deploys_a_contract_successfully() { path: contract_wasm_path, }; - let chainspec = Path::new(env!("CCTL_CHAINSPEC")); - let config = Path::new(env!("CCTL_CONFIG")); + let chainspec = PathBuf::from(std::env::var("CCTL_CHAINSPEC").unwrap()); + let config = PathBuf::from(std::env::var("CCTL_CONFIG").unwrap()); let network = CCTLNetwork::run( None, Some(contract_to_deploy), - Some(chainspec), - Some(config), + Some(chainspec.as_path()), + Some(config.as_path()), ) .await .unwrap(); diff --git a/kairos-test-utils/tests/test_cctl_network_starts_and_terminates.rs b/kairos-test-utils/tests/test_cctl_network_starts_and_terminates.rs index bd4ca319..64044748 100644 --- a/kairos-test-utils/tests/test_cctl_network_starts_and_terminates.rs +++ b/kairos-test-utils/tests/test_cctl_network_starts_and_terminates.rs @@ -1,4 +1,4 @@ -use std::path::Path; +use std::path::PathBuf; use casper_client::{get_node_status, rpcs::results::ReactorState, JsonRpcId, Verbosity}; use kairos_test_utils::cctl::{CCTLNetwork, NodeState}; @@ -16,12 +16,17 @@ fn tracing_init() { async fn test_cctl_network_starts_and_terminates() { tracing_init(); - let chainspec = Path::new(env!("CCTL_CHAINSPEC")); - let config = Path::new(env!("CCTL_CONFIG")); + let chainspec = PathBuf::from(std::env::var("CCTL_CHAINSPEC").unwrap()); + let config = PathBuf::from(std::env::var("CCTL_CONFIG").unwrap()); - let network = CCTLNetwork::run(None, None, Some(chainspec), Some(config)) - .await - .unwrap(); + let network = CCTLNetwork::run( + None, + None, + Some(chainspec.as_path()), + Some(config.as_path()), + ) + .await + .unwrap(); for node in &network.nodes { if node.state == NodeState::Running { From 0e9820d526e6a30070c71860175bbc5db8fc5c89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrzej=20Bro=C5=84ski?= Date: Thu, 25 Jul 2024 15:39:17 +0200 Subject: [PATCH 8/9] Remove unused import. --- .../tests/test_cctl_deploys_a_contract_successfully.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/kairos-test-utils/tests/test_cctl_deploys_a_contract_successfully.rs b/kairos-test-utils/tests/test_cctl_deploys_a_contract_successfully.rs index cf56d8c3..648756fd 100644 --- a/kairos-test-utils/tests/test_cctl_deploys_a_contract_successfully.rs +++ b/kairos-test-utils/tests/test_cctl_deploys_a_contract_successfully.rs @@ -2,7 +2,6 @@ use casper_types::ContractHash; use hex::FromHex; use kairos_test_utils::cctl::CCTLNetwork; use std::fs; -use std::path::Path; use std::path::PathBuf; use casper_client_types::{runtime_args, RuntimeArgs}; From 59ff5998fc9e8b2147603cd839692745f53ff257 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andrzej=20Bro=C5=84ski?= Date: Fri, 26 Jul 2024 12:34:00 +0200 Subject: [PATCH 9/9] Fix error fallback. --- kairos-test-utils/src/cctl.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/kairos-test-utils/src/cctl.rs b/kairos-test-utils/src/cctl.rs index acb30abb..0814033f 100644 --- a/kairos-test-utils/src/cctl.rs +++ b/kairos-test-utils/src/cctl.rs @@ -78,12 +78,10 @@ impl CCTLNetwork { ) -> anyhow::Result { let chainspec_path: String = chainspec_path .map(|p| p.to_str().unwrap().to_owned()) - .ok_or_else(|| std::env::var("CCTL_CHAINSPEC")) - .unwrap(); + .unwrap_or_else(|| std::env::var("CCTL_CHAINSPEC").unwrap()); let config_path: String = config_path .map(|p| p.to_str().unwrap().to_owned()) - .ok_or_else(|| std::env::var("CCTL_CONFIG")) - .unwrap(); + .unwrap_or_else(|| std::env::var("CCTL_CONFIG").unwrap()); let working_dir = working_dir .map(|dir| {