Skip to content

Commit 5beb449

Browse files
committed
Amend
1 parent af8a598 commit 5beb449

File tree

5 files changed

+57
-45
lines changed

5 files changed

+57
-45
lines changed

src/index.rs

+10-5
Original file line numberDiff line numberDiff line change
@@ -3486,7 +3486,8 @@ mod tests {
34863486
context
34873487
.index
34883488
.get_inscriptions_for_output(OutPoint { txid, vout: 0 })
3489-
.unwrap(),
3489+
.unwrap()
3490+
.unwrap_or_default(),
34903491
[]
34913492
);
34923493

@@ -3496,7 +3497,8 @@ mod tests {
34963497
context
34973498
.index
34983499
.get_inscriptions_for_output(OutPoint { txid, vout: 0 })
3499-
.unwrap(),
3500+
.unwrap()
3501+
.unwrap_or_default(),
35003502
[inscription_id]
35013503
);
35023504

@@ -3511,7 +3513,8 @@ mod tests {
35113513
context
35123514
.index
35133515
.get_inscriptions_for_output(OutPoint { txid, vout: 0 })
3514-
.unwrap(),
3516+
.unwrap()
3517+
.unwrap_or_default(),
35153518
[]
35163519
);
35173520

@@ -3522,7 +3525,8 @@ mod tests {
35223525
txid: send_id,
35233526
vout: 0,
35243527
})
3525-
.unwrap(),
3528+
.unwrap()
3529+
.unwrap_or_default(),
35263530
[inscription_id]
35273531
);
35283532
}
@@ -3552,7 +3556,8 @@ mod tests {
35523556
txid: first,
35533557
vout: 0
35543558
})
3555-
.unwrap(),
3559+
.unwrap()
3560+
.unwrap_or_default(),
35563561
[inscription_id]
35573562
);
35583563

src/templates/output.rs

