From 9f403bf2356f7c4100a46c564c8c40326bf9ec8c Mon Sep 17 00:00:00 2001 From: andrussal Date: Thu, 18 Dec 2025 22:01:07 +0100 Subject: [PATCH] configs: remove ProviderId unwrap --- testing-framework/configs/src/lib.rs | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/testing-framework/configs/src/lib.rs b/testing-framework/configs/src/lib.rs index df39d6d..e975e01 100644 --- a/testing-framework/configs/src/lib.rs +++ b/testing-framework/configs/src/lib.rs @@ -40,10 +40,16 @@ pub fn secret_key_to_peer_id(node_key: nomos_libp2p::ed25519::SecretKey) -> Peer #[must_use] pub fn secret_key_to_provider_id(node_key: nomos_libp2p::ed25519::SecretKey) -> ProviderId { - ProviderId::try_from( - nomos_libp2p::ed25519::Keypair::from(node_key) - .public() - .to_bytes(), - ) - .unwrap() + let bytes = nomos_libp2p::ed25519::Keypair::from(node_key) + .public() + .to_bytes(); + match ProviderId::try_from(bytes) { + Ok(value) => value, + Err(_) => unsafe { + // Safety: `bytes` is a 32-byte ed25519 public key, matching `ProviderId`'s + // expected width; failure would indicate a broken invariant in the + // dependency. + std::hint::unreachable_unchecked() + }, + } }