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

we have two copies of the u64_to_bytes() function (used in tests) #645

Merged
merged 1 commit into from
Aug 6, 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
2 changes: 1 addition & 1 deletion crates/chia-consensus/src/gen/conditions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1455,7 +1455,7 @@ pub fn validate_conditions(
}

#[cfg(test)]
fn u64_to_bytes(n: u64) -> Vec<u8> {
pub(crate) fn u64_to_bytes(n: u64) -> Vec<u8> {
let mut buf = Vec::<u8>::new();
buf.extend_from_slice(&n.to_be_bytes());
if (buf[0] & 0x80) != 0 {
Expand Down
14 changes: 1 addition & 13 deletions crates/chia-consensus/src/gen/get_puzzle_and_solution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,21 +59,9 @@ pub fn get_puzzle_and_solution_for_coin(
#[cfg(test)]
mod test {
use super::*;
use crate::gen::conditions::u64_to_bytes;
use clvmr::sha2::Sha256;

fn u64_to_bytes(n: u64) -> Vec<u8> {
let mut buf = Vec::<u8>::new();
buf.extend_from_slice(&n.to_be_bytes());
if (buf[0] & 0x80) != 0 {
buf.insert(0, 0);
} else {
while buf.len() > 1 && buf[0] == 0 && (buf[1] & 0x80) == 0 {
buf.remove(0);
}
}
buf
}

fn make_dummy_id(seed: u64) -> Bytes32 {
let mut sha256 = Sha256::new();
sha256.update(seed.to_be_bytes());
Expand Down
Loading