From aa86bd30dd959bf619deb2bbff7a65408dd26d8e Mon Sep 17 00:00:00 2001 From: jonas pauli Date: Thu, 2 May 2024 23:16:35 +0200 Subject: [PATCH] temporary fix --- flake.lock | 12 ++++++------ kairos-l1-utils/src/lib.rs | 25 ++++++++++++++++--------- kairos-test-utils/src/cctl.rs | 1 - 3 files changed, 22 insertions(+), 16 deletions(-) diff --git a/flake.lock b/flake.lock index 377f026d..0c21367c 100644 --- a/flake.lock +++ b/flake.lock @@ -66,11 +66,11 @@ "rust-analyzer-src": "rust-analyzer-src" }, "locked": { - "lastModified": 1714285404, - "narHash": "sha256-MmoQIO+KRiH3UnH0myAp2Fgi84rmpROMfw9VIbqrjHA=", + "lastModified": 1714631076, + "narHash": "sha256-at4+1R9gx3CGvX0ZJo9GwDZyt3RzOft7qDCTsYHjI4M=", "owner": "nix-community", "repo": "fenix", - "rev": "94be183087845937b0fd77281c37d0796572b899", + "rev": "22a9eb3f20dd340d084cee4426f386a90b1351ca", "type": "github" }, "original": { @@ -199,11 +199,11 @@ "rust-analyzer-src": { "flake": false, "locked": { - "lastModified": 1714217560, - "narHash": "sha256-zttBYGaoHpZfqWHQ8OI5f9OkGHCHb8tDBMySwsYNa2U=", + "lastModified": 1714572655, + "narHash": "sha256-xjD8vmit0Nz1qaSSSpeXOK3saSvAZtOGHS2SHZE75Ek=", "owner": "rust-lang", "repo": "rust-analyzer", - "rev": "f216be4a0746142c5f30835b254871256a7637b8", + "rev": "cfce2bb46da62950a8b70ddb0b2a12332da1b1e1", "type": "github" }, "original": { diff --git a/kairos-l1-utils/src/lib.rs b/kairos-l1-utils/src/lib.rs index 3aea2263..06a22232 100644 --- a/kairos-l1-utils/src/lib.rs +++ b/kairos-l1-utils/src/lib.rs @@ -2,7 +2,7 @@ use casper_client::{ get_state_root_hash, query_global_state, types::StoredValue, JsonRpcId, Verbosity, }; use casper_hashing::Digest; -use casper_types::URef; +use casper_types::{account::AccountHash, PublicKey, URef}; use casper_client::{ rpcs::results::PutDeployResult, @@ -10,7 +10,7 @@ use casper_client::{ SuccessResponse, }; use casper_types::{crypto::SecretKey, Key, RuntimeArgs}; -use std::fs; +use std::{fs, thread, time::Duration}; pub const DEFAULT_PAYMENT_AMOUNT: u64 = 1_000_000_000_000; @@ -51,7 +51,7 @@ pub async fn query_state_root_hash(node_address: &str) -> Digest { None, ) .await - .unwrap() + .expect("Failed to get state root hash") .result .state_root_hash .unwrap() @@ -88,7 +88,7 @@ async fn query_stored_value( path, ) .await - .unwrap() + .expect("Failed to query stored value") .result .stored_value } @@ -119,7 +119,7 @@ pub async fn query_contract_counter( value } - +/* #[cfg_attr(not(feature = "cctl-tests"), ignore)] #[tokio::test] async fn install_wasm() { @@ -198,6 +198,7 @@ async fn install_wasm() { .await .unwrap() } +*/ #[cfg_attr(not(feature = "cctl-tests"), ignore)] #[tokio::test] @@ -277,11 +278,17 @@ async fn counter_query_test() { .await .unwrap(); + // replace this with a better solution + thread::sleep(Duration::from_secs(10)); + + let public_key_path = network + .assets_dir + .join("users/user-1/public_key.pem"); + + let public_key: PublicKey = PublicKey::from_file(public_key_path.to_str().unwrap()).unwrap(); + let account_hash: AccountHash = public_key.to_account_hash(); // this is the default cctl account for user-1 - let account: Key = Key::from_formatted_str( - "account-hash-5a9eb1f7da515d9fa2f0b74e18ec84cccf90f146269d538073416dff432a3c77", - ) - .unwrap(); + let account: Key = Key::from(account_hash); let srh: Digest = query_state_root_hash(node_address).await; let counter_value: u64 = query_contract_counter( node_address, diff --git a/kairos-test-utils/src/cctl.rs b/kairos-test-utils/src/cctl.rs index 897d9f55..6b12c639 100644 --- a/kairos-test-utils/src/cctl.rs +++ b/kairos-test-utils/src/cctl.rs @@ -133,7 +133,6 @@ impl Drop for CCTLNetwork { #[cfg(test)] mod tests { use super::*; - #[cfg_attr(not(feature = "cctl-tests"), ignore)] #[tokio::test] async fn test_cctl_network_starts_and_terminates() {