Skip to content

Commit

Permalink
verify: split into methods
Browse files Browse the repository at this point in the history
  • Loading branch information
hinto-janai committed Dec 16, 2024
1 parent 6f85531 commit e6c96a6
Show file tree
Hide file tree
Showing 5 changed files with 283 additions and 194 deletions.
2 changes: 1 addition & 1 deletion tests/compat/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ async fn main() {
let count = constants::TESTED_BLOCK_COUNT.load(Ordering::Acquire);

if top_height == count {
println!("finished, took {}s", now.elapsed().as_secs());
println!("Finished, took {}s", now.elapsed().as_secs());
std::process::exit(0);
}

Expand Down
21 changes: 3 additions & 18 deletions tests/compat/src/randomx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,12 @@ pub fn randomx_vm_default(seed_hash: &[u8; 32]) -> RandomXVM {
}

/// Returns a [`RandomXVM`] with most optimization flags.
#[expect(dead_code)]
pub fn randomx_vm_optimized(seed_hash: &[u8; 32]) -> RandomXVM {
// TODO: conditional FLAG_LARGE_PAGES, FLAG_JIT

let mut vm_flag = RandomXFlag::FLAG_FULL_MEM;
let mut cache_flag = RandomXFlag::empty();

#[cfg(target_arch = "x86_64")]
for flag in [&mut vm_flag, &mut cache_flag] {
if is_x86_feature_detected!("aes") {
*flag |= RandomXFlag::FLAG_HARD_AES;
}

match (
is_x86_feature_detected!("ssse3"),
is_x86_feature_detected!("avx2"),
) {
(true, _) => *flag |= RandomXFlag::FLAG_ARGON2_SSSE3,
(_, true) => *flag |= RandomXFlag::FLAG_ARGON2_AVX2,
(_, _) => *flag |= RandomXFlag::FLAG_ARGON2,
}
}
let vm_flag = RandomXFlag::get_recommended_flags() | RandomXFlag::FLAG_FULL_MEM;
let cache_flag = RandomXFlag::get_recommended_flags();

let hash = hex::encode(seed_hash);

Expand Down
8 changes: 1 addition & 7 deletions tests/compat/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,13 +180,7 @@ impl RpcClient {
.try_into()
.unwrap();

let seed_hash = this
.get_block(seed_height)
.await
.block_header
.hash
.try_into()
.unwrap();
let seed_hash = this.get_block(seed_height).await.block_header.hash;

(seed_height, seed_hash)
};
Expand Down
2 changes: 1 addition & 1 deletion tests/compat/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ pub struct GetBlockResponse {
pub block_header: BlockHeader,
}

#[derive(Debug, Clone, Deserialize)]
#[derive(Debug, Copy, Clone, Deserialize)]
pub(crate) struct BlockHeader {
#[serde(deserialize_with = "deserialize")]
pub hash: [u8; 32],
Expand Down
Loading

0 comments on commit e6c96a6

Please sign in to comment.