Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(sidecar): add small test #546

Merged
merged 2 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .github/workflows/bolt_cli_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,6 @@ jobs:
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable

- name: Install Protoc
uses: arduino/setup-protoc@v3

- name: Cache cargo registry
uses: Swatinem/rust-cache@v2
with:
Expand Down
22 changes: 22 additions & 0 deletions bolt-cli/src/common/hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,25 @@ pub fn compress_bls_pubkey(pubkey: &BlsPublicKey) -> CompressedHash {

CompressedHash::from_slice(hash.get(0..20).expect("hash is longer than 20 bytes"))
}

#[cfg(test)]
mod tests {
use ethereum_consensus::crypto::PublicKey as BlsPublicKey;

use crate::common::hash::compress_bls_pubkey;

#[test]
fn test_compute_pubkey_hash() -> eyre::Result<()> {
let pubkey = "8fa1c53218bdcbb4c8eb27a6c92b8147ca557717a6aeb1f5c347559255b421e5c7327ab047662be883fde91947ae0334";
let pubkey = BlsPublicKey::try_from(hex::decode(pubkey)?.as_slice())?;

let hash = compress_bls_pubkey(&pubkey);
assert_eq!(
hex::encode(hash),
"9bf58e9a809e502234ece758ac401741d6c1a30d",
"hash should match the expected value"
);

Ok(())
}
}
Loading