+24-22
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,13 @@ mod tests {
6060
assert_regex_match!(
6161
OutputHtml {
6262
chain: Chain::Mainnet,
63-
inscriptions: Vec::new(),
63+
inscriptions: None,
6464
outpoint: outpoint(1),
6565
output: TxOut {
6666
value: Amount::from_sat(1),
6767
script_pubkey: script::Builder::new().push_int(0).into_script(),
6868
},
69-
runes: BTreeMap::new(),
69+
runes: None,
7070
sat_ranges: None,
7171
spent: true,
7272
},
@@ -88,10 +88,10 @@ mod tests {
8888
assert_regex_match!(
8989
OutputHtml {
9090
chain: Chain::Mainnet,
91-
inscriptions: Vec::new(),
91+
inscriptions: None,
9292
outpoint: outpoint(1),
9393
output: TxOut { value: Amount::from_sat(3), script_pubkey: ScriptBuf::new_p2pkh(&PubkeyHash::all_zeros()), },
94-
runes: BTreeMap::new(),
94+
runes: None,
9595
sat_ranges: Some(vec![(0, 1), (1, 3)]),
9696
spent: true,
9797
},
@@ -119,10 +119,10 @@ mod tests {
119119
assert_regex_match!(
120120
OutputHtml {
121121
chain: Chain::Mainnet,
122-
inscriptions: Vec::new(),
122+
inscriptions: None,
123123
outpoint: outpoint(1),
124124
output: TxOut { value: Amount::from_sat(3), script_pubkey: ScriptBuf::new_p2pkh(&PubkeyHash::all_zeros()), },
125-
runes: BTreeMap::new(),
125+
runes: None,
126126
sat_ranges: None,
127127
spent: false,
128128
}
@@ -146,13 +146,13 @@ mod tests {
146146
assert_regex_match!(
147147
OutputHtml {
148148
chain: Chain::Mainnet,
149-
inscriptions: vec![inscription_id(1)],
149+
inscriptions: Some(vec![inscription_id(1)]),
150150
outpoint: outpoint(1),
151151
output: TxOut {
152152
value: Amount::from_sat(3),
153153
script_pubkey: ScriptBuf::new_p2pkh(&PubkeyHash::all_zeros()),
154154
},
155-
runes: BTreeMap::new(),
155+
runes: None,
156156
sat_ranges: None,
157157
spent: false,
158158
},
@@ -175,25 +175,27 @@ mod tests {
175175
assert_regex_match!(
176176
OutputHtml {
177177
chain: Chain::Mainnet,
178-
inscriptions: Vec::new(),
178+
inscriptions: None,
179179
outpoint: outpoint(1),
180180
output: TxOut {
181181
value: Amount::from_sat(3),
182182
script_pubkey: ScriptBuf::new_p2pkh(&PubkeyHash::all_zeros()),
183183
},
184-
runes: vec![(
185-
SpacedRune {
186-
rune: Rune(26),
187-
spacers: 1
188-
},
189-
Pile {
190-
amount: 11,
191-
divisibility: 1,
192-
symbol: None,
193-
}
194-
)]
195-
.into_iter()
196-
.collect(),
184+
runes: Some(
185+
vec![(
186+
SpacedRune {
187+
rune: Rune(26),
188+
spacers: 1
189+
},
190+
Pile {
191+
amount: 11,
192+
divisibility: 1,
193+
symbol: None,
194+
}
195+
)]
196+
.into_iter()
197+
.collect()
198+
),
197199
sat_ranges: None,
198200
spent: false,
199201
},

tests/json_api.rs

+18-13
Original file line numberDiff line numberDiff line change
@@ -406,13 +406,13 @@ fn get_output() {
406406
.unwrap()
407407
),
408408
outpoint: OutPoint { txid, vout: 0 },
409-
inscriptions: vec![
409+
inscriptions: Some(vec![
410410
InscriptionId { txid, index: 0 },
411411
InscriptionId { txid, index: 1 },
412412
InscriptionId { txid, index: 2 },
413-
],
413+
]),
414414
indexed: true,
415-
runes: BTreeMap::new(),
415+
runes: None,
416416
sat_ranges: Some(vec![
417417
(5000000000, 10000000000,),
418418
(10000000000, 15000000000,),
@@ -809,13 +809,13 @@ fn outputs_address() {
809809
cardinals_json,
810810
vec![api::Output {
811811
address: Some(address.parse().unwrap()),
812-
inscriptions: vec![],
812+
inscriptions: Some(vec![]),
813813
outpoint: OutPoint {
814814
txid: cardinal_send.txid,
815815
vout: 0
816816
},
817817
indexed: true,
818-
runes: BTreeMap::new(),
818+
runes: Some(BTreeMap::new()),
819819
sat_ranges: None,
820820
script_pubkey: ScriptBuf::from(
821821
address
@@ -853,13 +853,13 @@ fn outputs_address() {
853853
runes_json,
854854
vec![api::Output {
855855
address: Some(address.parse().unwrap()),
856-
inscriptions: vec![],
856+
inscriptions: Some(vec![]),
857857
outpoint: OutPoint {
858858
txid: rune_send.txid,
859859
vout: 0
860860
},
861861
indexed: true,
862-
runes: expected_runes,
862+
runes: Some(expected_runes),
863863
sat_ranges: None,
864864
script_pubkey: ScriptBuf::from(
865865
address
@@ -884,16 +884,16 @@ fn outputs_address() {
884884
inscriptions_json,
885885
vec![api::Output {
886886
address: Some(address.parse().unwrap()),
887-
inscriptions: vec![InscriptionId {
887+
inscriptions: Some(vec![InscriptionId {
888888
txid: reveal,
889889
index: 0
890-
},],
890+
},]),
891891
outpoint: OutPoint {
892892
txid: inscription_send.txid,
893893
vout: 0
894894
},
895895
indexed: true,
896-
runes: BTreeMap::new(),
896+
runes: Some(BTreeMap::new()),
897897
sat_ranges: None,
898898
script_pubkey: ScriptBuf::from(
899899
address
@@ -924,11 +924,16 @@ fn outputs_address() {
924924
.unwrap();
925925

926926
assert_eq!(any.len(), 3);
927-
assert!(any.iter().any(|output| output.runes.len() == 1));
928-
assert!(any.iter().any(|output| output.inscriptions.len() == 1));
929927
assert!(any
930928
.iter()
931-
.any(|output| output.inscriptions.is_empty() && output.runes.is_empty()));
929+
.any(|output| output.runes.clone().unwrap_or_default().len() == 1));
930+
assert!(any
931+
.iter()
932+
.any(|output| output.inscriptions.clone().unwrap_or_default().len() == 1));
933+
assert!(any.iter().any(
934+
|output| output.inscriptions.clone().unwrap_or_default().is_empty()
935+
&& output.runes.clone().unwrap_or_default().is_empty()
936+
));
932937
assert_eq!(any, default);
933938
}
934939

tests/list.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ fn output_found() {
1717
Output {
1818
address: None,
1919
indexed: true,
20-
inscriptions: vec![],
21-
runes: BTreeMap::new(),
20+
inscriptions: Some(Vec::new()),
21+
runes: None,
2222
sat_ranges: Some(vec![Range {
2323
end: 50 * COIN_VALUE,
2424
name: "nvtdijuwxlp".into(),

tests/wallet/send.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ inscriptions:
349349
txid: reveal_txid,
350350
vout: 0
351351
},
352-
inscriptions: vec![
352+
inscriptions: Some(vec![
353353
InscriptionId {
354354
txid: reveal_txid,
355355
index: 0
@@ -362,9 +362,9 @@ inscriptions:
362362
txid: reveal_txid,
363363
index: 2
364364
},
365-
],
365+
]),
366366
indexed: true,
367-
runes: BTreeMap::new(),
367+
runes: Some(BTreeMap::new()),
368368
sat_ranges: Some(vec![(5_000_000_000, 5_000_030_000)]),
369369
script_pubkey: destination.assume_checked_ref().script_pubkey(),
370370
spent: false,

0 commit comments

Comments
 (0)