Skip to content

Commit c641e38

Browse files
authored
fix(benchy): fix an obviously-busted benchy (#922)
- len(user bytes) < len(bit-padded(user bytes)) - pass the correct file to pre_commit - propagate failure from benchy command or micro command
1 parent b4e1ea2 commit c641e38

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

fil-proofs-tooling/scripts/benchy.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,5 @@ if [[ ! $GTIME_EXIT_CODE -eq 0 || ! $JQ_EXIT_CODE -eq 0 ]]; then
5252
>&2 echo "<JQ_STDERR>"
5353
>&2 echo "$(cat $JQ_STDERR)"
5454
>&2 echo "</JQ_STDERR>"
55+
exit 1
5556
fi

fil-proofs-tooling/scripts/micro.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,5 @@ if [[ ! $MICRO_EXIT_CODE -eq 0 || ! $JQ_EXIT_CODE -eq 0 ]]; then
3434
>&2 echo "<JQ_STDERR>"
3535
>&2 echo "$(cat $JQ_STDERR)"
3636
>&2 echo "</JQ_STDERR>"
37+
exit 1
3738
fi

fil-proofs-tooling/src/bin/benchy/rational_post.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ pub fn run(sector_size: usize) -> Result<(), failure::Error> {
5858
UnpaddedBytesAmount::from(PaddedBytesAmount(sector_size as u64));
5959

6060
// Create files for the staged and sealed sectors.
61-
let staged_file = NamedTempFile::new().expect("could not create temp file for staged sector");
61+
let mut staged_file =
62+
NamedTempFile::new().expect("could not create temp file for staged sector");
6263

6364
let sealed_file = NamedTempFile::new().expect("could not create temp file for sealed sector");
6465

@@ -70,7 +71,9 @@ pub fn run(sector_size: usize) -> Result<(), failure::Error> {
7071

7172
// Generate the data from which we will create a replica, we will then prove the continued
7273
// storage of that replica using the PoSt.
73-
let piece_bytes: Vec<u8> = (0..sector_size).map(|_| rand::random::<u8>()).collect();
74+
let piece_bytes: Vec<u8> = (0..usize::from(sector_size_unpadded_bytes_ammount))
75+
.map(|_| rand::random::<u8>())
76+
.collect();
7477

7578
let mut piece_file = NamedTempFile::new()?;
7679
piece_file.write_all(&piece_bytes)?;
@@ -81,10 +84,9 @@ pub fn run(sector_size: usize) -> Result<(), failure::Error> {
8184
generate_piece_commitment(piece_file.as_file_mut(), sector_size_unpadded_bytes_ammount)?;
8285
piece_file.as_file_mut().seek(SeekFrom::Start(0))?;
8386

84-
let mut staged_sector_file = NamedTempFile::new()?;
8587
add_piece(
8688
&mut piece_file,
87-
&mut staged_sector_file,
89+
&mut staged_file,
8890
sector_size_unpadded_bytes_ammount,
8991
&[],
9092
)?;

0 commit comments

Comments
 (0)