mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-01 05:27:56 +00:00
* Fix keystore types * Use SyncCryptoStorePtr * Borrow keystore * Fix unused imports * Fix polkadot service * Fix bitfield-distribution tests * Fix indentation * Fix backing tests * Fix tests * Fix provisioner tests * Removed SyncCryptoStorePtr * Fix services * Address PR feedback * Address PR feedback - 2 * Update CryptoStorePtr imports to be from sp_keystore * Typo * Fix CryptoStore import * Document the reason behind using filesystem keystore * Remove VALIDATORS * Fix duplicate dependency * Mark sp-keystore as optional * Fix availability distribution * Fix call to sign_with * Fix keystore usage * Remove tokio and fix parachains Cargo config * Typos * Fix keystore dereferencing * Fix CryptoStore import * Fix provisioner * Fix node backing * Update services * Cleanup dependencies * Use sync_keystore * Fix node service * Fix node service - 2 * Fix node service - 3 * Rename CryptoStorePtr to SyncCryptoStorePtr * "Update Substrate" * Apply suggestions from code review * Update node/core/backing/Cargo.toml * Update primitives/src/v0.rs Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com> * Fix wasm build * Update Cargo.lock Co-authored-by: parity-processbot <> Co-authored-by: Bastian Köcher <bkchr@users.noreply.github.com>
This commit is contained in:
@@ -978,11 +978,15 @@ impl metrics::Metrics for Metrics {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use std::sync::Arc;
|
||||
use sp_keyring::Sr25519Keyring;
|
||||
use sp_application_crypto::AppKey;
|
||||
use node_primitives::Statement;
|
||||
use polkadot_primitives::v1::CommittedCandidateReceipt;
|
||||
use assert_matches::assert_matches;
|
||||
use futures::executor;
|
||||
use futures::executor::{self, block_on};
|
||||
use sp_keystore::{CryptoStore, SyncCryptoStorePtr, SyncCryptoStore};
|
||||
use sc_keystore::LocalKeystore;
|
||||
|
||||
#[test]
|
||||
fn active_head_accepts_only_2_seconded_per_validator() {
|
||||
@@ -1022,13 +1026,22 @@ mod tests {
|
||||
|
||||
let mut head_data = ActiveHeadData::new(validators, session_index);
|
||||
|
||||
let keystore: SyncCryptoStorePtr = Arc::new(LocalKeystore::in_memory());
|
||||
let alice_public = SyncCryptoStore::sr25519_generate_new(
|
||||
&*keystore, ValidatorId::ID, Some(&Sr25519Keyring::Alice.to_seed())
|
||||
).unwrap();
|
||||
let bob_public = SyncCryptoStore::sr25519_generate_new(
|
||||
&*keystore, ValidatorId::ID, Some(&Sr25519Keyring::Bob.to_seed())
|
||||
).unwrap();
|
||||
|
||||
// note A
|
||||
let a_seconded_val_0 = SignedFullStatement::sign(
|
||||
let a_seconded_val_0 = block_on(SignedFullStatement::sign(
|
||||
&keystore,
|
||||
Statement::Seconded(candidate_a.clone()),
|
||||
&signing_context,
|
||||
0,
|
||||
&Sr25519Keyring::Alice.pair().into(),
|
||||
);
|
||||
&alice_public.into(),
|
||||
)).expect("should be signed");
|
||||
let noted = head_data.note_statement(a_seconded_val_0.clone());
|
||||
|
||||
assert_matches!(noted, NotedStatement::Fresh(_));
|
||||
@@ -1039,42 +1052,46 @@ mod tests {
|
||||
assert_matches!(noted, NotedStatement::UsefulButKnown);
|
||||
|
||||
// note B
|
||||
let noted = head_data.note_statement(SignedFullStatement::sign(
|
||||
let noted = head_data.note_statement(block_on(SignedFullStatement::sign(
|
||||
&keystore,
|
||||
Statement::Seconded(candidate_b.clone()),
|
||||
&signing_context,
|
||||
0,
|
||||
&Sr25519Keyring::Alice.pair().into(),
|
||||
));
|
||||
&alice_public.into(),
|
||||
)).expect("should be signed"));
|
||||
|
||||
assert_matches!(noted, NotedStatement::Fresh(_));
|
||||
|
||||
// note C (beyond 2 - ignored)
|
||||
let noted = head_data.note_statement(SignedFullStatement::sign(
|
||||
let noted = head_data.note_statement(block_on(SignedFullStatement::sign(
|
||||
&keystore,
|
||||
Statement::Seconded(candidate_c.clone()),
|
||||
&signing_context,
|
||||
0,
|
||||
&Sr25519Keyring::Alice.pair().into(),
|
||||
));
|
||||
&alice_public.into(),
|
||||
)).expect("should be signed"));
|
||||
|
||||
assert_matches!(noted, NotedStatement::NotUseful);
|
||||
|
||||
// note B (new validator)
|
||||
let noted = head_data.note_statement(SignedFullStatement::sign(
|
||||
let noted = head_data.note_statement(block_on(SignedFullStatement::sign(
|
||||
&keystore,
|
||||
Statement::Seconded(candidate_b.clone()),
|
||||
&signing_context,
|
||||
1,
|
||||
&Sr25519Keyring::Bob.pair().into(),
|
||||
));
|
||||
&bob_public.into(),
|
||||
)).expect("should be signed"));
|
||||
|
||||
assert_matches!(noted, NotedStatement::Fresh(_));
|
||||
|
||||
// note C (new validator)
|
||||
let noted = head_data.note_statement(SignedFullStatement::sign(
|
||||
let noted = head_data.note_statement(block_on(SignedFullStatement::sign(
|
||||
&keystore,
|
||||
Statement::Seconded(candidate_c.clone()),
|
||||
&signing_context,
|
||||
1,
|
||||
&Sr25519Keyring::Bob.pair().into(),
|
||||
));
|
||||
&bob_public.into(),
|
||||
)).expect("should be signed"));
|
||||
|
||||
assert_matches!(noted, NotedStatement::Fresh(_));
|
||||
}
|
||||
@@ -1252,33 +1269,48 @@ mod tests {
|
||||
session_index,
|
||||
};
|
||||
|
||||
let keystore: SyncCryptoStorePtr = Arc::new(LocalKeystore::in_memory());
|
||||
|
||||
let alice_public = SyncCryptoStore::sr25519_generate_new(
|
||||
&*keystore, ValidatorId::ID, Some(&Sr25519Keyring::Alice.to_seed())
|
||||
).unwrap();
|
||||
let bob_public = SyncCryptoStore::sr25519_generate_new(
|
||||
&*keystore, ValidatorId::ID, Some(&Sr25519Keyring::Bob.to_seed())
|
||||
).unwrap();
|
||||
let charlie_public = SyncCryptoStore::sr25519_generate_new(
|
||||
&*keystore, ValidatorId::ID, Some(&Sr25519Keyring::Charlie.to_seed())
|
||||
).unwrap();
|
||||
|
||||
let new_head_data = {
|
||||
let mut data = ActiveHeadData::new(validators, session_index);
|
||||
|
||||
let noted = data.note_statement(SignedFullStatement::sign(
|
||||
let noted = data.note_statement(block_on(SignedFullStatement::sign(
|
||||
&keystore,
|
||||
Statement::Seconded(candidate.clone()),
|
||||
&signing_context,
|
||||
0,
|
||||
&Sr25519Keyring::Alice.pair().into(),
|
||||
));
|
||||
&alice_public.into(),
|
||||
)).expect("should be signed"));
|
||||
|
||||
assert_matches!(noted, NotedStatement::Fresh(_));
|
||||
|
||||
let noted = data.note_statement(SignedFullStatement::sign(
|
||||
let noted = data.note_statement(block_on(SignedFullStatement::sign(
|
||||
&keystore,
|
||||
Statement::Valid(candidate_hash),
|
||||
&signing_context,
|
||||
1,
|
||||
&Sr25519Keyring::Bob.pair().into(),
|
||||
));
|
||||
&bob_public.into(),
|
||||
)).expect("should be signed"));
|
||||
|
||||
assert_matches!(noted, NotedStatement::Fresh(_));
|
||||
|
||||
let noted = data.note_statement(SignedFullStatement::sign(
|
||||
let noted = data.note_statement(block_on(SignedFullStatement::sign(
|
||||
&keystore,
|
||||
Statement::Valid(candidate_hash),
|
||||
&signing_context,
|
||||
2,
|
||||
&Sr25519Keyring::Charlie.pair().into(),
|
||||
));
|
||||
&charlie_public.into(),
|
||||
)).expect("should be signed"));
|
||||
|
||||
assert_matches!(noted, NotedStatement::Fresh(_));
|
||||
|
||||
@@ -1399,12 +1431,18 @@ mod tests {
|
||||
session_index,
|
||||
};
|
||||
|
||||
let keystore: SyncCryptoStorePtr = Arc::new(LocalKeystore::in_memory());
|
||||
let alice_public = CryptoStore::sr25519_generate_new(
|
||||
&*keystore, ValidatorId::ID, Some(&Sr25519Keyring::Alice.to_seed())
|
||||
).await.unwrap();
|
||||
|
||||
let statement = SignedFullStatement::sign(
|
||||
&keystore,
|
||||
Statement::Seconded(candidate),
|
||||
&signing_context,
|
||||
0,
|
||||
&Sr25519Keyring::Alice.pair().into(),
|
||||
);
|
||||
&alice_public.into(),
|
||||
).await.expect("should be signed");
|
||||
|
||||
StoredStatement {
|
||||
comparator: StoredStatementComparator {
|
||||
|
||||
Reference in New Issue
Block a user