Skip to content

Commit

Permalink
Amend
Browse files Browse the repository at this point in the history
  • Loading branch information
raphjaph committed Dec 19, 2024
1 parent af8a598 commit 5beb449
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 45 deletions.
15 changes: 10 additions & 5 deletions src/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3486,7 +3486,8 @@ mod tests {
context
.index
.get_inscriptions_for_output(OutPoint { txid, vout: 0 })
.unwrap(),
.unwrap()
.unwrap_or_default(),
[]
);

Expand All @@ -3496,7 +3497,8 @@ mod tests {
context
.index
.get_inscriptions_for_output(OutPoint { txid, vout: 0 })
.unwrap(),
.unwrap()
.unwrap_or_default(),
[inscription_id]
);

Expand All @@ -3511,7 +3513,8 @@ mod tests {
context
.index
.get_inscriptions_for_output(OutPoint { txid, vout: 0 })
.unwrap(),
.unwrap()
.unwrap_or_default(),
[]
);

Expand All @@ -3522,7 +3525,8 @@ mod tests {
txid: send_id,
vout: 0,
})
.unwrap(),
.unwrap()
.unwrap_or_default(),
[inscription_id]
);
}
Expand Down Expand Up @@ -3552,7 +3556,8 @@ mod tests {
txid: first,
vout: 0
})
.unwrap(),
.unwrap()
.unwrap_or_default(),
[inscription_id]
);

