Skip to content

Commit 657246e

Browse files
committed
reduce some rustfmt new-lines
1 parent 813ad20 commit 657246e

1 file changed

Lines changed: 21 additions & 57 deletions

File tree

tests/pset.rs

Lines changed: 21 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -102,62 +102,40 @@ fn tx_issuance() {
102102
}
103103

104104
#[test]
105-
#[ignore] // TODO this fails because elements decodepsbt is not printing TxOut::asset (PSET_IN_WITNESS_UTXO)
105+
#[ignore] // TODO this fails because elements decodepsbt is not printing TxOut::asset (PSET_IN_WITNESS_UTXO)
106106
fn tx_pegin() {
107107
let (elementsd, bitcoind) = setup(true);
108108
let bitcoind = bitcoind.unwrap();
109-
let mainchain_address = bitcoind.client.get_new_address(None, None).unwrap();
109+
let btc_addr = bitcoind.client.get_new_address(None, None).unwrap();
110110
let address_lbtc = elementsd.get_new_address();
111-
bitcoind
112-
.client
113-
.generate_to_address(101, &mainchain_address)
114-
.unwrap();
111+
bitcoind.client.generate_to_address(101, &btc_addr).unwrap();
115112
let (pegin_address, claim_script) = elementsd.get_pegin_address();
113+
let address = Address::from_str(&pegin_address).unwrap();
114+
let amount = Amount::from_sat(100_000_000);
116115
let txid = bitcoind
117116
.client
118-
.send_to_address(
119-
&Address::from_str(&pegin_address).unwrap(),
120-
Amount::from_sat(100_000_000),
121-
None,
122-
None,
123-
None,
124-
None,
125-
None,
126-
None,
127-
)
117+
.send_to_address(&address, amount, None, None, None, None, None, None)
128118
.unwrap();
129119
let tx = bitcoind.client.get_raw_transaction(&txid, None).unwrap();
130120
let tx_bytes = serialize(&tx);
131121
let vout = tx
132122
.output
133123
.iter()
134124
.position(|o| {
135-
Address::from_script(&o.script_pubkey, bitcoin::Network::Regtest)
136-
.unwrap()
137-
.to_string()
138-
== pegin_address
125+
let addr = Address::from_script(&o.script_pubkey, bitcoin::Network::Regtest);
126+
addr.unwrap().to_string() == pegin_address
139127
})
140128
.unwrap();
141129

142-
bitcoind
143-
.client
144-
.generate_to_address(101, &mainchain_address)
145-
.unwrap();
130+
bitcoind.client.generate_to_address(101, &btc_addr).unwrap();
146131
let proof = bitcoind.client.get_tx_out_proof(&[txid], None).unwrap();
147132
elementsd.generate(2);
148133
let inputs = json!([ {"txid":txid, "vout": vout,"pegin_bitcoin_tx": tx_bytes.to_hex(), "pegin_txout_proof": proof.to_hex(), "pegin_claim_script": claim_script } ]);
149-
let value = elementsd.call(
150-
"createpsbt",
151-
&[
152-
inputs,
153-
json!([
154-
{address_lbtc: "0.9", "blinder_index": 0},
155-
{"fee": "0.1" }
156-
]),
157-
0.into(),
158-
false.into(),
159-
],
160-
);
134+
let outputs = json!([
135+
{address_lbtc: "0.9", "blinder_index": 0},
136+
{"fee": "0.1" }
137+
]);
138+
let value = elementsd.call("createpsbt", &[inputs, outputs, 0.into(), false.into()]);
161139
let psbt_base64 = value.as_str().unwrap().to_string();
162140
assert_eq!(elementsd.expected_next(&psbt_base64), "updater");
163141
let psbt_base64 = elementsd.wallet_process_psbt(&psbt_base64);
@@ -218,20 +196,11 @@ impl Call for ElementsD {
218196

219197
fn get_pegin_address(&self) -> (String, String) {
220198
let value = self.call("getpeginaddress", &[]);
221-
(
222-
value
223-
.get("mainchain_address")
224-
.unwrap()
225-
.as_str()
226-
.unwrap()
227-
.to_string(),
228-
value
229-
.get("claim_script")
230-
.unwrap()
231-
.as_str()
232-
.unwrap()
233-
.to_string(),
234-
)
199+
let mainchain_address = value.get("mainchain_address").unwrap();
200+
let mainchain_address = mainchain_address.as_str().unwrap().to_string();
201+
let claim_script = value.get("claim_script").unwrap();
202+
let claim_script = claim_script.as_str().unwrap().to_string();
203+
(mainchain_address, claim_script)
235204
}
236205

237206
fn generate(&self, blocks: u32) {
@@ -276,13 +245,8 @@ impl Call for ElementsD {
276245

277246
fn test_mempool_accept(&self, hex: &str) -> bool {
278247
let result = self.call("testmempoolaccept", &[json!([hex])]);
279-
result
280-
.get(0)
281-
.unwrap()
282-
.get("allowed")
283-
.unwrap()
284-
.as_bool()
285-
.unwrap()
248+
let allowed = result.get(0).unwrap().get("allowed");
249+
allowed.unwrap().as_bool().unwrap()
286250
}
287251
}
288252

0 commit comments

Comments
 (0)