chore: Fix lint warnings for all targets (#240)

This commit is contained in:
Santiago Carmuega 2023-03-24 10:59:49 +01:00 committed by GitHub
parent 66a095df4a
commit ae7e1f5c82
15 changed files with 93 additions and 94 deletions

View file

@ -44,19 +44,18 @@ mod tests {
#[test]
fn known_fee_matches() {
// TODO: expand this test to include more test blocks
let block_idx = 1;
let block_str = include_str!("../../test_data/byron4.block");
let block_bytes = hex::decode(block_str).expect(&format!("bad block file {block_idx}"));
let block_bytes = hex::decode(block_str).expect("bad block file");
let block = crate::MultiEraBlock::decode_byron(&block_bytes).unwrap();
let txs = block.txs();
// don't want to pass if we don't have tx in the block
assert!(txs.len() > 0);
assert!(!txs.is_empty());
for tx in txs.iter().take(1) {
let byron = tx.as_byron().unwrap();
let fee = compute_byron_fee(&byron, None);
let fee = compute_byron_fee(byron, None);
assert_eq!(fee, 171070);
}
}

View file

@ -144,7 +144,7 @@ impl ComputeHash<32> for babbage::DatumOption {
#[cfg(test)]
mod tests {
use crate::{Era, MultiEraBlock, MultiEraTx};
use crate::{Era, MultiEraTx};
use super::{ComputeHash, OriginalHash};
use pallas_codec::utils::Int;
@ -159,12 +159,11 @@ mod tests {
type BlockWrapper<'b> = (u16, byron::MintedBlock<'b>);
// TODO: expand this test to include more test blocks
let block_idx = 1;
let block_str = include_str!("../../test_data/byron1.block");
let block_bytes = hex::decode(block_str).expect(&format!("bad block file {block_idx}"));
let (_, block_model): BlockWrapper = minicbor::decode(&block_bytes[..])
.expect(&format!("error decoding cbor for file {block_idx}"));
let block_bytes = hex::decode(block_str).expect("bad block file");
let (_, block_model): BlockWrapper =
minicbor::decode(&block_bytes[..]).expect("error decoding cbor for file");
let computed_hash = block_model.header.original_hash();
@ -179,12 +178,11 @@ mod tests {
type BlockWrapper<'b> = (u16, alonzo::MintedBlock<'b>);
// TODO: expand this test to include more test blocks
let block_idx = 1;
let block_str = include_str!("../../test_data/alonzo1.block");
let block_bytes = hex::decode(block_str).expect(&format!("bad block file {block_idx}"));
let (_, block_model): BlockWrapper = minicbor::decode(&block_bytes[..])
.expect(&format!("error decoding cbor for file {block_idx}"));
let block_bytes = hex::decode(block_str).expect("bad block file");
let (_, block_model): BlockWrapper =
minicbor::decode(&block_bytes[..]).expect("error decoding cbor for file");
let valid_hashes = vec![
"8ae0cd531635579a9b52b954a840782d12235251fb1451e5c699e864c677514a",
@ -209,9 +207,10 @@ mod tests {
let block_idx = 1;
let block_str = include_str!("../../test_data/babbage1.block");
let block_bytes = hex::decode(block_str).expect(&format!("bad block file {block_idx}"));
let block_bytes =
hex::decode(block_str).unwrap_or_else(|_| panic!("bad block file {block_idx}"));
let (_, block_model): BlockWrapper = minicbor::decode(&block_bytes[..])
.expect(&format!("error decoding cbor for file {block_idx}"));
.unwrap_or_else(|_| panic!("error decoding cbor for file {block_idx}"));
let valid_hashes = vec!["3fad302595665b004971a6b76909854a39a0a7ecdbff3692f37b77ae37dbe882"];

View file

@ -103,11 +103,12 @@ pub enum MultiEraCert<'b> {
AlonzoCompatible(Box<Cow<'b, alonzo::Certificate>>),
}
#[derive(Debug, Clone)]
#[derive(Debug, Clone, Default)]
#[non_exhaustive]
pub enum MultiEraMeta<'b> {
NotApplicable,
#[default]
Empty,
NotApplicable,
AlonzoCompatible(&'b alonzo::Metadata),
}

View file

@ -2,12 +2,6 @@ use pallas_primitives::alonzo;
use crate::MultiEraMeta;
impl Default for MultiEraMeta<'_> {
fn default() -> Self {
MultiEraMeta::Empty
}
}
impl<'b> MultiEraMeta<'b> {
pub fn as_alonzo(&self) -> Option<&alonzo::Metadata> {
match self {