Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

Commit 19f39f6

Browse files
committed
test: author_insertKey
1 parent 075e613 commit 19f39f6

File tree

1 file changed

+16
-44
lines changed

1 file changed

+16
-44
lines changed

client/rpc/src/author/tests.rs

Lines changed: 16 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -243,50 +243,22 @@ async fn author_should_remove_extrinsics() {
243243
assert_eq!(removed.result, vec![xt1_hash, xt2_hash, xt3_hash]);
244244
}
245245

246-
// #[test]
247-
// fn should_remove_extrinsics() {
248-
// let setup = TestSetup::default();
249-
// let p = setup.author();
250-
251-
// let ex1 = uxt(AccountKeyring::Alice, 0);
252-
// executor::block_on(p.submit_extrinsic(ex1.encode().into())).unwrap();
253-
// let ex2 = uxt(AccountKeyring::Alice, 1);
254-
// executor::block_on(p.submit_extrinsic(ex2.encode().into())).unwrap();
255-
// let ex3 = uxt(AccountKeyring::Bob, 0);
256-
// let hash3 = executor::block_on(p.submit_extrinsic(ex3.encode().into())).unwrap();
257-
// assert_eq!(setup.pool.status().ready, 3);
258-
259-
// // now remove all 3
260-
// let removed = p
261-
// .remove_extrinsic(vec![
262-
// hash::ExtrinsicOrHash::Hash(hash3),
263-
// // Removing this one will also remove ex2
264-
// hash::ExtrinsicOrHash::Extrinsic(ex1.encode().into()),
265-
// ])
266-
// .unwrap();
267-
268-
// assert_eq!(removed.len(), 3);
269-
// }
270-
271-
// #[test]
272-
// fn should_insert_key() {
273-
// let setup = TestSetup::default();
274-
// let p = setup.author();
275-
276-
// let suri = "//Alice";
277-
// let key_pair = ed25519::Pair::from_string(suri, None).expect("Generates keypair");
278-
// p.insert_key(
279-
// String::from_utf8(ED25519.0.to_vec()).expect("Keytype is a valid string"),
280-
// suri.to_string(),
281-
// key_pair.public().0.to_vec().into(),
282-
// )
283-
// .expect("Insert key");
284-
285-
// let public_keys = SyncCryptoStore::keys(&*setup.keystore, ED25519).unwrap();
286-
287-
// assert!(public_keys
288-
// .contains(&CryptoTypePublicPair(ed25519::CRYPTO_ID, key_pair.public().to_raw_vec())));
289-
// }
246+
#[tokio::test]
247+
async fn author_should_insert_key() {
248+
let setup = TestSetup::default();
249+
let api = setup.author().into_rpc();
250+
let suri = "//Alice";
251+
let keypair = ed25519::Pair::from_string(suri, None).expect("generates keypair");
252+
let params: (String, String, Bytes) = (
253+
String::from_utf8(ED25519.0.to_vec()).expect("Keytype is a valid string"),
254+
suri.to_string(),
255+
keypair.public().0.to_vec().into(),
256+
);
257+
api.call_with("author_insertKey", params).await.unwrap();
258+
let pubkeys = SyncCryptoStore::keys(&*setup.keystore, ED25519).unwrap();
259+
260+
assert!(pubkeys.contains(&CryptoTypePublicPair(ed25519::CRYPTO_ID, keypair.public().to_raw_vec())));
261+
}
290262

291263
// #[test]
292264
// fn should_rotate_keys() {

0 commit comments

Comments
 (0)