Skip to content

Commit

Permalink
clean
Browse files Browse the repository at this point in the history
  • Loading branch information
JesseAbram committed Dec 16, 2024
1 parent 40997da commit 246351d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 17 deletions.
2 changes: 1 addition & 1 deletion crates/threshold-signature-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ axum ={ version="0.7.9", features=["ws"] }
subxt ="0.35.3"
parity-scale-codec="3.6.12"
sp-core ={ version="31.0.0", default-features=false }
sp-keyring ="34.0.0"

# Entropy
entropy-shared ={ version="0.3.0", path="../shared" }
Expand Down Expand Up @@ -79,7 +80,6 @@ configfs-tsm ={ version="0.0.1", optional=true }
serial_test ="3.2.0"
hex-literal ="0.4.1"
project-root="0.2.2"
sp-keyring ="34.0.0"
more-asserts="0.3.1"
lazy_static ="1.5.0"
blake3 ="1.5.5"
Expand Down
16 changes: 9 additions & 7 deletions crates/threshold-signature-server/src/helpers/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ use crate::{
chain_api::{
entropy::{
self,
runtime_types::pallet_staking_extension::pallet::{JumpStartStatus, ServerInfo},
runtime_types::entropy_runtime::RuntimeCall,
runtime_types::pallet_staking_extension::pallet::{JumpStartStatus, ServerInfo},
},
EntropyConfig,
},
Expand All @@ -49,14 +49,13 @@ use entropy_protocol::PartyId;
#[cfg(test)]
use entropy_shared::EncodedVerifyingKey;
use entropy_shared::NETWORK_PARENT_KEY;
use sp_keyring::AccountKeyring;
use std::{fmt, net::SocketAddr, str, time::Duration};
use subxt::{
backend::legacy::LegacyRpcMethods, ext::sp_core::sr25519, tx::{PairSigner, TxPayload},
utils::AccountId32 as SubxtAccountId32, Config, OnlineClient, config::PolkadotExtrinsicParamsBuilder as Params
backend::legacy::LegacyRpcMethods, ext::sp_core::sr25519, tx::PairSigner,
utils::AccountId32 as SubxtAccountId32, Config, OnlineClient,
};
use tokio::sync::OnceCell;
#[cfg(test)]
use sp_keyring::AccountKeyring;

/// A shared reference to the logger used for tests.
///
Expand Down Expand Up @@ -374,8 +373,11 @@ pub fn get_port(server_info: &ServerInfo<SubxtAccountId32>) -> u32 {
socket_address.port().into()
}

#[cfg(test)]
pub async fn call_set_storage(api: &OnlineClient<EntropyConfig>, rpc: &LegacyRpcMethods<EntropyConfig>, call: RuntimeCall) {
pub async fn call_set_storage(
api: &OnlineClient<EntropyConfig>,
rpc: &LegacyRpcMethods<EntropyConfig>,
call: RuntimeCall,
) {
let set_storage = entropy::tx().sudo().sudo(call);
let alice = AccountKeyring::Alice;

Expand Down
17 changes: 8 additions & 9 deletions crates/threshold-signature-server/src/validator/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ use crate::{
use entropy_client::{self as test_client};
use entropy_client::{
chain_api::{
entropy, entropy::runtime_types::bounded_collections::bounded_vec::BoundedVec,
entropy,
entropy::runtime_types::bounded_collections::bounded_vec::BoundedVec,
entropy::runtime_types::entropy_runtime::RuntimeCall,
entropy::runtime_types::entropy_runtime::RuntimeCall::StakingExtension,
entropy::runtime_types::frame_system::pallet::Call as SystemsCall,
entropy::runtime_types::pallet_registry::pallet::ProgramInstance,
entropy::runtime_types::pallet_staking_extension::pallet::{ReshareInfo, NextSignerInfo}, get_api, get_rpc,
EntropyConfig,
entropy::runtime_types::pallet_staking_extension::pallet::{NextSignerInfo, ReshareInfo},
get_api, get_rpc,
},
substrate::query_chain,
Hasher,
Expand All @@ -55,7 +55,7 @@ use serial_test::serial;
use sp_core::Pair;
use sp_keyring::AccountKeyring;
use std::collections::HashSet;
use subxt::{config::PolkadotExtrinsicParamsBuilder as Params, tx::PairSigner, utils::AccountId32};
use subxt::utils::AccountId32;
use synedrion::k256::ecdsa::VerifyingKey;

#[tokio::test]
Expand All @@ -74,7 +74,6 @@ async fn test_reshare_basic() {
.await;
let api = get_api(&context[0].ws_url).await.unwrap();
let rpc = get_rpc(&context[0].ws_url).await.unwrap();
let alice = AccountKeyring::Alice;
let alice_stash = AccountKeyring::AliceStash;
let client = reqwest::Client::new();

Expand Down Expand Up @@ -191,17 +190,17 @@ async fn test_reshare_basic() {
let block_number = rpc.chain_get_header(None).await.unwrap().unwrap().number + 2;
let key_share_before_2 = unsafe_get(&client, hex::encode(NETWORK_PARENT_KEY), 3002).await;


let storage_address_next_signers = entropy::storage().staking_extension().next_signers();
let value_next_signers = NextSignerInfo { confirmations: vec![], next_signers: next_signers };
let value_next_signers = NextSignerInfo { confirmations: vec![], next_signers };
// Add another reshare
let call = RuntimeCall::System(SystemsCall::set_storage {
items: vec![(storage_address_next_signers.to_root_bytes(), value_next_signers.encode())],
});
call_set_storage(&api, &rpc, call).await;

let storage_address_reshare_data = entropy::storage().staking_extension().reshare_data();
let value_reshare_info = ReshareInfo { block_number, new_signers: vec![alice_stash.public().encode()] };
let value_reshare_info =
ReshareInfo { block_number, new_signers: vec![alice_stash.public().encode()] };
// Add another reshare
let call = RuntimeCall::System(SystemsCall::set_storage {
items: vec![(storage_address_reshare_data.to_root_bytes(), value_reshare_info.encode())],
Expand Down

0 comments on commit 246351d

Please sign in to comment.