Expand Down
46 changes: 24 additions & 22 deletions src/templates/output.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,13 @@ mod tests {
assert_regex_match!(
OutputHtml {
chain: Chain::Mainnet,
inscriptions: Vec::new(),
inscriptions: None,
outpoint: outpoint(1),
output: TxOut {
value: Amount::from_sat(1),
script_pubkey: script::Builder::new().push_int(0).into_script(),
},
runes: BTreeMap::new(),
runes: None,
sat_ranges: None,
spent: true,
},
Expand All @@ -88,10 +88,10 @@ mod tests {
assert_regex_match!(
OutputHtml {
chain: Chain::Mainnet,
inscriptions: Vec::new(),
inscriptions: None,
outpoint: outpoint(1),
output: TxOut { value: Amount::from_sat(3), script_pubkey: ScriptBuf::new_p2pkh(&PubkeyHash::all_zeros()), },
runes: BTreeMap::new(),
runes: None,
sat_ranges: Some(vec![(0, 1), (1, 3)]),
spent: true,
},
Expand Down Expand Up @@ -119,10 +119,10 @@ mod tests {
assert_regex_match!(
OutputHtml {
chain: Chain::Mainnet,
inscriptions: Vec::new(),
inscriptions: None,
outpoint: outpoint(1),
output: TxOut { value: Amount::from_sat(3), script_pubkey: ScriptBuf::new_p2pkh(&PubkeyHash::all_zeros()), },
runes: BTreeMap::new(),
runes: None,
sat_ranges: None,
spent: false,
}
Expand All @@ -146,13 +146,13 @@ mod tests {
assert_regex_match!(
OutputHtml {
chain: Chain::Mainnet,
inscriptions: vec![inscription_id(1)],
inscriptions: Some(vec![inscription_id(1)]),
outpoint: outpoint(1),
output: TxOut {
value: Amount::from_sat(3),
script_pubkey: ScriptBuf::new_p2pkh(&PubkeyHash::all_zeros()),
},
runes: BTreeMap::new(),
runes: None,
sat_ranges: None,
spent: false,
},
Expand All @@ -175,25 +175,27 @@ mod tests {
assert_regex_match!(
OutputHtml {
chain: Chain::Mainnet,
inscriptions: Vec::new(),
inscriptions: None,
outpoint: outpoint(1),
output: TxOut {
value: Amount::from_sat(3),
script_pubkey: ScriptBuf::new_p2pkh(&PubkeyHash::all_zeros()),
},
runes: vec![(
SpacedRune {
rune: Rune(26),
spacers: 1
},
Pile {
amount: 11,
divisibility: 1,
symbol: None,
}
)]
.into_iter()
.collect(),
runes: Some(
vec![(
SpacedRune {
rune: Rune(26),
spacers: 1
},
Pile {
amount: 11,
divisibility: 1,
symbol: None,
}
)]
.into_iter()
.collect()
),
sat_ranges: None,
spent: false,
},
Expand Down
31 changes: 18 additions & 13 deletions tests/json_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -406,13 +406,13 @@ fn get_output() {
.unwrap()
),
outpoint: OutPoint { txid, vout: 0 },
inscriptions: vec![
inscriptions: Some(vec![
InscriptionId { txid, index: 0 },
InscriptionId { txid, index: 1 },
InscriptionId { txid, index: 2 },
],
]),
indexed: true,
runes: BTreeMap::new(),
runes: None,
sat_ranges: Some(vec![
(5000000000, 10000000000,),
(10000000000, 15000000000,),
Expand Down Expand Up @@ -809,13 +809,13 @@ fn outputs_address() {
cardinals_json,
vec![api::Output {
address: Some(address.parse().unwrap()),
inscriptions: vec![],
inscriptions: Some(vec![]),
outpoint: OutPoint {
txid: cardinal_send.txid,
vout: 0
},
indexed: true,
runes: BTreeMap::new(),
runes: Some(BTreeMap::new()),
sat_ranges: None,
script_pubkey: ScriptBuf::from(
address
Expand Down Expand Up @@ -853,13 +853,13 @@ fn outputs_address() {
runes_json,
vec![api::Output {
address: Some(address.parse().unwrap()),
inscriptions: vec![],
inscriptions: Some(vec![]),
outpoint: OutPoint {
txid: rune_send.txid,
vout: 0
},
indexed: true,
runes: expected_runes,
runes: Some(expected_runes),
sat_ranges: None,
script_pubkey: ScriptBuf::from(
address
Expand All @@ -884,16 +884,16 @@ fn outputs_address() {
inscriptions_json,
vec![api::Output {
address: Some(address.parse().unwrap()),
inscriptions: vec![InscriptionId {
inscriptions: Some(vec![InscriptionId {
txid: reveal,
index: 0
},],
},]),
outpoint: OutPoint {
txid: inscription_send.txid,
vout: 0
},
indexed: true,
runes: BTreeMap::new(),
runes: Some(BTreeMap::new()),
sat_ranges: None,
script_pubkey: ScriptBuf::from(
address
Expand Down Expand Up @@ -924,11 +924,16 @@ fn outputs_address() {
.unwrap();

assert_eq!(any.len(), 3);
assert!(any.iter().any(|output| output.runes.len() == 1));
assert!(any.iter().any(|output| output.inscriptions.len() == 1));
assert!(any
.iter()
.any(|output| output.inscriptions.is_empty() && output.runes.is_empty()));
.any(|output| output.runes.clone().unwrap_or_default().len() == 1));
assert!(any
.iter()
.any(|output| output.inscriptions.clone().unwrap_or_default().len() == 1));
assert!(any.iter().any(
|output| output.inscriptions.clone().unwrap_or_default().is_empty()
&& output.runes.clone().unwrap_or_default().is_empty()
));
assert_eq!(any, default);
}

Expand Down
4 changes: 2 additions & 2 deletions tests/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ fn output_found() {
Output {
address: None,
indexed: true,
inscriptions: vec![],
runes: BTreeMap::new(),
inscriptions: Some(Vec::new()),
runes: None,
sat_ranges: Some(vec![Range {
end: 50 * COIN_VALUE,
name: "nvtdijuwxlp".into(),
Expand Down
6 changes: 3 additions & 3 deletions tests/wallet/send.rs
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ inscriptions:
txid: reveal_txid,
vout: 0
},
inscriptions: vec![
inscriptions: Some(vec![
InscriptionId {
txid: reveal_txid,
index: 0
Expand All @@ -362,9 +362,9 @@ inscriptions:
txid: reveal_txid,
index: 2
},
],
]),
indexed: true,
runes: BTreeMap::new(),
runes: Some(BTreeMap::new()),
sat_ranges: Some(vec![(5_000_000_000, 5_000_030_000)]),
script_pubkey: destination.assume_checked_ref().script_pubkey(),
spent: false,
Expand Down

0 comments on commit 5beb449

Please sign in to comment.