From 121714f63a10e902fdffe3188a12f9e7ee80abf9 Mon Sep 17 00:00:00 2001 From: JesseAbram <33698952+JesseAbram@users.noreply.github.com> Date: Tue, 1 Oct 2024 17:52:16 -0400 Subject: [PATCH] Fix master build (#1088) * Fix master build * fix * Fix race condition * increase TEST_RESHARE_BLOCK * add logger to sign eth * fix do jump start * fmt --- crates/shared/src/constants.rs | 2 +- .../src/helpers/tests.rs | 29 ++++++++++--------- .../src/validator/tests.rs | 3 +- .../tests/sign_eth_tx.rs | 3 +- 4 files changed, 21 insertions(+), 16 deletions(-) diff --git a/crates/shared/src/constants.rs b/crates/shared/src/constants.rs index c2bc4d689..e592a9889 100644 --- a/crates/shared/src/constants.rs +++ b/crates/shared/src/constants.rs @@ -75,7 +75,7 @@ pub const MAX_SIGNERS: u8 = 15; pub const SIGNER_THRESHOLD: u8 = 2; /// For testing to line up chain mock data and reshare_test -pub const TEST_RESHARE_BLOCK_NUMBER: u32 = 7; +pub const TEST_RESHARE_BLOCK_NUMBER: u32 = 9; /// Program version number, must be incremented if version number changes pub const PROGRAM_VERSION_NUMBER: u8 = 0; diff --git a/crates/threshold-signature-server/src/helpers/tests.rs b/crates/threshold-signature-server/src/helpers/tests.rs index 4e85966fd..ef3b37c7e 100644 --- a/crates/threshold-signature-server/src/helpers/tests.rs +++ b/crates/threshold-signature-server/src/helpers/tests.rs @@ -365,6 +365,7 @@ pub async fn do_jump_start( rpc: &LegacyRpcMethods, pair: sr25519::Pair, ) { + run_to_block(rpc, 2).await; let block_number = rpc.chain_get_header(None).await.unwrap().unwrap().number + 1; put_jumpstart_request_on_chain(api, rpc, pair).await; @@ -374,21 +375,23 @@ pub async fn do_jump_start( let validators_info = query_chain(api, rpc, selected_validators_query, None).await.unwrap().unwrap(); let validators_info: Vec<_> = validators_info.into_iter().map(|v| v.0).collect(); - let onchain_user_request = OcwMessageDkg { block_number, validators_info }; + let onchain_user_request = + OcwMessageDkg { block_number, validators_info: validators_info.clone() }; let client = reqwest::Client::new(); - let response_results = join_all( - [3002, 3003, 3004] - .iter() - .map(|port| { - client - .post(format!("http://127.0.0.1:{}/generate_network_key", port)) - .body(onchain_user_request.clone().encode()) - .send() - }) - .collect::>(), - ) - .await; + + let mut results = vec![]; + for validator_info in validators_info { + let url = format!( + "http://{}/generate_network_key", + std::str::from_utf8(&validator_info.ip_address.clone()).unwrap() + ); + if url != *"http://127.0.0.1:3001/generate_network_key" { + results.push(client.post(url).body(onchain_user_request.clone().encode()).send()) + } + } + + let response_results = join_all(results).await; let jump_start_status_query = entropy::storage().staking_extension().jump_start_progress(); let mut jump_start_status = query_chain(api, rpc, jump_start_status_query.clone(), None) diff --git a/crates/threshold-signature-server/src/validator/tests.rs b/crates/threshold-signature-server/src/validator/tests.rs index a82e0aa58..3bdefba2e 100644 --- a/crates/threshold-signature-server/src/validator/tests.rs +++ b/crates/threshold-signature-server/src/validator/tests.rs @@ -220,8 +220,9 @@ async fn test_reshare() { ); } + let current_block_number = rpc.chain_get_header(None).await.unwrap().unwrap().number; // Check that rotating the network key wont work again later - run_to_block(&rpc, block_number + 9).await; + run_to_block(&rpc, current_block_number + 3).await; let response_stale = client.post("http://127.0.0.1:3001/validator/rotate_network_key").send().await.unwrap(); diff --git a/crates/threshold-signature-server/tests/sign_eth_tx.rs b/crates/threshold-signature-server/tests/sign_eth_tx.rs index 16f946baf..e8564065f 100644 --- a/crates/threshold-signature-server/tests/sign_eth_tx.rs +++ b/crates/threshold-signature-server/tests/sign_eth_tx.rs @@ -26,7 +26,7 @@ use entropy_testing_utils::{ constants::{AUXILARY_DATA_SHOULD_SUCCEED, TEST_PROGRAM_WASM_BYTECODE}, spawn_testing_validators, test_node_process_testing_state, ChainSpecType, }; -use entropy_tss::helpers::tests::do_jump_start; +use entropy_tss::helpers::tests::{do_jump_start, initialize_test_logger}; use ethers_core::{ abi::ethabi::ethereum_types::{H160, H256}, types::{RecoveryMessage, Transaction, TransactionRequest, U256}, @@ -46,6 +46,7 @@ const GOERLI_CHAIN_ID: u64 = 5; #[tokio::test] #[serial] async fn integration_test_sign_eth_tx() { + initialize_test_logger().await; clean_tests(); let (_validator_ips, _validator_ids) =