Skip to content

Commit

Permalink
Implement #2457
Browse files Browse the repository at this point in the history
  • Loading branch information
ordinally committed Oct 11, 2023
1 parent 3d7e095 commit 1fb911e
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions src/inscription.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,12 +179,10 @@ impl Inscription {
let (txid, index) = value.split_at(Txid::LEN);

if let Some(last) = index.last() {
if *last == 0 {
log::info!(
"parsing parent inscription index {:?} for {:?} with trailing zeroes",
index,
txid
);
// Accept fixed length encoding with 4 bytes (with potential trailing zeroes)
// or variable length (no trailing zeroes)
if index.len() != 4 && *last == 0 {
return None;
}
}

Expand Down Expand Up @@ -382,11 +380,25 @@ mod tests {
}

#[test]
fn inscription_with_parent_field_index_with_trailing_zeroes_has_no_parent() {
fn inscription_with_parent_field_index_with_trailing_zeroes_and_fixed_length_has_parent() {
let mut parent = vec![1; 36];

parent[35] = 0;

assert!(Inscription {
parent: Some(parent),
..Default::default()
}
.parent()
.is_some());
}

#[test]
fn inscription_with_parent_field_index_with_trailing_zeroes_and_variable_length_has_no_parent() {
let mut parent = vec![1; 35];

parent[34] = 0;

assert!(Inscription {
parent: Some(parent),
..Default::default()
Expand Down

0 comments on commit 1fb911e

Please sign in to comment.