@@ -3695,6 +3695,7 @@ impl From<&NativeScripts> for RequiredSignersSet {
36953695
36963696#[ cfg( test) ]
36973697mod tests {
3698+ use crate :: tx_builder_constants:: TxBuilderConstants ;
36983699 use super :: * ;
36993700
37003701 #[ test]
@@ -3946,4 +3947,39 @@ mod tests {
39463947 assert ! ( pks4. contains( & keyhash2) ) ;
39473948 assert ! ( pks4. contains( & keyhash3) ) ;
39483949 }
3950+
3951+ #[ test]
3952+ fn protocol_params_update_cbor_roundtrip ( ) {
3953+ let mut orig_ppu = ProtocolParamUpdate :: new ( ) ;
3954+ orig_ppu. set_max_tx_size ( 1234 ) ;
3955+ orig_ppu. set_max_block_body_size ( 5678 ) ;
3956+ orig_ppu. set_max_block_header_size ( 91011 ) ;
3957+ orig_ppu. set_minfee_a ( & Coin :: from ( 1u32 ) ) ;
3958+ orig_ppu. set_minfee_b ( & Coin :: from ( 2u32 ) ) ;
3959+ orig_ppu. set_key_deposit ( & Coin :: from ( 3u32 ) ) ;
3960+ orig_ppu. set_pool_deposit ( & Coin :: from ( 4u32 ) ) ;
3961+ orig_ppu. set_max_epoch ( 5 ) ;
3962+ orig_ppu. set_n_opt ( 6 ) ;
3963+ orig_ppu. set_pool_pledge_influence ( & Rational :: new ( & BigNum :: from ( 7u32 ) , & BigNum :: from ( 77u32 ) ) ) ;
3964+ orig_ppu. set_expansion_rate ( & UnitInterval :: new ( & BigNum :: from ( 8u32 ) , & BigNum :: from ( 9u32 ) ) ) ;
3965+ orig_ppu. set_treasury_growth_rate ( & UnitInterval :: new ( & BigNum :: from ( 10u32 ) , & BigNum :: from ( 11u32 ) ) ) ;
3966+ orig_ppu. set_protocol_version ( & ProtocolVersion :: new ( 12u32 , 13u32 ) ) ;
3967+ orig_ppu. set_min_pool_cost ( & Coin :: from ( 14u32 ) ) ;
3968+ orig_ppu. set_ada_per_utxo_byte ( & Coin :: from ( 15u32 ) ) ;
3969+ orig_ppu. set_cost_models ( & TxBuilderConstants :: plutus_vasil_cost_models ( ) ) ;
3970+ orig_ppu. set_execution_costs ( & ExUnitPrices :: new (
3971+ & SubCoin :: new ( & BigNum :: from ( 16u32 ) , & BigNum :: from ( 17u32 ) ) ,
3972+ & SubCoin :: new ( & BigNum :: from ( 18u32 ) , & BigNum :: from ( 19u32 ) ) ) ) ;
3973+ orig_ppu. set_max_tx_ex_units ( & ExUnits :: new ( & BigNum :: from ( 20u32 ) , & BigNum :: from ( 21u32 ) ) ) ;
3974+ orig_ppu. set_max_block_ex_units ( & ExUnits :: new ( & BigNum :: from ( 22u32 ) , & BigNum :: from ( 23u32 ) ) ) ;
3975+ orig_ppu. set_max_value_size ( 24 ) ;
3976+ orig_ppu. set_collateral_percentage ( 25 ) ;
3977+ orig_ppu. set_max_collateral_inputs ( 25 ) ;
3978+
3979+ let encoded = orig_ppu. to_bytes ( ) ;
3980+ let dencoded = ProtocolParamUpdate :: from_bytes ( encoded) . unwrap ( ) ;
3981+
3982+ assert_eq ! ( dencoded, orig_ppu) ;
3983+ assert_eq ! ( dencoded. to_bytes( ) , orig_ppu. to_bytes( ) ) ;
3984+ }
39493985}
0 commit comments