chore(primitives): Compact TxType Unit Table Test (#5325)

This commit is contained in:
refcell.eth
2023-11-06 17:25:50 +01:00
committed by GitHub
parent 164b486d9b
commit 45f3ee7b32

View File

@@ -116,6 +116,29 @@ impl Compact for TxType {
mod tests {
use super::*;
#[test]
fn test_txtype_to_compat() {
let cases = vec![
(TxType::Legacy, 0, vec![]),
(TxType::EIP2930, 1, vec![]),
(TxType::EIP1559, 2, vec![]),
(TxType::EIP4844, 3, vec![EIP4844_TX_TYPE_ID]),
#[cfg(feature = "optimism")]
(TxType::DEPOSIT, 3, vec![DEPOSIT_TX_TYPE_ID]),
];
for (tx_type, expected_identifier, expected_buf) in cases {
let mut buf = vec![];
let identifier = tx_type.to_compact(&mut buf);
assert_eq!(
identifier, expected_identifier,
"Unexpected identifier for TxType {:?}",
tx_type
);
assert_eq!(buf, expected_buf, "Unexpected buffer for TxType {:?}", tx_type);
}
}
#[test]
fn test_txtype_from_compact() {
let cases = vec![