diff --git a/crates/shared/src/constants.rs b/crates/shared/src/constants.rs index 73cf975bd..a34a547ac 100644 --- a/crates/shared/src/constants.rs +++ b/crates/shared/src/constants.rs @@ -68,3 +68,6 @@ pub const TOTAL_SIGNERS: u8 = 3; /// Threshold for those signers pub const SIGNER_THRESHOLD: u8 = 2; + +/// For testing to line up chain mock data and reshare_test +pub const TEST_RESHARE_BLOCK_NUMBER: u32 = 5; diff --git a/crates/threshold-signature-server/src/validator/tests.rs b/crates/threshold-signature-server/src/validator/tests.rs index 88316c211..c419fcfe0 100644 --- a/crates/threshold-signature-server/src/validator/tests.rs +++ b/crates/threshold-signature-server/src/validator/tests.rs @@ -32,7 +32,10 @@ use crate::{ validator::{api::validate_new_reshare, errors::ValidatorErr}, }; use entropy_kvdb::clean_tests; -use entropy_shared::{OcwMessageReshare, EVE_VERIFYING_KEY, MIN_BALANCE, NETWORK_PARENT_KEY}; +use entropy_shared::{ + OcwMessageReshare, EVE_VERIFYING_KEY, MIN_BALANCE, NETWORK_PARENT_KEY, + TEST_RESHARE_BLOCK_NUMBER, +}; use entropy_testing_utils::{ constants::{ALICE_STASH_ADDRESS, RANDOM_ACCOUNT}, substrate_context::{test_node_process_testing_state, testing_context}, @@ -68,7 +71,7 @@ async fn test_reshare() { setup_for_reshare(&api, &rpc).await; - let block_number = rpc.chain_get_header(None).await.unwrap().unwrap().number + 1; + let block_number = TEST_RESHARE_BLOCK_NUMBER; let onchain_reshare_request = OcwMessageReshare { new_signer: alice.public().encode(), block_number }; diff --git a/pallets/staking/src/lib.rs b/pallets/staking/src/lib.rs index 0ace9031e..33871397f 100644 --- a/pallets/staking/src/lib.rs +++ b/pallets/staking/src/lib.rs @@ -57,7 +57,9 @@ use sp_staking::SessionIndex; #[frame_support::pallet] pub mod pallet { - use entropy_shared::{ValidatorInfo, X25519PublicKey, SIGNING_PARTY_SIZE}; + use entropy_shared::{ + ValidatorInfo, X25519PublicKey, SIGNING_PARTY_SIZE, TEST_RESHARE_BLOCK_NUMBER, + }; use frame_support::{ dispatch::{DispatchResult, DispatchResultWithPostInfo}, pallet_prelude::*, @@ -239,7 +241,8 @@ pub mod pallet { }); ReshareData::::put(ReshareInfo { - block_number: 4u32.into(), + // To give enough time for test_reshare setup + block_number: TEST_RESHARE_BLOCK_NUMBER.into(), // Alice signer public key new_signer: vec![ 212, 53, 147, 199, 21, 253, 211, 28, 97, 20, 26, 189, 4, 169, 159, 214,