Skip to content

Commit

Permalink
Merge pull request #645 from Chia-Network/remove-redundant-function
Browse files Browse the repository at this point in the history
we have two copies of the u64_to_bytes() function (used in tests)
  • Loading branch information
arvidn committed Aug 6, 2024
2 parents 5c68492 + e86bf57 commit b7d070a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 14 deletions.
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

0 comments on commit b7d070a

Please sign in to comment.