-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add validator helpers to cli * add change threshold account * changelog * Apply suggestions from code review Co-authored-by: peg <peg@magmacollective.org> Co-authored-by: Hernando Castano <HCastano@users.noreply.github.com> * pull logic out to client from cli * add tests * lint * lint * clean --------- Co-authored-by: peg <peg@magmacollective.org> Co-authored-by: Hernando Castano <HCastano@users.noreply.github.com>
- Loading branch information
1 parent
62230f0
commit a1ac1f3
Showing
7 changed files
with
198 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
use crate::{ | ||
chain_api::{ | ||
entropy::{ | ||
runtime_types::pallet_staking_extension::pallet::ServerInfo, staking_extension::events, | ||
}, | ||
get_api, get_rpc, | ||
}, | ||
change_endpoint, change_threshold_accounts, | ||
}; | ||
use entropy_testing_utils::substrate_context::test_context_stationary; | ||
use serial_test::serial; | ||
use sp_core::Pair; | ||
use sp_keyring::AccountKeyring; | ||
use subxt::utils::AccountId32; | ||
|
||
#[tokio::test] | ||
#[serial] | ||
async fn test_change_endpoint() { | ||
let one = AccountKeyring::AliceStash; | ||
let substrate_context = test_context_stationary().await; | ||
|
||
let api = get_api(&substrate_context.node_proc.ws_url).await.unwrap(); | ||
let rpc = get_rpc(&substrate_context.node_proc.ws_url).await.unwrap(); | ||
|
||
let result = change_endpoint(&api, &rpc, one.into(), "new_endpoint".to_string()).await.unwrap(); | ||
assert_eq!( | ||
format!("{:?}", result), | ||
format!( | ||
"{:?}", | ||
events::EndpointChanged( | ||
AccountId32(one.pair().public().0), | ||
"new_endpoint".as_bytes().to_vec() | ||
) | ||
) | ||
); | ||
} | ||
|
||
#[tokio::test] | ||
#[serial] | ||
async fn test_change_threhsold_accounts() { | ||
let one = AccountKeyring::AliceStash; | ||
let substrate_context = test_context_stationary().await; | ||
|
||
let api = get_api(&substrate_context.node_proc.ws_url).await.unwrap(); | ||
let rpc = get_rpc(&substrate_context.node_proc.ws_url).await.unwrap(); | ||
let x25519_public_key = [0u8; 32]; | ||
let result = change_threshold_accounts( | ||
&api, | ||
&rpc, | ||
one.into(), | ||
AccountId32(one.pair().public().0.into()).to_string(), | ||
hex::encode(x25519_public_key), | ||
) | ||
.await | ||
.unwrap(); | ||
assert_eq!( | ||
format!("{:?}", result), | ||
format!( | ||
"{:?}", | ||
events::ThresholdAccountChanged( | ||
AccountId32(one.pair().public().0), | ||
ServerInfo { | ||
tss_account: AccountId32(one.pair().public().0), | ||
x25519_public_key, | ||
endpoint: "127.0.0.1:3001".as_bytes().to_vec() | ||
} | ||
) | ||
) | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters