Skip to content

Commit

Permalink
test prdoc
Browse files Browse the repository at this point in the history
  • Loading branch information
programskillforverification committed Sep 18, 2024
1 parent e6f2203 commit d59183d
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 41 deletions.
3 changes: 2 additions & 1 deletion polkadot/node/network/dispute-distribution/src/tests/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ pub const BOB_INDEX: ValidatorIndex = ValidatorIndex(2);
pub const CHARLIE_INDEX: ValidatorIndex = ValidatorIndex(3);

/// Mocked `AuthorityDiscovery` service.
pub static MOCK_AUTHORITY_DISCOVERY: OnceLock<MockAuthorityDiscovery> = OnceLock::new();
pub static MOCK_AUTHORITY_DISCOVERY: LazyLock<MockAuthorityDiscovery> =
LazyLock::new(|| MockAuthorityDiscovery::new());
// Creating an innocent looking `SessionInfo` is really expensive in a debug build. Around
// 700ms on my machine, We therefore cache those keys here:
pub static MOCK_VALIDATORS_DISCOVERY_KEYS: LazyLock<HashMap<Sr25519Keyring, AuthorityDiscoveryId>> =
Expand Down
43 changes: 9 additions & 34 deletions polkadot/node/network/dispute-distribution/src/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,10 +208,7 @@ fn received_request_triggers_import() {
nested_network_dispute_request(
&mut handle,
req_tx,
MOCK_AUTHORITY_DISCOVERY
.get()
.unwrap()
.get_peer_id_by_authority(Sr25519Keyring::Alice),
MOCK_AUTHORITY_DISCOVERY.get_peer_id_by_authority(Sr25519Keyring::Alice),
message.clone().into(),
ImportStatementsResult::ValidImport,
true,
Expand Down Expand Up @@ -240,10 +237,7 @@ fn batching_works() {
nested_network_dispute_request(
&mut handle,
req_tx,
MOCK_AUTHORITY_DISCOVERY
.get()
.unwrap()
.get_peer_id_by_authority(Sr25519Keyring::Alice),
MOCK_AUTHORITY_DISCOVERY.get_peer_id_by_authority(Sr25519Keyring::Alice),
message.clone().into(),
ImportStatementsResult::ValidImport,
true,
Expand All @@ -254,17 +248,11 @@ fn batching_works() {
let mut rx_responses = Vec::new();

let message = make_dispute_message(candidate.clone(), BOB_INDEX, FERDIE_INDEX);
let peer = MOCK_AUTHORITY_DISCOVERY
.get()
.unwrap()
.get_peer_id_by_authority(Sr25519Keyring::Bob);
let peer = MOCK_AUTHORITY_DISCOVERY.get_peer_id_by_authority(Sr25519Keyring::Bob);
rx_responses.push(send_network_dispute_request(req_tx, peer, message.clone().into()).await);

let message = make_dispute_message(candidate.clone(), CHARLIE_INDEX, FERDIE_INDEX);
let peer = MOCK_AUTHORITY_DISCOVERY
.get()
.unwrap()
.get_peer_id_by_authority(Sr25519Keyring::Charlie);
let peer = MOCK_AUTHORITY_DISCOVERY.get_peer_id_by_authority(Sr25519Keyring::Charlie);
rx_responses.push(send_network_dispute_request(req_tx, peer, message.clone().into()).await);
gum::trace!("Imported 3 votes into batch");

Expand All @@ -275,18 +263,12 @@ fn batching_works() {
gum::trace!("Importing duplicate votes");
let mut rx_responses_duplicate = Vec::new();
let message = make_dispute_message(candidate.clone(), BOB_INDEX, FERDIE_INDEX);
let peer = MOCK_AUTHORITY_DISCOVERY
.get()
.unwrap()
.get_peer_id_by_authority(Sr25519Keyring::Bob);
let peer = MOCK_AUTHORITY_DISCOVERY.get_peer_id_by_authority(Sr25519Keyring::Bob);
rx_responses_duplicate
.push(send_network_dispute_request(req_tx, peer, message.clone().into()).await);

let message = make_dispute_message(candidate.clone(), CHARLIE_INDEX, FERDIE_INDEX);
let peer = MOCK_AUTHORITY_DISCOVERY
.get()
.unwrap()
.get_peer_id_by_authority(Sr25519Keyring::Charlie);
let peer = MOCK_AUTHORITY_DISCOVERY.get_peer_id_by_authority(Sr25519Keyring::Charlie);
rx_responses_duplicate
.push(send_network_dispute_request(req_tx, peer, message.clone().into()).await);

Expand Down Expand Up @@ -380,10 +362,7 @@ fn receive_rate_limit_is_enforced() {
nested_network_dispute_request(
&mut handle,
req_tx,
MOCK_AUTHORITY_DISCOVERY
.get()
.unwrap()
.get_peer_id_by_authority(Sr25519Keyring::Alice),
MOCK_AUTHORITY_DISCOVERY.get_peer_id_by_authority(Sr25519Keyring::Alice),
message.clone().into(),
ImportStatementsResult::ValidImport,
true,
Expand All @@ -393,10 +372,7 @@ fn receive_rate_limit_is_enforced() {

let mut rx_responses = Vec::new();

let peer = MOCK_AUTHORITY_DISCOVERY
.get()
.unwrap()
.get_peer_id_by_authority(Sr25519Keyring::Bob);
let peer = MOCK_AUTHORITY_DISCOVERY.get_peer_id_by_authority(Sr25519Keyring::Bob);

let message = make_dispute_message(candidate.clone(), BOB_INDEX, FERDIE_INDEX);
rx_responses.push(send_network_dispute_request(req_tx, peer, message.clone().into()).await);
Expand Down Expand Up @@ -899,7 +875,6 @@ where
Fut: Future<Output = ()>,
{
sp_tracing::try_init_simple();
MOCK_AUTHORITY_DISCOVERY.get_or_init(|| mock::MockAuthorityDiscovery::new());
let keystore = make_ferdie_keystore();

let genesis_hash = Hash::repeat_byte(0xff);
Expand All @@ -911,7 +886,7 @@ where
let subsystem = DisputeDistributionSubsystem::new(
keystore,
req_receiver,
MOCK_AUTHORITY_DISCOVERY.get().unwrap().clone(),
MOCK_AUTHORITY_DISCOVERY.clone(),
Metrics::new_dummy(),
);

Expand Down
7 changes: 1 addition & 6 deletions polkadot/node/zombienet-backchannel/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,7 @@ license.workspace = true
workspace = true

[dependencies]
tokio = { features = [
"macros",
"net",
"rt-multi-thread",
"sync",
], workspace = true }
tokio = { features = ["macros", "net", "rt-multi-thread", "sync",], workspace = true }
url = { workspace = true }
tokio-tungstenite = { workspace = true }
futures-util = { workspace = true, default-features = true }
Expand Down
37 changes: 37 additions & 0 deletions prdoc/pr_5716.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Schema: Polkadot SDK PRDoc Schema (prdoc) v1.0.0
# See doc at https://raw.githubusercontent.com/paritytech/polkadot-sdk/master/prdoc/schema_user.json

title: Replace `lazy_static` with `LazyLock`

doc:
- audience: Node Dev
description: |
Replace all lazy_static usages with LazyLock from the Rust standard library. This will bring us less dependencies.

crates:
- name: sp-core
bump: patch
- name: sp-panic-handler
bump: patch
- name: sp-trie
bump: patch
- name: sc-utils
bump: patch
- name: cumulus-pallet-parachain-system
bump: patch
- name: sp-consensus-beefy
bump: patch
- name: polkadot-node-primitives
bump: patch
- name: polkadot-node-jaeger
bump: patch
- name: frame-benchmarking-cli
bump: patch
- name: sc-offchain
bump: patch
- name: polkadot-dispute-distribution
bump: patch
- name: polkadot-gossip-support
bump: patch
- name: xcm-emulator
bump: patch

0 comments on commit d59183d

Please sign in to comment.