diff --git a/.github/workflows/build-and-run-node-test.yaml b/.github/workflows/build-and-run-node-test.yaml index 0c28340f6..abc505b38 100644 --- a/.github/workflows/build-and-run-node-test.yaml +++ b/.github/workflows/build-and-run-node-test.yaml @@ -33,7 +33,5 @@ jobs: - name: Run `cargo build && cargo test` run: | pushd node - cargo build --all-targets --release -j $(nproc) - cargo test --all-targets --release - yarn --cwd ../crates/protocol/nodejs-test test - cargo test -p entropy-tss --release --features=test_helpers -F wasm_test test_wasm + cd crates/threshold-signature-server + cargo test --release -- --test integration_test_register_sign_reshare_sign --nocapture \ No newline at end of file diff --git a/crates/threshold-signature-server/src/helpers/tests.rs b/crates/threshold-signature-server/src/helpers/tests.rs index ef3b37c7e..079fe1924 100644 --- a/crates/threshold-signature-server/src/helpers/tests.rs +++ b/crates/threshold-signature-server/src/helpers/tests.rs @@ -358,18 +358,20 @@ pub async fn store_program_and_register( (verifying_key, program_hash) } - /// Do a network jumpstart DKG pub async fn do_jump_start( api: &OnlineClient, rpc: &LegacyRpcMethods, pair: sr25519::Pair, + other_chains: &[LegacyRpcMethods], ) { run_to_block(rpc, 2).await; + log_all_block_numbers(other_chains).await; let block_number = rpc.chain_get_header(None).await.unwrap().unwrap().number + 1; put_jumpstart_request_on_chain(api, rpc, pair).await; run_to_block(rpc, block_number + 1).await; + log_all_block_numbers(other_chains).await; let selected_validators_query = entropy::storage().registry().jumpstart_dkg(block_number); let validators_info = @@ -381,6 +383,7 @@ pub async fn do_jump_start( let client = reqwest::Client::new(); let mut results = vec![]; + log_all_block_numbers(other_chains).await; for validator_info in validators_info { let url = format!( "http://{}/generate_network_key", @@ -390,9 +393,14 @@ pub async fn do_jump_start( results.push(client.post(url).body(onchain_user_request.clone().encode()).send()) } } + log_all_block_numbers(other_chains).await; let response_results = join_all(results).await; + for response_result in response_results { + assert_eq!(response_result.unwrap().text().await.unwrap(), ""); + } + 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) .await @@ -414,8 +422,12 @@ pub async fn do_jump_start( } assert_eq!(format!("{:?}", jump_start_status), format!("{:?}", JumpStartStatus::Done)); - for response_result in response_results { - assert_eq!(response_result.unwrap().text().await.unwrap(), ""); +} + +pub async fn log_all_block_numbers(other_chains: &[LegacyRpcMethods]) { + for (i, other_chain) in other_chains.iter().enumerate() { + let block_number = other_chain.chain_get_header(None).await.unwrap().unwrap().number; + tracing::info!("Block number for rpc `{}`: `{}`", i, block_number); } } diff --git a/crates/threshold-signature-server/src/user/tests.rs b/crates/threshold-signature-server/src/user/tests.rs index 0290d4fef..0f9da21e0 100644 --- a/crates/threshold-signature-server/src/user/tests.rs +++ b/crates/threshold-signature-server/src/user/tests.rs @@ -907,12 +907,18 @@ async fn test_jumpstart_network() { spawn_testing_validators(ChainSpecType::Integration).await; let force_authoring = true; - let substrate_context = &test_node_process_testing_state(force_authoring).await[0]; + let substrate_context = &test_node_process_testing_state(force_authoring).await; - let api = get_api(&substrate_context.ws_url).await.unwrap(); - let rpc = get_rpc(&substrate_context.ws_url).await.unwrap(); + let api = get_api(&substrate_context[0].ws_url).await.unwrap(); + let rpc = get_rpc(&substrate_context[0].ws_url).await.unwrap(); + + let mut other_rpcs = vec![]; + for context in substrate_context { + let next_rpc = get_rpc(&context.ws_url).await.unwrap(); + other_rpcs.push(next_rpc) + } - do_jump_start(&api, &rpc, AccountKeyring::Alice.pair()).await; + do_jump_start(&api, &rpc, AccountKeyring::Alice.pair(), &other_rpcs).await; let client = reqwest::Client::new(); let response_key = unsafe_get(&client, hex::encode(NETWORK_PARENT_KEY), 3001).await; diff --git a/crates/threshold-signature-server/src/validator/api.rs b/crates/threshold-signature-server/src/validator/api.rs index aff360cb5..2abc1a351 100644 --- a/crates/threshold-signature-server/src/validator/api.rs +++ b/crates/threshold-signature-server/src/validator/api.rs @@ -266,6 +266,8 @@ pub async fn validate_new_reshare( // we subtract 1 as the message info is coming from the previous block if latest_block_number.saturating_sub(1) != chain_data.block_number { + tracing::info!("latest_block_number: {}", latest_block_number.saturating_sub(1)); + tracing::info!("chain_data.block_number: {}", chain_data.block_number); return Err(ValidatorErr::StaleData); } diff --git a/crates/threshold-signature-server/tests/register_sign_reshare_sign.rs b/crates/threshold-signature-server/tests/register_sign_reshare_sign.rs index 3115d30ec..c59d374ab 100644 --- a/crates/threshold-signature-server/tests/register_sign_reshare_sign.rs +++ b/crates/threshold-signature-server/tests/register_sign_reshare_sign.rs @@ -33,7 +33,9 @@ use entropy_testing_utils::{ }, spawn_testing_validators, test_node_process_testing_state, ChainSpecType, }; -use entropy_tss::helpers::tests::{do_jump_start, initialize_test_logger, run_to_block}; +use entropy_tss::helpers::tests::{ + do_jump_start, initialize_test_logger, log_all_block_numbers, run_to_block, +}; use futures::future::join_all; use serial_test::serial; use sp_core::{Encode, Pair}; @@ -51,13 +53,19 @@ async fn integration_test_register_sign_reshare_sign() { spawn_testing_validators(ChainSpecType::Integration).await; let force_authoring = true; - let substrate_context = &test_node_process_testing_state(force_authoring).await[0]; + let substrate_context = &test_node_process_testing_state(force_authoring).await; + + let api = get_api(&substrate_context[0].ws_url).await.unwrap(); + let rpc = get_rpc(&substrate_context[0].ws_url).await.unwrap(); - let api = get_api(&substrate_context.ws_url).await.unwrap(); - let rpc = get_rpc(&substrate_context.ws_url).await.unwrap(); + let mut other_rpcs = vec![]; + for context in substrate_context { + let next_rpc = get_rpc(&context.ws_url).await.unwrap(); + other_rpcs.push(next_rpc) + } // First jumpstart the network - do_jump_start(&api, &rpc, AccountKeyring::Alice.pair()).await; + do_jump_start(&api, &rpc, AccountKeyring::Alice.pair(), &other_rpcs).await; // Now register an account let account_owner = AccountKeyring::Ferdie.pair(); @@ -114,7 +122,7 @@ async fn integration_test_register_sign_reshare_sign() { ); // Do a reshare - do_reshare(&api, &rpc).await; + do_reshare(&api, &rpc, &other_rpcs).await; // Sign a message again let recoverable_signature = test_client::sign( @@ -142,7 +150,11 @@ async fn integration_test_register_sign_reshare_sign() { ); } -async fn do_reshare(api: &OnlineClient, rpc: &LegacyRpcMethods) { +async fn do_reshare( + api: &OnlineClient, + rpc: &LegacyRpcMethods, + rpcs: &[LegacyRpcMethods], +) { // Get current signers let signer_query = entropy::storage().staking_extension().signers(); let signer_stash_accounts = query_chain(&api, &rpc, signer_query, None).await.unwrap().unwrap(); @@ -161,13 +173,13 @@ async fn do_reshare(api: &OnlineClient, rpc: &LegacyRpcMethods, rpc: &LegacyRpcMethods>(), ) .await; - for response_result in response_results { + for (i, response_result) in response_results.into_iter().enumerate() { + dbg!(ips[i]); assert_eq!(response_result.unwrap().text().await.unwrap(), ""); } @@ -215,3 +228,12 @@ async fn do_reshare(api: &OnlineClient, rpc: &LegacyRpcMethods = new_signer_stash_accounts.iter().map(|s| s.0).collect(); assert_ne!(old, new); } + +pub async fn run_to_all_blocks(rpcs: &[LegacyRpcMethods], block_run: u32) { + let mut current_block = 0; + for rpc in rpcs { + while current_block < block_run { + current_block = rpc.chain_get_header(None).await.unwrap().unwrap().number; + } + } +} diff --git a/crates/threshold-signature-server/tests/sign_eth_tx.rs b/crates/threshold-signature-server/tests/sign_eth_tx.rs index e8564065f..c9ae1238d 100644 --- a/crates/threshold-signature-server/tests/sign_eth_tx.rs +++ b/crates/threshold-signature-server/tests/sign_eth_tx.rs @@ -53,13 +53,19 @@ async fn integration_test_sign_eth_tx() { spawn_testing_validators(ChainSpecType::Integration).await; let force_authoring = true; - let substrate_context = &test_node_process_testing_state(force_authoring).await[0]; + let substrate_context = &test_node_process_testing_state(force_authoring).await; - let api = get_api(&substrate_context.ws_url).await.unwrap(); - let rpc = get_rpc(&substrate_context.ws_url).await.unwrap(); + let api = get_api(&substrate_context[0].ws_url).await.unwrap(); + let rpc = get_rpc(&substrate_context[0].ws_url).await.unwrap(); + + let mut other_rpcs = vec![]; + for context in substrate_context { + let next_rpc = get_rpc(&context.ws_url).await.unwrap(); + other_rpcs.push(next_rpc) + } // First jumpstart the network - do_jump_start(&api, &rpc, AccountKeyring::Alice.pair()).await; + do_jump_start(&api, &rpc, AccountKeyring::Alice.pair(), &other_rpcs).await; let account_owner = AccountKeyring::Ferdie.pair(); let signature_request_author = AccountKeyring::One;