Skip to content

Commit 3dd00ad

Browse files
authored
chore: fix new lint warnings (#400)
1 parent 78414b6 commit 3dd00ad

File tree

10 files changed

+163
-182
lines changed

10 files changed

+163
-182
lines changed

pallas-applying/tests/alonzo.rs

Lines changed: 86 additions & 105 deletions
Large diffs are not rendered by default.

pallas-applying/tests/byron.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ mod byron_tests {
107107
Ok(_) => (),
108108
Err(err) => panic!("Unable to encode Tx ({:?})", err),
109109
};
110-
mtxp.transaction = Decode::decode(&mut Decoder::new(&tx_buf.as_slice()), &mut ()).unwrap();
110+
mtxp.transaction = Decode::decode(&mut Decoder::new(tx_buf.as_slice()), &mut ()).unwrap();
111111
let metx: MultiEraTx = MultiEraTx::from_byron(&mtxp);
112112
let env: Environment = Environment {
113113
prot_params: MultiEraProtParams::Byron(ByronProtParams {
@@ -122,7 +122,7 @@ mod byron_tests {
122122
network_id: 1,
123123
};
124124
match validate(&metx, &utxos, &env) {
125-
Ok(()) => assert!(false, "Inputs set should not be empty"),
125+
Ok(()) => panic!("Inputs set should not be empty"),
126126
Err(err) => match err {
127127
Byron(ByronError::TxInsEmpty) => (),
128128
_ => panic!("Unexpected error ({:?})", err),
@@ -143,7 +143,7 @@ mod byron_tests {
143143
Ok(_) => (),
144144
Err(err) => panic!("Unable to encode Tx ({:?})", err),
145145
};
146-
mtxp.transaction = Decode::decode(&mut Decoder::new(&tx_buf.as_slice()), &mut ()).unwrap();
146+
mtxp.transaction = Decode::decode(&mut Decoder::new(tx_buf.as_slice()), &mut ()).unwrap();
147147
let metx: MultiEraTx = MultiEraTx::from_byron(&mtxp);
148148
let utxos: UTxOs = mk_utxo_for_byron_tx(
149149
&mtxp.transaction,
@@ -165,7 +165,7 @@ mod byron_tests {
165165
network_id: 1,
166166
};
167167
match validate(&metx, &utxos, &env) {
168-
Ok(()) => assert!(false, "Outputs set should not be empty"),
168+
Ok(()) => panic!("Outputs set should not be empty"),
169169
Err(err) => match err {
170170
Byron(ByronError::TxOutsEmpty) => (),
171171
_ => panic!("Unexpected error ({:?})", err),
@@ -193,7 +193,7 @@ mod byron_tests {
193193
network_id: 1,
194194
};
195195
match validate(&metx, &utxos, &env) {
196-
Ok(()) => assert!(false, "All inputs must be within the UTxO set"),
196+
Ok(()) => panic!("All inputs must be within the UTxO set"),
197197
Err(err) => match err {
198198
Byron(ByronError::InputNotInUTxO) => (),
199199
_ => panic!("Unexpected error ({:?})", err),
@@ -220,7 +220,7 @@ mod byron_tests {
220220
Ok(_) => (),
221221
Err(err) => panic!("Unable to encode Tx ({:?})", err),
222222
};
223-
mtxp.transaction = Decode::decode(&mut Decoder::new(&tx_buf.as_slice()), &mut ()).unwrap();
223+
mtxp.transaction = Decode::decode(&mut Decoder::new(tx_buf.as_slice()), &mut ()).unwrap();
224224
let metx: MultiEraTx = MultiEraTx::from_byron(&mtxp);
225225
let utxos: UTxOs = mk_utxo_for_byron_tx(
226226
&mtxp.transaction,
@@ -242,7 +242,7 @@ mod byron_tests {
242242
network_id: 1,
243243
};
244244
match validate(&metx, &utxos, &env) {
245-
Ok(()) => assert!(false, "All outputs must contain lovelace"),
245+
Ok(()) => panic!("All outputs must contain lovelace"),
246246
Err(err) => match err {
247247
Byron(ByronError::OutputWithoutLovelace) => (),
248248
_ => panic!("Unexpected error ({:?})", err),
@@ -276,7 +276,7 @@ mod byron_tests {
276276
network_id: 1,
277277
};
278278
match validate(&metx, &utxos, &env) {
279-
Ok(()) => assert!(false, "Fees should not be below minimum"),
279+
Ok(()) => panic!("Fees should not be below minimum"),
280280
Err(err) => match err {
281281
Byron(ByronError::FeesBelowMin) => (),
282282
_ => panic!("Unexpected error ({:?})", err),
@@ -310,7 +310,7 @@ mod byron_tests {
310310
network_id: 1,
311311
};
312312
match validate(&metx, &utxos, &env) {
313-
Ok(()) => assert!(false, "Transaction size cannot exceed protocol limit"),
313+
Ok(()) => panic!("Transaction size cannot exceed protocol limit"),
314314
Err(err) => match err {
315315
Byron(ByronError::MaxTxSizeExceeded) => (),
316316
_ => panic!("Unexpected error ({:?})", err),
@@ -330,7 +330,7 @@ mod byron_tests {
330330
Ok(_) => (),
331331
Err(err) => panic!("Unable to encode Tx ({:?})", err),
332332
};
333-
mtxp.witness = Decode::decode(&mut Decoder::new(&tx_buf.as_slice()), &mut ()).unwrap();
333+
mtxp.witness = Decode::decode(&mut Decoder::new(tx_buf.as_slice()), &mut ()).unwrap();
334334
let metx: MultiEraTx = MultiEraTx::from_byron(&mtxp);
335335
let utxos: UTxOs = mk_utxo_for_byron_tx(
336336
&mtxp.transaction,
@@ -352,7 +352,7 @@ mod byron_tests {
352352
network_id: 1,
353353
};
354354
match validate(&metx, &utxos, &env) {
355-
Ok(()) => assert!(false, "All inputs must have a witness signature"),
355+
Ok(()) => panic!("All inputs must have a witness signature"),
356356
Err(err) => match err {
357357
Byron(ByronError::MissingWitness) => (),
358358
_ => panic!("Unexpected error ({:?})", err),
@@ -381,7 +381,7 @@ mod byron_tests {
381381
Ok(_) => (),
382382
Err(err) => panic!("Unable to encode Tx ({:?})", err),
383383
};
384-
mtxp.witness = Decode::decode(&mut Decoder::new(&tx_buf.as_slice()), &mut ()).unwrap();
384+
mtxp.witness = Decode::decode(&mut Decoder::new(tx_buf.as_slice()), &mut ()).unwrap();
385385
let metx: MultiEraTx = MultiEraTx::from_byron(&mtxp);
386386
let utxos: UTxOs = mk_utxo_for_byron_tx(
387387
&mtxp.transaction,
@@ -403,7 +403,7 @@ mod byron_tests {
403403
network_id: 1,
404404
};
405405
match validate(&metx, &utxos, &env) {
406-
Ok(()) => assert!(false, "Witness signature should verify the transaction"),
406+
Ok(()) => panic!("Witness signature should verify the transaction"),
407407
Err(err) => match err {
408408
Byron(ByronError::WrongSignature) => (),
409409
_ => panic!("Unexpected error ({:?})", err),

pallas-applying/tests/common.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ pub fn cbor_to_bytes(input: &str) -> Vec<u8> {
1414
hex::decode(input).unwrap()
1515
}
1616

17-
pub fn minted_tx_from_cbor<'a>(tx_cbor: &'a Vec<u8>) -> MintedTx<'a> {
18-
pallas_codec::minicbor::decode::<MintedTx>(&tx_cbor[..]).unwrap()
17+
pub fn minted_tx_from_cbor(tx_cbor: &[u8]) -> MintedTx<'_> {
18+
pallas_codec::minicbor::decode::<MintedTx>(tx_cbor).unwrap()
1919
}
2020

21-
pub fn minted_tx_payload_from_cbor<'a>(tx_cbor: &'a Vec<u8>) -> MintedTxPayload<'a> {
22-
pallas_codec::minicbor::decode::<MintedTxPayload>(&tx_cbor[..]).unwrap()
21+
pub fn minted_tx_payload_from_cbor(tx_cbor: &[u8]) -> MintedTxPayload<'_> {
22+
pallas_codec::minicbor::decode::<MintedTxPayload>(tx_cbor).unwrap()
2323
}
2424

2525
pub fn mk_utxo_for_byron_tx<'a>(tx: &Tx, tx_outs_info: &[(String, u64)]) -> UTxOs<'a> {
@@ -34,7 +34,7 @@ pub fn mk_utxo_for_byron_tx<'a>(tx: &Tx, tx_outs_info: &[(String, u64)]) -> UTxO
3434
};
3535
let tx_out: TxOut = TxOut {
3636
address: input_tx_out_addr,
37-
amount: amount.clone(),
37+
amount: *amount,
3838
};
3939
let multi_era_in: MultiEraInput = MultiEraInput::Byron(Box::new(Cow::Owned(tx_in)));
4040
let multi_era_out: MultiEraOutput = MultiEraOutput::Byron(Box::new(Cow::Owned(tx_out)));
@@ -56,7 +56,7 @@ pub fn mk_utxo_for_alonzo_compatible_tx<'a>(
5656
let tx_out: TransactionOutput = TransactionOutput {
5757
address: address_bytes,
5858
amount: amount.clone(),
59-
datum_hash: datum_hash.clone(),
59+
datum_hash: *datum_hash,
6060
};
6161
let multi_era_in: MultiEraInput =
6262
MultiEraInput::AlonzoCompatible(Box::new(Cow::Owned(tx_in)));
@@ -67,9 +67,9 @@ pub fn mk_utxo_for_alonzo_compatible_tx<'a>(
6767
utxos
6868
}
6969

70-
pub fn add_collateral<'a>(
70+
pub fn add_collateral(
7171
tx_body: &TransactionBody,
72-
utxos: &mut UTxOs<'a>,
72+
utxos: &mut UTxOs<'_>,
7373
collateral_info: &[(String, Value, Option<Hash<32>>)],
7474
) {
7575
match &tx_body.collateral {
@@ -82,7 +82,7 @@ pub fn add_collateral<'a>(
8282
let tx_out: TransactionOutput = TransactionOutput {
8383
address: address_bytes,
8484
amount: amount.clone(),
85-
datum_hash: datum_hash.clone(),
85+
datum_hash: *datum_hash,
8686
};
8787
let multi_era_in: MultiEraInput =
8888
MultiEraInput::AlonzoCompatible(Box::new(Cow::Owned(tx_in.clone())));

0 commit comments

Comments
 (0)