chore: fix new lint warnings (#400)
This commit is contained in:
parent
78414b6ce8
commit
3dd00ad3cd
10 changed files with 163 additions and 182 deletions
|
|
@ -1,7 +1,7 @@
|
|||
pub mod common;
|
||||
|
||||
use common::*;
|
||||
use hex;
|
||||
|
||||
use pallas_addresses::{Address, Network, ShelleyAddress, ShelleyPaymentPart};
|
||||
use pallas_applying::{
|
||||
utils::{
|
||||
|
|
@ -65,7 +65,7 @@ mod alonzo_tests {
|
|||
};
|
||||
match validate(&metx, &utxos, &env) {
|
||||
Ok(()) => (),
|
||||
Err(err) => assert!(false, "Unexpected error ({:?})", err),
|
||||
Err(err) => panic!("Unexpected error ({:?})", err),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -179,7 +179,7 @@ mod alonzo_tests {
|
|||
};
|
||||
match validate(&metx, &utxos, &env) {
|
||||
Ok(()) => (),
|
||||
Err(err) => assert!(false, "Unexpected error ({:?})", err),
|
||||
Err(err) => panic!("Unexpected error ({:?})", err),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -220,7 +220,7 @@ mod alonzo_tests {
|
|||
};
|
||||
match validate(&metx, &utxos, &env) {
|
||||
Ok(()) => (),
|
||||
Err(err) => assert!(false, "Unexpected error ({:?})", err),
|
||||
Err(err) => panic!("Unexpected error ({:?})", err),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -261,7 +261,7 @@ mod alonzo_tests {
|
|||
};
|
||||
match validate(&metx, &utxos, &env) {
|
||||
Ok(()) => (),
|
||||
Err(err) => assert!(false, "Unexpected error ({:?})", err),
|
||||
Err(err) => panic!("Unexpected error ({:?})", err),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -283,7 +283,7 @@ mod alonzo_tests {
|
|||
let mut tx_buf: Vec<u8> = Vec::new();
|
||||
let _ = encode(tx_body, &mut tx_buf);
|
||||
mtx.transaction_body =
|
||||
Decode::decode(&mut Decoder::new(&tx_buf.as_slice()), &mut ()).unwrap();
|
||||
Decode::decode(&mut Decoder::new(tx_buf.as_slice()), &mut ()).unwrap();
|
||||
let metx: MultiEraTx = MultiEraTx::from_alonzo_compatible(&mtx, Era::Alonzo);
|
||||
let env: Environment = Environment {
|
||||
prot_params: MultiEraProtParams::Alonzo(AlonzoProtParams {
|
||||
|
|
@ -306,10 +306,10 @@ mod alonzo_tests {
|
|||
network_id: 1,
|
||||
};
|
||||
match validate(&metx, &utxos, &env) {
|
||||
Ok(()) => assert!(false, "Inputs set should not be empty"),
|
||||
Ok(()) => panic!("Inputs set should not be empty"),
|
||||
Err(err) => match err {
|
||||
Alonzo(AlonzoError::TxInsEmpty) => (),
|
||||
_ => assert!(false, "Unexpected error ({:?})", err),
|
||||
_ => panic!("Unexpected error ({:?})", err),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
@ -343,10 +343,10 @@ mod alonzo_tests {
|
|||
network_id: 1,
|
||||
};
|
||||
match validate(&metx, &utxos, &env) {
|
||||
Ok(()) => assert!(false, "All inputs should be within the UTxO set"),
|
||||
Ok(()) => panic!("All inputs should be within the UTxO set"),
|
||||
Err(err) => match err {
|
||||
Alonzo(AlonzoError::InputNotInUTxO) => (),
|
||||
_ => assert!(false, "Unexpected error ({:?})", err),
|
||||
_ => panic!("Unexpected error ({:?})", err),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
@ -370,7 +370,7 @@ mod alonzo_tests {
|
|||
let mut tx_buf: Vec<u8> = Vec::new();
|
||||
let _ = encode(tx_body, &mut tx_buf);
|
||||
mtx.transaction_body =
|
||||
Decode::decode(&mut Decoder::new(&tx_buf.as_slice()), &mut ()).unwrap();
|
||||
Decode::decode(&mut Decoder::new(tx_buf.as_slice()), &mut ()).unwrap();
|
||||
let metx: MultiEraTx = MultiEraTx::from_alonzo_compatible(&mtx, Era::Alonzo);
|
||||
let env: Environment = Environment {
|
||||
prot_params: MultiEraProtParams::Alonzo(AlonzoProtParams {
|
||||
|
|
@ -393,13 +393,10 @@ mod alonzo_tests {
|
|||
network_id: 1,
|
||||
};
|
||||
match validate(&metx, &utxos, &env) {
|
||||
Ok(()) => assert!(
|
||||
false,
|
||||
"Validity interval lower bound should have been reached",
|
||||
),
|
||||
Ok(()) => panic!("Validity interval lower bound should have been reached",),
|
||||
Err(err) => match err {
|
||||
Alonzo(AlonzoError::BlockPrecedesValInt) => (),
|
||||
_ => assert!(false, "Unexpected error ({:?})", err),
|
||||
_ => panic!("Unexpected error ({:?})", err),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
@ -423,7 +420,7 @@ mod alonzo_tests {
|
|||
let mut tx_buf: Vec<u8> = Vec::new();
|
||||
let _ = encode(tx_body, &mut tx_buf);
|
||||
mtx.transaction_body =
|
||||
Decode::decode(&mut Decoder::new(&tx_buf.as_slice()), &mut ()).unwrap();
|
||||
Decode::decode(&mut Decoder::new(tx_buf.as_slice()), &mut ()).unwrap();
|
||||
let metx: MultiEraTx = MultiEraTx::from_alonzo_compatible(&mtx, Era::Alonzo);
|
||||
let env: Environment = Environment {
|
||||
prot_params: MultiEraProtParams::Alonzo(AlonzoProtParams {
|
||||
|
|
@ -446,13 +443,10 @@ mod alonzo_tests {
|
|||
network_id: 1,
|
||||
};
|
||||
match validate(&metx, &utxos, &env) {
|
||||
Ok(()) => assert!(
|
||||
false,
|
||||
"Validity interval upper bound should not have been surpassed",
|
||||
),
|
||||
Ok(()) => panic!("Validity interval upper bound should not have been surpassed",),
|
||||
Err(err) => match err {
|
||||
Alonzo(AlonzoError::BlockExceedsValInt) => (),
|
||||
_ => assert!(false, "Unexpected error ({:?})", err),
|
||||
_ => panic!("Unexpected error ({:?})", err),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
@ -493,10 +487,10 @@ mod alonzo_tests {
|
|||
network_id: 1,
|
||||
};
|
||||
match validate(&metx, &utxos, &env) {
|
||||
Ok(()) => assert!(false, "Fee should not be below minimum"),
|
||||
Ok(()) => panic!("Fee should not be below minimum"),
|
||||
Err(err) => match err {
|
||||
Alonzo(AlonzoError::FeeBelowMin) => (),
|
||||
_ => assert!(false, "Unexpected error ({:?})", err),
|
||||
_ => panic!("Unexpected error ({:?})", err),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
@ -593,7 +587,7 @@ mod alonzo_tests {
|
|||
let mut tx_buf: Vec<u8> = Vec::new();
|
||||
let _ = encode(tx_body, &mut tx_buf);
|
||||
mtx.transaction_body =
|
||||
Decode::decode(&mut Decoder::new(&tx_buf.as_slice()), &mut ()).unwrap();
|
||||
Decode::decode(&mut Decoder::new(tx_buf.as_slice()), &mut ()).unwrap();
|
||||
let metx: MultiEraTx = MultiEraTx::from_alonzo_compatible(&mtx, Era::Alonzo);
|
||||
let env: Environment = Environment {
|
||||
prot_params: MultiEraProtParams::Alonzo(AlonzoProtParams {
|
||||
|
|
@ -616,10 +610,10 @@ mod alonzo_tests {
|
|||
network_id: 1,
|
||||
};
|
||||
match validate(&metx, &utxos, &env) {
|
||||
Ok(()) => assert!(false, "No collateral inputs"),
|
||||
Ok(()) => panic!("No collateral inputs"),
|
||||
Err(err) => match err {
|
||||
Alonzo(AlonzoError::CollateralMissing) => (),
|
||||
_ => assert!(false, "Unexpected error ({:?})", err),
|
||||
_ => panic!("Unexpected error ({:?})", err),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
@ -734,10 +728,10 @@ mod alonzo_tests {
|
|||
network_id: 1,
|
||||
};
|
||||
match validate(&metx, &utxos, &env) {
|
||||
Ok(()) => assert!(false, "Number of collateral inputs should be within limits"),
|
||||
Ok(()) => panic!("Number of collateral inputs should be within limits"),
|
||||
Err(err) => match err {
|
||||
Alonzo(AlonzoError::TooManyCollaterals) => (),
|
||||
_ => assert!(false, "Unexpected error ({:?})", err),
|
||||
_ => panic!("Unexpected error ({:?})", err),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
@ -832,7 +826,7 @@ mod alonzo_tests {
|
|||
};
|
||||
let altered_address: ShelleyAddress = ShelleyAddress::new(
|
||||
old_shelley_address.network(),
|
||||
ShelleyPaymentPart::Script(old_shelley_address.payment().as_hash().clone()),
|
||||
ShelleyPaymentPart::Script(*old_shelley_address.payment().as_hash()),
|
||||
old_shelley_address.delegation().clone(),
|
||||
);
|
||||
let tx_in = mtx
|
||||
|
|
@ -873,10 +867,10 @@ mod alonzo_tests {
|
|||
network_id: 1,
|
||||
};
|
||||
match validate(&metx, &utxos, &env) {
|
||||
Ok(()) => assert!(false, "Collateral inputs should be verification-key locked"),
|
||||
Ok(()) => panic!("Collateral inputs should be verification-key locked"),
|
||||
Err(err) => match err {
|
||||
Alonzo(AlonzoError::CollateralNotVKeyLocked) => (),
|
||||
_ => assert!(false, "Unexpected error ({:?})", err),
|
||||
_ => panic!("Unexpected error ({:?})", err),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
@ -1001,10 +995,10 @@ mod alonzo_tests {
|
|||
network_id: 1,
|
||||
};
|
||||
match validate(&metx, &utxos, &env) {
|
||||
Ok(()) => assert!(false, "Collateral inputs should contain only lovelace"),
|
||||
Ok(()) => panic!("Collateral inputs should contain only lovelace"),
|
||||
Err(err) => match err {
|
||||
Alonzo(AlonzoError::NonLovelaceCollateral) => (),
|
||||
_ => assert!(false, "Unexpected error ({:?})", err),
|
||||
_ => panic!("Unexpected error ({:?})", err),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
@ -1118,13 +1112,10 @@ mod alonzo_tests {
|
|||
network_id: 1,
|
||||
};
|
||||
match validate(&metx, &utxos, &env) {
|
||||
Ok(()) => assert!(
|
||||
false,
|
||||
"Collateral inputs should contain the minimum lovelace"
|
||||
),
|
||||
Ok(()) => panic!("Collateral inputs should contain the minimum lovelace"),
|
||||
Err(err) => match err {
|
||||
Alonzo(AlonzoError::CollateralMinLovelace) => (),
|
||||
_ => assert!(false, "Unexpected error ({:?})", err),
|
||||
_ => panic!("Unexpected error ({:?})", err),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
@ -1144,11 +1135,11 @@ mod alonzo_tests {
|
|||
)],
|
||||
);
|
||||
let mut tx_body: TransactionBody = (*mtx.transaction_body).clone();
|
||||
tx_body.fee = tx_body.fee - 1;
|
||||
tx_body.fee -= 1;
|
||||
let mut tx_buf: Vec<u8> = Vec::new();
|
||||
let _ = encode(tx_body, &mut tx_buf);
|
||||
mtx.transaction_body =
|
||||
Decode::decode(&mut Decoder::new(&tx_buf.as_slice()), &mut ()).unwrap();
|
||||
Decode::decode(&mut Decoder::new(tx_buf.as_slice()), &mut ()).unwrap();
|
||||
let metx: MultiEraTx = MultiEraTx::from_alonzo_compatible(&mtx, Era::Alonzo);
|
||||
let env: Environment = Environment {
|
||||
prot_params: MultiEraProtParams::Alonzo(AlonzoProtParams {
|
||||
|
|
@ -1171,10 +1162,10 @@ mod alonzo_tests {
|
|||
network_id: 1,
|
||||
};
|
||||
match validate(&metx, &utxos, &env) {
|
||||
Ok(()) => assert!(false, "Preservation of value doesn't hold"),
|
||||
Ok(()) => panic!("Preservation of value doesn't hold"),
|
||||
Err(err) => match err {
|
||||
Alonzo(AlonzoError::PreservationOfValue) => (),
|
||||
_ => assert!(false, "Unexpected error ({:?})", err),
|
||||
_ => panic!("Unexpected error ({:?})", err),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
@ -1187,7 +1178,7 @@ mod alonzo_tests {
|
|||
let mut mtx: MintedTx = minted_tx_from_cbor(&cbor_bytes);
|
||||
let mut tx_body: TransactionBody = (*mtx.transaction_body).clone();
|
||||
let (first_output, rest): (&TransactionOutput, &[TransactionOutput]) =
|
||||
(&tx_body.outputs).split_first().unwrap();
|
||||
tx_body.outputs.split_first().unwrap();
|
||||
let addr: ShelleyAddress =
|
||||
match Address::from_bytes(&Vec::<u8>::from(first_output.address.clone())) {
|
||||
Ok(Address::Shelley(sa)) => sa,
|
||||
|
|
@ -1210,7 +1201,7 @@ mod alonzo_tests {
|
|||
let mut tx_buf: Vec<u8> = Vec::new();
|
||||
let _ = encode(tx_body, &mut tx_buf);
|
||||
mtx.transaction_body =
|
||||
Decode::decode(&mut Decoder::new(&tx_buf.as_slice()), &mut ()).unwrap();
|
||||
Decode::decode(&mut Decoder::new(tx_buf.as_slice()), &mut ()).unwrap();
|
||||
let metx: MultiEraTx = MultiEraTx::from_alonzo_compatible(&mtx, Era::Alonzo);
|
||||
let utxos: UTxOs = mk_utxo_for_alonzo_compatible_tx(
|
||||
&mtx.transaction_body,
|
||||
|
|
@ -1241,13 +1232,10 @@ mod alonzo_tests {
|
|||
network_id: 1,
|
||||
};
|
||||
match validate(&metx, &utxos, &env) {
|
||||
Ok(()) => assert!(
|
||||
false,
|
||||
"Transaction network ID should match environment network_id"
|
||||
),
|
||||
Ok(()) => panic!("Transaction network ID should match environment network_id"),
|
||||
Err(err) => match err {
|
||||
Alonzo(AlonzoError::OutputWrongNetworkID) => (),
|
||||
_ => assert!(false, "Unexpected error ({:?})", err),
|
||||
_ => panic!("Unexpected error ({:?})", err),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
@ -1263,7 +1251,7 @@ mod alonzo_tests {
|
|||
let mut tx_buf: Vec<u8> = Vec::new();
|
||||
let _ = encode(tx_body, &mut tx_buf);
|
||||
mtx.transaction_body =
|
||||
Decode::decode(&mut Decoder::new(&tx_buf.as_slice()), &mut ()).unwrap();
|
||||
Decode::decode(&mut Decoder::new(tx_buf.as_slice()), &mut ()).unwrap();
|
||||
let metx: MultiEraTx = MultiEraTx::from_alonzo_compatible(&mtx, Era::Alonzo);
|
||||
let utxos: UTxOs = mk_utxo_for_alonzo_compatible_tx(
|
||||
&mtx.transaction_body,
|
||||
|
|
@ -1294,13 +1282,10 @@ mod alonzo_tests {
|
|||
network_id: 1,
|
||||
};
|
||||
match validate(&metx, &utxos, &env) {
|
||||
Ok(()) => assert!(
|
||||
false,
|
||||
"Transaction network ID should match environment network_id"
|
||||
),
|
||||
Ok(()) => panic!("Transaction network ID should match environment network_id"),
|
||||
Err(err) => match err {
|
||||
Alonzo(AlonzoError::TxWrongNetworkID) => (),
|
||||
_ => assert!(false, "Unexpected error ({:?})", err),
|
||||
_ => panic!("Unexpected error ({:?})", err),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
@ -1414,10 +1399,10 @@ mod alonzo_tests {
|
|||
network_id: 1,
|
||||
};
|
||||
match validate(&metx, &utxos, &env) {
|
||||
Ok(()) => assert!(false, "Transaction ex units should be below maximum"),
|
||||
Ok(()) => panic!("Transaction ex units should be below maximum"),
|
||||
Err(err) => match err {
|
||||
Alonzo(AlonzoError::TxExUnitsExceeded) => (),
|
||||
_ => assert!(false, "Unexpected error ({:?})", err),
|
||||
_ => panic!("Unexpected error ({:?})", err),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
@ -1459,13 +1444,12 @@ mod alonzo_tests {
|
|||
network_id: 1,
|
||||
};
|
||||
match validate(&metx, &utxos, &env) {
|
||||
Ok(()) => assert!(
|
||||
false,
|
||||
Ok(()) => panic!(
|
||||
"Transaction size should not exceed the maximum allowed by the protocol parameter"
|
||||
),
|
||||
Err(err) => match err {
|
||||
Alonzo(AlonzoError::MaxTxSizeExceeded) => (),
|
||||
_ => assert!(false, "Unexpected error ({:?})", err),
|
||||
_ => panic!("Unexpected error ({:?})", err),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
@ -1568,7 +1552,7 @@ mod alonzo_tests {
|
|||
let mut tx_buf: Vec<u8> = Vec::new();
|
||||
let _ = encode(tx_body, &mut tx_buf);
|
||||
mtx.transaction_body =
|
||||
Decode::decode(&mut Decoder::new(&tx_buf.as_slice()), &mut ()).unwrap();
|
||||
Decode::decode(&mut Decoder::new(tx_buf.as_slice()), &mut ()).unwrap();
|
||||
let metx: MultiEraTx = MultiEraTx::from_alonzo_compatible(&mtx, Era::Alonzo);
|
||||
let env: Environment = Environment {
|
||||
prot_params: MultiEraProtParams::Alonzo(AlonzoProtParams {
|
||||
|
|
@ -1591,13 +1575,10 @@ mod alonzo_tests {
|
|||
network_id: 1,
|
||||
};
|
||||
match validate(&metx, &utxos, &env) {
|
||||
Ok(()) => assert!(
|
||||
false,
|
||||
"All required signers should have signed the transaction"
|
||||
),
|
||||
Ok(()) => panic!("All required signers should have signed the transaction"),
|
||||
Err(err) => match err {
|
||||
Alonzo(AlonzoError::ReqSignerMissing) => (),
|
||||
_ => assert!(false, "Unexpected error ({:?})", err),
|
||||
_ => panic!("Unexpected error ({:?})", err),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
@ -1621,7 +1602,7 @@ mod alonzo_tests {
|
|||
let mut tx_buf: Vec<u8> = Vec::new();
|
||||
let _ = encode(tx_wits, &mut tx_buf);
|
||||
mtx.transaction_witness_set =
|
||||
Decode::decode(&mut Decoder::new(&tx_buf.as_slice()), &mut ()).unwrap();
|
||||
Decode::decode(&mut Decoder::new(tx_buf.as_slice()), &mut ()).unwrap();
|
||||
let metx: MultiEraTx = MultiEraTx::from_alonzo_compatible(&mtx, Era::Alonzo);
|
||||
let env: Environment = Environment {
|
||||
prot_params: MultiEraProtParams::Alonzo(AlonzoProtParams {
|
||||
|
|
@ -1644,10 +1625,10 @@ mod alonzo_tests {
|
|||
network_id: 1,
|
||||
};
|
||||
match validate(&metx, &utxos, &env) {
|
||||
Ok(()) => assert!(false, "Missing verification key witness"),
|
||||
Ok(()) => panic!("Missing verification key witness"),
|
||||
Err(err) => match err {
|
||||
Alonzo(AlonzoError::VKWitnessMissing) => (),
|
||||
_ => assert!(false, "Unexpected error ({:?})", err),
|
||||
_ => panic!("Unexpected error ({:?})", err),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
@ -1678,7 +1659,7 @@ mod alonzo_tests {
|
|||
let mut tx_buf: Vec<u8> = Vec::new();
|
||||
let _ = encode(tx_wits, &mut tx_buf);
|
||||
mtx.transaction_witness_set =
|
||||
Decode::decode(&mut Decoder::new(&tx_buf.as_slice()), &mut ()).unwrap();
|
||||
Decode::decode(&mut Decoder::new(tx_buf.as_slice()), &mut ()).unwrap();
|
||||
let metx: MultiEraTx = MultiEraTx::from_alonzo_compatible(&mtx, Era::Alonzo);
|
||||
let env: Environment = Environment {
|
||||
prot_params: MultiEraProtParams::Alonzo(AlonzoProtParams {
|
||||
|
|
@ -1701,10 +1682,10 @@ mod alonzo_tests {
|
|||
network_id: 1,
|
||||
};
|
||||
match validate(&metx, &utxos, &env) {
|
||||
Ok(()) => assert!(false, "Witness signature should verify the transaction"),
|
||||
Ok(()) => panic!("Witness signature should verify the transaction"),
|
||||
Err(err) => match err {
|
||||
Alonzo(AlonzoError::VKWrongSignature) => (),
|
||||
_ => assert!(false, "Unexpected error ({:?})", err),
|
||||
_ => panic!("Unexpected error ({:?})", err),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
@ -1801,7 +1782,7 @@ mod alonzo_tests {
|
|||
let mut tx_buf: Vec<u8> = Vec::new();
|
||||
let _ = encode(tx_wits, &mut tx_buf);
|
||||
mtx.transaction_witness_set =
|
||||
Decode::decode(&mut Decoder::new(&tx_buf.as_slice()), &mut ()).unwrap();
|
||||
Decode::decode(&mut Decoder::new(tx_buf.as_slice()), &mut ()).unwrap();
|
||||
let metx: MultiEraTx = MultiEraTx::from_alonzo_compatible(&mtx, Era::Alonzo);
|
||||
let env: Environment = Environment {
|
||||
prot_params: MultiEraProtParams::Alonzo(AlonzoProtParams {
|
||||
|
|
@ -1824,10 +1805,10 @@ mod alonzo_tests {
|
|||
network_id: 1,
|
||||
};
|
||||
match validate(&metx, &utxos, &env) {
|
||||
Ok(()) => assert!(false, "Missing Plutus script"),
|
||||
Ok(()) => panic!("Missing Plutus script"),
|
||||
Err(err) => match err {
|
||||
Alonzo(AlonzoError::ScriptWitnessMissing) => (),
|
||||
_ => assert!(false, "Unexpected error ({:?})", err),
|
||||
_ => panic!("Unexpected error ({:?})", err),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
@ -1924,7 +1905,7 @@ mod alonzo_tests {
|
|||
let mut encode_native_script_buf: Vec<u8> = Vec::new();
|
||||
let _ = encode(native_script, &mut encode_native_script_buf);
|
||||
let keep_raw_native_script: KeepRaw<NativeScript> = Decode::decode(
|
||||
&mut Decoder::new(&encode_native_script_buf.as_slice()),
|
||||
&mut Decoder::new(encode_native_script_buf.as_slice()),
|
||||
&mut (),
|
||||
)
|
||||
.unwrap();
|
||||
|
|
@ -1932,7 +1913,7 @@ mod alonzo_tests {
|
|||
let mut tx_buf: Vec<u8> = Vec::new();
|
||||
let _ = encode(tx_wits, &mut tx_buf);
|
||||
mtx.transaction_witness_set =
|
||||
Decode::decode(&mut Decoder::new(&tx_buf.as_slice()), &mut ()).unwrap();
|
||||
Decode::decode(&mut Decoder::new(tx_buf.as_slice()), &mut ()).unwrap();
|
||||
let metx: MultiEraTx = MultiEraTx::from_alonzo_compatible(&mtx, Era::Alonzo);
|
||||
let env: Environment = Environment {
|
||||
prot_params: MultiEraProtParams::Alonzo(AlonzoProtParams {
|
||||
|
|
@ -1955,10 +1936,10 @@ mod alonzo_tests {
|
|||
network_id: 1,
|
||||
};
|
||||
match validate(&metx, &utxos, &env) {
|
||||
Ok(()) => assert!(false, "Unneeded Plutus script"),
|
||||
Ok(()) => panic!("Unneeded Plutus script"),
|
||||
Err(err) => match err {
|
||||
Alonzo(AlonzoError::UnneededNativeScript) => (),
|
||||
_ => assert!(false, "Unexpected error ({:?})", err),
|
||||
_ => panic!("Unexpected error ({:?})", err),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
@ -1982,7 +1963,7 @@ mod alonzo_tests {
|
|||
let mut tx_buf: Vec<u8> = Vec::new();
|
||||
let _ = encode(tx_wits, &mut tx_buf);
|
||||
mtx.transaction_witness_set =
|
||||
Decode::decode(&mut Decoder::new(&tx_buf.as_slice()), &mut ()).unwrap();
|
||||
Decode::decode(&mut Decoder::new(tx_buf.as_slice()), &mut ()).unwrap();
|
||||
let metx: MultiEraTx = MultiEraTx::from_alonzo_compatible(&mtx, Era::Alonzo);
|
||||
let env: Environment = Environment {
|
||||
prot_params: MultiEraProtParams::Alonzo(AlonzoProtParams {
|
||||
|
|
@ -2005,10 +1986,10 @@ mod alonzo_tests {
|
|||
network_id: 1,
|
||||
};
|
||||
match validate(&metx, &utxos, &env) {
|
||||
Ok(()) => assert!(false, "Minting policy is not supported by native script"),
|
||||
Ok(()) => panic!("Minting policy is not supported by native script"),
|
||||
Err(err) => match err {
|
||||
Alonzo(AlonzoError::MintingLacksPolicy) => (),
|
||||
_ => assert!(false, "Unexpected error ({:?})", err),
|
||||
_ => panic!("Unexpected error ({:?})", err),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
@ -2105,7 +2086,7 @@ mod alonzo_tests {
|
|||
let mut tx_buf: Vec<u8> = Vec::new();
|
||||
let _ = encode(tx_wits, &mut tx_buf);
|
||||
mtx.transaction_witness_set =
|
||||
Decode::decode(&mut Decoder::new(&tx_buf.as_slice()), &mut ()).unwrap();
|
||||
Decode::decode(&mut Decoder::new(tx_buf.as_slice()), &mut ()).unwrap();
|
||||
let metx: MultiEraTx = MultiEraTx::from_alonzo_compatible(&mtx, Era::Alonzo);
|
||||
let env: Environment = Environment {
|
||||
prot_params: MultiEraProtParams::Alonzo(AlonzoProtParams {
|
||||
|
|
@ -2128,10 +2109,10 @@ mod alonzo_tests {
|
|||
network_id: 1,
|
||||
};
|
||||
match validate(&metx, &utxos, &env) {
|
||||
Ok(()) => assert!(false, "Missing datum"),
|
||||
Ok(()) => panic!("Missing datum"),
|
||||
Err(err) => match err {
|
||||
Alonzo(AlonzoError::DatumMissing) => (),
|
||||
_ => assert!(false, "Unexpected error ({:?})", err),
|
||||
_ => panic!("Unexpected error ({:?})", err),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
@ -2229,12 +2210,12 @@ mod alonzo_tests {
|
|||
let mut new_datum_buf: Vec<u8> = Vec::new();
|
||||
let _ = encode(new_datum, &mut new_datum_buf);
|
||||
let keep_raw_new_datum: KeepRaw<PlutusData> =
|
||||
Decode::decode(&mut Decoder::new(&new_datum_buf.as_slice()), &mut ()).unwrap();
|
||||
Decode::decode(&mut Decoder::new(new_datum_buf.as_slice()), &mut ()).unwrap();
|
||||
tx_wits.plutus_data = Some(vec![old_datum, keep_raw_new_datum]);
|
||||
let mut tx_buf: Vec<u8> = Vec::new();
|
||||
let _ = encode(tx_wits, &mut tx_buf);
|
||||
mtx.transaction_witness_set =
|
||||
Decode::decode(&mut Decoder::new(&tx_buf.as_slice()), &mut ()).unwrap();
|
||||
Decode::decode(&mut Decoder::new(tx_buf.as_slice()), &mut ()).unwrap();
|
||||
let metx: MultiEraTx = MultiEraTx::from_alonzo_compatible(&mtx, Era::Alonzo);
|
||||
let env: Environment = Environment {
|
||||
prot_params: MultiEraProtParams::Alonzo(AlonzoProtParams {
|
||||
|
|
@ -2257,10 +2238,10 @@ mod alonzo_tests {
|
|||
network_id: 1,
|
||||
};
|
||||
match validate(&metx, &utxos, &env) {
|
||||
Ok(()) => assert!(false, "Unneeded datum"),
|
||||
Ok(()) => panic!("Unneeded datum"),
|
||||
Err(err) => match err {
|
||||
Alonzo(AlonzoError::UnneededDatum) => (),
|
||||
_ => assert!(false, "Unexpected error ({:?})", err),
|
||||
_ => panic!("Unexpected error ({:?})", err),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
@ -2364,7 +2345,7 @@ mod alonzo_tests {
|
|||
let mut tx_buf: Vec<u8> = Vec::new();
|
||||
let _ = encode(tx_wits, &mut tx_buf);
|
||||
mtx.transaction_witness_set =
|
||||
Decode::decode(&mut Decoder::new(&tx_buf.as_slice()), &mut ()).unwrap();
|
||||
Decode::decode(&mut Decoder::new(tx_buf.as_slice()), &mut ()).unwrap();
|
||||
let metx: MultiEraTx = MultiEraTx::from_alonzo_compatible(&mtx, Era::Alonzo);
|
||||
let env: Environment = Environment {
|
||||
prot_params: MultiEraProtParams::Alonzo(AlonzoProtParams {
|
||||
|
|
@ -2387,10 +2368,10 @@ mod alonzo_tests {
|
|||
network_id: 1,
|
||||
};
|
||||
match validate(&metx, &utxos, &env) {
|
||||
Ok(()) => assert!(false, "Unneeded redeemer"),
|
||||
Ok(()) => panic!("Unneeded redeemer"),
|
||||
Err(err) => match err {
|
||||
Alonzo(AlonzoError::UnneededRedeemer) => (),
|
||||
_ => assert!(false, "Unexpected error ({:?})", err),
|
||||
_ => panic!("Unexpected error ({:?})", err),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
@ -2487,7 +2468,7 @@ mod alonzo_tests {
|
|||
let mut tx_buf: Vec<u8> = Vec::new();
|
||||
let _ = encode(tx_wits, &mut tx_buf);
|
||||
mtx.transaction_witness_set =
|
||||
Decode::decode(&mut Decoder::new(&tx_buf.as_slice()), &mut ()).unwrap();
|
||||
Decode::decode(&mut Decoder::new(tx_buf.as_slice()), &mut ()).unwrap();
|
||||
let metx: MultiEraTx = MultiEraTx::from_alonzo_compatible(&mtx, Era::Alonzo);
|
||||
let env: Environment = Environment {
|
||||
prot_params: MultiEraProtParams::Alonzo(AlonzoProtParams {
|
||||
|
|
@ -2510,10 +2491,10 @@ mod alonzo_tests {
|
|||
network_id: 1,
|
||||
};
|
||||
match validate(&metx, &utxos, &env) {
|
||||
Ok(()) => assert!(false, "Unneeded redeemer"),
|
||||
Ok(()) => panic!("Unneeded redeemer"),
|
||||
Err(err) => match err {
|
||||
Alonzo(AlonzoError::RedeemerMissing) => (),
|
||||
_ => assert!(false, "Unexpected error ({:?})", err),
|
||||
_ => panic!("Unexpected error ({:?})", err),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
@ -2555,10 +2536,10 @@ mod alonzo_tests {
|
|||
network_id: 1,
|
||||
};
|
||||
match validate(&metx, &utxos, &env) {
|
||||
Ok(()) => assert!(false, "Unneeded redeemer"),
|
||||
Ok(()) => panic!("Unneeded redeemer"),
|
||||
Err(err) => match err {
|
||||
Alonzo(AlonzoError::MetadataHash) => (),
|
||||
_ => assert!(false, "Unexpected error ({:?})", err),
|
||||
_ => panic!("Unexpected error ({:?})", err),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
@ -2599,10 +2580,10 @@ mod alonzo_tests {
|
|||
network_id: 1,
|
||||
};
|
||||
match validate(&metx, &utxos, &env) {
|
||||
Ok(()) => assert!(false, "Unneeded redeemer"),
|
||||
Ok(()) => panic!("Unneeded redeemer"),
|
||||
Err(err) => match err {
|
||||
Alonzo(AlonzoError::MinLovelaceUnreached) => (),
|
||||
_ => assert!(false, "Unexpected error ({:?})", err),
|
||||
_ => panic!("Unexpected error ({:?})", err),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
@ -2643,10 +2624,10 @@ mod alonzo_tests {
|
|||
network_id: 1,
|
||||
};
|
||||
match validate(&metx, &utxos, &env) {
|
||||
Ok(()) => assert!(false, "Unneeded redeemer"),
|
||||
Ok(()) => panic!("Unneeded redeemer"),
|
||||
Err(err) => match err {
|
||||
Alonzo(AlonzoError::MaxValSizeExceeded) => (),
|
||||
_ => assert!(false, "Unexpected error ({:?})", err),
|
||||
_ => panic!("Unexpected error ({:?})", err),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
@ -2747,7 +2728,7 @@ mod alonzo_tests {
|
|||
let mut tx_witness_set_buf: Vec<u8> = Vec::new();
|
||||
let _ = encode(tx_witness_set, &mut tx_witness_set_buf);
|
||||
mtx.transaction_witness_set =
|
||||
Decode::decode(&mut Decoder::new(&tx_witness_set_buf.as_slice()), &mut ()).unwrap();
|
||||
Decode::decode(&mut Decoder::new(tx_witness_set_buf.as_slice()), &mut ()).unwrap();
|
||||
let metx: MultiEraTx = MultiEraTx::from_alonzo_compatible(&mtx, Era::Alonzo);
|
||||
let env: Environment = Environment {
|
||||
prot_params: MultiEraProtParams::Alonzo(AlonzoProtParams {
|
||||
|
|
@ -2770,10 +2751,10 @@ mod alonzo_tests {
|
|||
network_id: 1,
|
||||
};
|
||||
match validate(&metx, &utxos, &env) {
|
||||
Ok(()) => assert!(false, "Wrong script integrity hash"),
|
||||
Ok(()) => panic!("Wrong script integrity hash"),
|
||||
Err(err) => match err {
|
||||
Alonzo(AlonzoError::ScriptIntegrityHash) => (),
|
||||
_ => assert!(false, "Unexpected error ({:?})", err),
|
||||
_ => panic!("Unexpected error ({:?})", err),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -107,7 +107,7 @@ mod byron_tests {
|
|||
Ok(_) => (),
|
||||
Err(err) => panic!("Unable to encode Tx ({:?})", err),
|
||||
};
|
||||
mtxp.transaction = Decode::decode(&mut Decoder::new(&tx_buf.as_slice()), &mut ()).unwrap();
|
||||
mtxp.transaction = Decode::decode(&mut Decoder::new(tx_buf.as_slice()), &mut ()).unwrap();
|
||||
let metx: MultiEraTx = MultiEraTx::from_byron(&mtxp);
|
||||
let env: Environment = Environment {
|
||||
prot_params: MultiEraProtParams::Byron(ByronProtParams {
|
||||
|
|
@ -122,7 +122,7 @@ mod byron_tests {
|
|||
network_id: 1,
|
||||
};
|
||||
match validate(&metx, &utxos, &env) {
|
||||
Ok(()) => assert!(false, "Inputs set should not be empty"),
|
||||
Ok(()) => panic!("Inputs set should not be empty"),
|
||||
Err(err) => match err {
|
||||
Byron(ByronError::TxInsEmpty) => (),
|
||||
_ => panic!("Unexpected error ({:?})", err),
|
||||
|
|
@ -143,7 +143,7 @@ mod byron_tests {
|
|||
Ok(_) => (),
|
||||
Err(err) => panic!("Unable to encode Tx ({:?})", err),
|
||||
};
|
||||
mtxp.transaction = Decode::decode(&mut Decoder::new(&tx_buf.as_slice()), &mut ()).unwrap();
|
||||
mtxp.transaction = Decode::decode(&mut Decoder::new(tx_buf.as_slice()), &mut ()).unwrap();
|
||||
let metx: MultiEraTx = MultiEraTx::from_byron(&mtxp);
|
||||
let utxos: UTxOs = mk_utxo_for_byron_tx(
|
||||
&mtxp.transaction,
|
||||
|
|
@ -165,7 +165,7 @@ mod byron_tests {
|
|||
network_id: 1,
|
||||
};
|
||||
match validate(&metx, &utxos, &env) {
|
||||
Ok(()) => assert!(false, "Outputs set should not be empty"),
|
||||
Ok(()) => panic!("Outputs set should not be empty"),
|
||||
Err(err) => match err {
|
||||
Byron(ByronError::TxOutsEmpty) => (),
|
||||
_ => panic!("Unexpected error ({:?})", err),
|
||||
|
|
@ -193,7 +193,7 @@ mod byron_tests {
|
|||
network_id: 1,
|
||||
};
|
||||
match validate(&metx, &utxos, &env) {
|
||||
Ok(()) => assert!(false, "All inputs must be within the UTxO set"),
|
||||
Ok(()) => panic!("All inputs must be within the UTxO set"),
|
||||
Err(err) => match err {
|
||||
Byron(ByronError::InputNotInUTxO) => (),
|
||||
_ => panic!("Unexpected error ({:?})", err),
|
||||
|
|
@ -220,7 +220,7 @@ mod byron_tests {
|
|||
Ok(_) => (),
|
||||
Err(err) => panic!("Unable to encode Tx ({:?})", err),
|
||||
};
|
||||
mtxp.transaction = Decode::decode(&mut Decoder::new(&tx_buf.as_slice()), &mut ()).unwrap();
|
||||
mtxp.transaction = Decode::decode(&mut Decoder::new(tx_buf.as_slice()), &mut ()).unwrap();
|
||||
let metx: MultiEraTx = MultiEraTx::from_byron(&mtxp);
|
||||
let utxos: UTxOs = mk_utxo_for_byron_tx(
|
||||
&mtxp.transaction,
|
||||
|
|
@ -242,7 +242,7 @@ mod byron_tests {
|
|||
network_id: 1,
|
||||
};
|
||||
match validate(&metx, &utxos, &env) {
|
||||
Ok(()) => assert!(false, "All outputs must contain lovelace"),
|
||||
Ok(()) => panic!("All outputs must contain lovelace"),
|
||||
Err(err) => match err {
|
||||
Byron(ByronError::OutputWithoutLovelace) => (),
|
||||
_ => panic!("Unexpected error ({:?})", err),
|
||||
|
|
@ -276,7 +276,7 @@ mod byron_tests {
|
|||
network_id: 1,
|
||||
};
|
||||
match validate(&metx, &utxos, &env) {
|
||||
Ok(()) => assert!(false, "Fees should not be below minimum"),
|
||||
Ok(()) => panic!("Fees should not be below minimum"),
|
||||
Err(err) => match err {
|
||||
Byron(ByronError::FeesBelowMin) => (),
|
||||
_ => panic!("Unexpected error ({:?})", err),
|
||||
|
|
@ -310,7 +310,7 @@ mod byron_tests {
|
|||
network_id: 1,
|
||||
};
|
||||
match validate(&metx, &utxos, &env) {
|
||||
Ok(()) => assert!(false, "Transaction size cannot exceed protocol limit"),
|
||||
Ok(()) => panic!("Transaction size cannot exceed protocol limit"),
|
||||
Err(err) => match err {
|
||||
Byron(ByronError::MaxTxSizeExceeded) => (),
|
||||
_ => panic!("Unexpected error ({:?})", err),
|
||||
|
|
@ -330,7 +330,7 @@ mod byron_tests {
|
|||
Ok(_) => (),
|
||||
Err(err) => panic!("Unable to encode Tx ({:?})", err),
|
||||
};
|
||||
mtxp.witness = Decode::decode(&mut Decoder::new(&tx_buf.as_slice()), &mut ()).unwrap();
|
||||
mtxp.witness = Decode::decode(&mut Decoder::new(tx_buf.as_slice()), &mut ()).unwrap();
|
||||
let metx: MultiEraTx = MultiEraTx::from_byron(&mtxp);
|
||||
let utxos: UTxOs = mk_utxo_for_byron_tx(
|
||||
&mtxp.transaction,
|
||||
|
|
@ -352,7 +352,7 @@ mod byron_tests {
|
|||
network_id: 1,
|
||||
};
|
||||
match validate(&metx, &utxos, &env) {
|
||||
Ok(()) => assert!(false, "All inputs must have a witness signature"),
|
||||
Ok(()) => panic!("All inputs must have a witness signature"),
|
||||
Err(err) => match err {
|
||||
Byron(ByronError::MissingWitness) => (),
|
||||
_ => panic!("Unexpected error ({:?})", err),
|
||||
|
|
@ -381,7 +381,7 @@ mod byron_tests {
|
|||
Ok(_) => (),
|
||||
Err(err) => panic!("Unable to encode Tx ({:?})", err),
|
||||
};
|
||||
mtxp.witness = Decode::decode(&mut Decoder::new(&tx_buf.as_slice()), &mut ()).unwrap();
|
||||
mtxp.witness = Decode::decode(&mut Decoder::new(tx_buf.as_slice()), &mut ()).unwrap();
|
||||
let metx: MultiEraTx = MultiEraTx::from_byron(&mtxp);
|
||||
let utxos: UTxOs = mk_utxo_for_byron_tx(
|
||||
&mtxp.transaction,
|
||||
|
|
@ -403,7 +403,7 @@ mod byron_tests {
|
|||
network_id: 1,
|
||||
};
|
||||
match validate(&metx, &utxos, &env) {
|
||||
Ok(()) => assert!(false, "Witness signature should verify the transaction"),
|
||||
Ok(()) => panic!("Witness signature should verify the transaction"),
|
||||
Err(err) => match err {
|
||||
Byron(ByronError::WrongSignature) => (),
|
||||
_ => panic!("Unexpected error ({:?})", err),
|
||||
|
|
|
|||
|
|
@ -14,12 +14,12 @@ pub fn cbor_to_bytes(input: &str) -> Vec<u8> {
|
|||
hex::decode(input).unwrap()
|
||||
}
|
||||
|
||||
pub fn minted_tx_from_cbor<'a>(tx_cbor: &'a Vec<u8>) -> MintedTx<'a> {
|
||||
pallas_codec::minicbor::decode::<MintedTx>(&tx_cbor[..]).unwrap()
|
||||
pub fn minted_tx_from_cbor(tx_cbor: &[u8]) -> MintedTx<'_> {
|
||||
pallas_codec::minicbor::decode::<MintedTx>(tx_cbor).unwrap()
|
||||
}
|
||||
|
||||
pub fn minted_tx_payload_from_cbor<'a>(tx_cbor: &'a Vec<u8>) -> MintedTxPayload<'a> {
|
||||
pallas_codec::minicbor::decode::<MintedTxPayload>(&tx_cbor[..]).unwrap()
|
||||
pub fn minted_tx_payload_from_cbor(tx_cbor: &[u8]) -> MintedTxPayload<'_> {
|
||||
pallas_codec::minicbor::decode::<MintedTxPayload>(tx_cbor).unwrap()
|
||||
}
|
||||
|
||||
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
|
|||
};
|
||||
let tx_out: TxOut = TxOut {
|
||||
address: input_tx_out_addr,
|
||||
amount: amount.clone(),
|
||||
amount: *amount,
|
||||
};
|
||||
let multi_era_in: MultiEraInput = MultiEraInput::Byron(Box::new(Cow::Owned(tx_in)));
|
||||
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>(
|
|||
let tx_out: TransactionOutput = TransactionOutput {
|
||||
address: address_bytes,
|
||||
amount: amount.clone(),
|
||||
datum_hash: datum_hash.clone(),
|
||||
datum_hash: *datum_hash,
|
||||
};
|
||||
let multi_era_in: MultiEraInput =
|
||||
MultiEraInput::AlonzoCompatible(Box::new(Cow::Owned(tx_in)));
|
||||
|
|
@ -67,9 +67,9 @@ pub fn mk_utxo_for_alonzo_compatible_tx<'a>(
|
|||
utxos
|
||||
}
|
||||
|
||||
pub fn add_collateral<'a>(
|
||||
pub fn add_collateral(
|
||||
tx_body: &TransactionBody,
|
||||
utxos: &mut UTxOs<'a>,
|
||||
utxos: &mut UTxOs<'_>,
|
||||
collateral_info: &[(String, Value, Option<Hash<32>>)],
|
||||
) {
|
||||
match &tx_body.collateral {
|
||||
|
|
@ -82,7 +82,7 @@ pub fn add_collateral<'a>(
|
|||
let tx_out: TransactionOutput = TransactionOutput {
|
||||
address: address_bytes,
|
||||
amount: amount.clone(),
|
||||
datum_hash: datum_hash.clone(),
|
||||
datum_hash: *datum_hash,
|
||||
};
|
||||
let multi_era_in: MultiEraInput =
|
||||
MultiEraInput::AlonzoCompatible(Box::new(Cow::Owned(tx_in.clone())));
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ mod shelley_ma_tests {
|
|||
};
|
||||
match validate(&metx, &utxos, &env) {
|
||||
Ok(()) => (),
|
||||
Err(err) => assert!(false, "Unexpected error ({:?})", err),
|
||||
Err(err) => panic!("Unexpected error ({:?})", err),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -89,7 +89,7 @@ mod shelley_ma_tests {
|
|||
};
|
||||
match validate(&metx, &utxos, &env) {
|
||||
Ok(()) => (),
|
||||
Err(err) => assert!(false, "Unexpected error ({:?})", err),
|
||||
Err(err) => panic!("Unexpected error ({:?})", err),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -123,7 +123,7 @@ mod shelley_ma_tests {
|
|||
};
|
||||
match validate(&metx, &utxos, &env) {
|
||||
Ok(()) => (),
|
||||
Err(err) => assert!(false, "Unexpected error ({:?})", err),
|
||||
Err(err) => panic!("Unexpected error ({:?})", err),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -157,7 +157,7 @@ mod shelley_ma_tests {
|
|||
};
|
||||
match validate(&metx, &utxos, &env) {
|
||||
Ok(()) => (),
|
||||
Err(err) => assert!(false, "Unexpected error ({:?})", err),
|
||||
Err(err) => panic!("Unexpected error ({:?})", err),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -180,10 +180,10 @@ mod shelley_ma_tests {
|
|||
let mut tx_buf: Vec<u8> = Vec::new();
|
||||
match encode(tx_body, &mut tx_buf) {
|
||||
Ok(_) => (),
|
||||
Err(err) => assert!(false, "Unable to encode Tx ({:?})", err),
|
||||
Err(err) => panic!("Unable to encode Tx ({:?})", err),
|
||||
};
|
||||
mtx.transaction_body =
|
||||
Decode::decode(&mut Decoder::new(&tx_buf.as_slice()), &mut ()).unwrap();
|
||||
Decode::decode(&mut Decoder::new(tx_buf.as_slice()), &mut ()).unwrap();
|
||||
let metx: MultiEraTx = MultiEraTx::from_alonzo_compatible(&mtx, Era::Shelley);
|
||||
let env: Environment = Environment {
|
||||
prot_params: MultiEraProtParams::Shelley(ShelleyProtParams {
|
||||
|
|
@ -199,10 +199,10 @@ mod shelley_ma_tests {
|
|||
network_id: 1,
|
||||
};
|
||||
match validate(&metx, &utxos, &env) {
|
||||
Ok(()) => assert!(false, "Inputs set should not be empty"),
|
||||
Ok(()) => panic!("Inputs set should not be empty"),
|
||||
Err(err) => match err {
|
||||
ShelleyMA(ShelleyMAError::TxInsEmpty) => (),
|
||||
_ => assert!(false, "Unexpected error ({:?})", err),
|
||||
_ => panic!("Unexpected error ({:?})", err),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
@ -228,10 +228,10 @@ mod shelley_ma_tests {
|
|||
network_id: 1,
|
||||
};
|
||||
match validate(&metx, &utxos, &env) {
|
||||
Ok(()) => assert!(false, "All inputs must be within the UTxO set"),
|
||||
Ok(()) => panic!("All inputs must be within the UTxO set"),
|
||||
Err(err) => match err {
|
||||
ShelleyMA(ShelleyMAError::InputNotInUTxO) => (),
|
||||
_ => assert!(false, "Unexpected error ({:?})", err),
|
||||
_ => panic!("Unexpected error ({:?})", err),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
@ -254,10 +254,10 @@ mod shelley_ma_tests {
|
|||
let mut tx_buf: Vec<u8> = Vec::new();
|
||||
match encode(tx_body, &mut tx_buf) {
|
||||
Ok(_) => (),
|
||||
Err(err) => assert!(false, "Unable to encode Tx ({:?})", err),
|
||||
Err(err) => panic!("Unable to encode Tx ({:?})", err),
|
||||
};
|
||||
mtx.transaction_body =
|
||||
Decode::decode(&mut Decoder::new(&tx_buf.as_slice()), &mut ()).unwrap();
|
||||
Decode::decode(&mut Decoder::new(tx_buf.as_slice()), &mut ()).unwrap();
|
||||
let metx: MultiEraTx = MultiEraTx::from_alonzo_compatible(&mtx, Era::Shelley);
|
||||
let env: Environment = Environment {
|
||||
prot_params: MultiEraProtParams::Shelley(ShelleyProtParams {
|
||||
|
|
@ -273,10 +273,10 @@ mod shelley_ma_tests {
|
|||
network_id: 1,
|
||||
};
|
||||
match validate(&metx, &utxos, &env) {
|
||||
Ok(()) => assert!(false, "TTL must always be present in Shelley transactions"),
|
||||
Ok(()) => panic!("TTL must always be present in Shelley transactions"),
|
||||
Err(err) => match err {
|
||||
ShelleyMA(ShelleyMAError::AlonzoCompNotShelley) => (),
|
||||
_ => assert!(false, "Unexpected error ({:?})", err),
|
||||
_ => panic!("Unexpected error ({:?})", err),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
@ -309,10 +309,10 @@ mod shelley_ma_tests {
|
|||
network_id: 1,
|
||||
};
|
||||
match validate(&metx, &utxos, &env) {
|
||||
Ok(()) => assert!(false, "TTL cannot be exceeded"),
|
||||
Ok(()) => panic!("TTL cannot be exceeded"),
|
||||
Err(err) => match err {
|
||||
ShelleyMA(ShelleyMAError::TTLExceeded) => (),
|
||||
_ => assert!(false, "Unexpected error ({:?})", err),
|
||||
_ => panic!("Unexpected error ({:?})", err),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
@ -345,10 +345,10 @@ mod shelley_ma_tests {
|
|||
network_id: 1,
|
||||
};
|
||||
match validate(&metx, &utxos, &env) {
|
||||
Ok(()) => assert!(false, "Tx size exceeds max limit"),
|
||||
Ok(()) => panic!("Tx size exceeds max limit"),
|
||||
Err(err) => match err {
|
||||
ShelleyMA(ShelleyMAError::MaxTxSizeExceeded) => (),
|
||||
_ => assert!(false, "Unexpected error ({:?})", err),
|
||||
_ => panic!("Unexpected error ({:?})", err),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
@ -382,10 +382,10 @@ mod shelley_ma_tests {
|
|||
network_id: 1,
|
||||
};
|
||||
match validate(&metx, &utxos, &env) {
|
||||
Ok(()) => assert!(false, "Output amount must be above min lovelace value"),
|
||||
Ok(()) => panic!("Output amount must be above min lovelace value"),
|
||||
Err(err) => match err {
|
||||
ShelleyMA(ShelleyMAError::MinLovelaceUnreached) => (),
|
||||
_ => assert!(false, "Unexpected error ({:?})", err),
|
||||
_ => panic!("Unexpected error ({:?})", err),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
@ -397,14 +397,14 @@ mod shelley_ma_tests {
|
|||
let cbor_bytes: Vec<u8> = cbor_to_bytes(include_str!("../../test_data/shelley1.tx"));
|
||||
let mut mtx: MintedTx = minted_tx_from_cbor(&cbor_bytes);
|
||||
let mut tx_body: TransactionBody = mtx.transaction_body.unwrap().clone();
|
||||
tx_body.fee = tx_body.fee - 1;
|
||||
tx_body.fee -= 1;
|
||||
let mut tx_buf: Vec<u8> = Vec::new();
|
||||
match encode(tx_body, &mut tx_buf) {
|
||||
Ok(_) => (),
|
||||
Err(err) => assert!(false, "Unable to encode Tx ({:?})", err),
|
||||
Err(err) => panic!("Unable to encode Tx ({:?})", err),
|
||||
};
|
||||
mtx.transaction_body =
|
||||
Decode::decode(&mut Decoder::new(&tx_buf.as_slice()), &mut ()).unwrap();
|
||||
Decode::decode(&mut Decoder::new(tx_buf.as_slice()), &mut ()).unwrap();
|
||||
let metx: MultiEraTx = MultiEraTx::from_alonzo_compatible(&mtx, Era::Shelley);
|
||||
let utxos: UTxOs = mk_utxo_for_alonzo_compatible_tx(
|
||||
&mtx.transaction_body,
|
||||
|
|
@ -428,10 +428,10 @@ mod shelley_ma_tests {
|
|||
network_id: 1,
|
||||
};
|
||||
match validate(&metx, &utxos, &env) {
|
||||
Ok(()) => assert!(false, "Preservation of value property doesn't hold"),
|
||||
Ok(()) => panic!("Preservation of value property doesn't hold"),
|
||||
Err(err) => match err {
|
||||
ShelleyMA(ShelleyMAError::PreservationOfValue) => (),
|
||||
_ => assert!(false, "Unexpected error ({:?})", err),
|
||||
_ => panic!("Unexpected error ({:?})", err),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
@ -464,10 +464,10 @@ mod shelley_ma_tests {
|
|||
network_id: 1,
|
||||
};
|
||||
match validate(&metx, &utxos, &env) {
|
||||
Ok(()) => assert!(false, "Fee should not be below minimum"),
|
||||
Ok(()) => panic!("Fee should not be below minimum"),
|
||||
Err(err) => match err {
|
||||
ShelleyMA(ShelleyMAError::FeesBelowMin) => (),
|
||||
_ => assert!(false, "Unexpected error ({:?})", err),
|
||||
_ => panic!("Unexpected error ({:?})", err),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
@ -481,7 +481,7 @@ mod shelley_ma_tests {
|
|||
// Modify the first output address.
|
||||
let mut tx_body: TransactionBody = mtx.transaction_body.unwrap().clone();
|
||||
let (first_output, rest): (&TransactionOutput, &[TransactionOutput]) =
|
||||
(&tx_body.outputs).split_first().unwrap();
|
||||
(tx_body.outputs).split_first().unwrap();
|
||||
let addr: ShelleyAddress =
|
||||
match Address::from_bytes(&Vec::<u8>::from(first_output.address.clone())) {
|
||||
Ok(Address::Shelley(sa)) => sa,
|
||||
|
|
@ -504,10 +504,10 @@ mod shelley_ma_tests {
|
|||
let mut tx_buf: Vec<u8> = Vec::new();
|
||||
match encode(tx_body, &mut tx_buf) {
|
||||
Ok(_) => (),
|
||||
Err(err) => assert!(false, "Unable to encode Tx ({:?})", err),
|
||||
Err(err) => panic!("Unable to encode Tx ({:?})", err),
|
||||
};
|
||||
mtx.transaction_body =
|
||||
Decode::decode(&mut Decoder::new(&tx_buf.as_slice()), &mut ()).unwrap();
|
||||
Decode::decode(&mut Decoder::new(tx_buf.as_slice()), &mut ()).unwrap();
|
||||
let metx: MultiEraTx = MultiEraTx::from_alonzo_compatible(&mtx, Era::Shelley);
|
||||
let env: Environment = Environment {
|
||||
prot_params: MultiEraProtParams::Shelley(ShelleyProtParams {
|
||||
|
|
@ -531,10 +531,10 @@ mod shelley_ma_tests {
|
|||
)],
|
||||
);
|
||||
match validate(&metx, &utxos, &env) {
|
||||
Ok(()) => assert!(false, "Output with wrong network ID should be rejected"),
|
||||
Ok(()) => panic!("Output with wrong network ID should be rejected"),
|
||||
Err(err) => match err {
|
||||
ShelleyMA(ShelleyMAError::WrongNetworkID) => (),
|
||||
_ => assert!(false, "Unexpected error ({:?})", err),
|
||||
_ => panic!("Unexpected error ({:?})", err),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
@ -570,10 +570,10 @@ mod shelley_ma_tests {
|
|||
network_id: 1,
|
||||
};
|
||||
match validate(&metx, &utxos, &env) {
|
||||
Ok(()) => assert!(false, "Output with wrong network ID should be rejected"),
|
||||
Ok(()) => panic!("Output with wrong network ID should be rejected"),
|
||||
Err(err) => match err {
|
||||
ShelleyMA(ShelleyMAError::MetadataHash) => (),
|
||||
_ => assert!(false, "Unexpected error ({:?})", err),
|
||||
_ => panic!("Unexpected error ({:?})", err),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
@ -591,10 +591,10 @@ mod shelley_ma_tests {
|
|||
let mut tx_buf: Vec<u8> = Vec::new();
|
||||
match encode(tx_wits, &mut tx_buf) {
|
||||
Ok(_) => (),
|
||||
Err(err) => assert!(false, "Unable to encode Tx ({:?})", err),
|
||||
Err(err) => panic!("Unable to encode Tx ({:?})", err),
|
||||
};
|
||||
mtx.transaction_witness_set =
|
||||
Decode::decode(&mut Decoder::new(&tx_buf.as_slice()), &mut ()).unwrap();
|
||||
Decode::decode(&mut Decoder::new(tx_buf.as_slice()), &mut ()).unwrap();
|
||||
let metx: MultiEraTx = MultiEraTx::from_alonzo_compatible(&mtx, Era::Shelley);
|
||||
let env: Environment = Environment {
|
||||
prot_params: MultiEraProtParams::Shelley(ShelleyProtParams {
|
||||
|
|
@ -618,10 +618,10 @@ mod shelley_ma_tests {
|
|||
)],
|
||||
);
|
||||
match validate(&metx, &utxos, &env) {
|
||||
Ok(()) => assert!(false, "Missing verification key witness"),
|
||||
Ok(()) => panic!("Missing verification key witness"),
|
||||
Err(err) => match err {
|
||||
ShelleyMA(ShelleyMAError::MissingVKWitness) => (),
|
||||
_ => assert!(false, "Unexpected error ({:?})", err),
|
||||
_ => panic!("Unexpected error ({:?})", err),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
@ -644,10 +644,10 @@ mod shelley_ma_tests {
|
|||
let mut tx_buf: Vec<u8> = Vec::new();
|
||||
match encode(tx_wits, &mut tx_buf) {
|
||||
Ok(_) => (),
|
||||
Err(err) => assert!(false, "Unable to encode Tx ({:?})", err),
|
||||
Err(err) => panic!("Unable to encode Tx ({:?})", err),
|
||||
};
|
||||
mtx.transaction_witness_set =
|
||||
Decode::decode(&mut Decoder::new(&tx_buf.as_slice()), &mut ()).unwrap();
|
||||
Decode::decode(&mut Decoder::new(tx_buf.as_slice()), &mut ()).unwrap();
|
||||
let metx: MultiEraTx = MultiEraTx::from_alonzo_compatible(&mtx, Era::Shelley);
|
||||
let env: Environment = Environment {
|
||||
prot_params: MultiEraProtParams::Shelley(ShelleyProtParams {
|
||||
|
|
@ -671,10 +671,10 @@ mod shelley_ma_tests {
|
|||
)],
|
||||
);
|
||||
match validate(&metx, &utxos, &env) {
|
||||
Ok(()) => assert!(false, "Missing verification key witness"),
|
||||
Ok(()) => panic!("Missing verification key witness"),
|
||||
Err(err) => match err {
|
||||
ShelleyMA(ShelleyMAError::WrongSignature) => (),
|
||||
_ => assert!(false, "Unexpected error ({:?})", err),
|
||||
_ => panic!("Unexpected error ({:?})", err),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
@ -692,10 +692,10 @@ mod shelley_ma_tests {
|
|||
let mut tx_buf: Vec<u8> = Vec::new();
|
||||
match encode(tx_wits, &mut tx_buf) {
|
||||
Ok(_) => (),
|
||||
Err(err) => assert!(false, "Unable to encode Tx ({:?})", err),
|
||||
Err(err) => panic!("Unable to encode Tx ({:?})", err),
|
||||
};
|
||||
mtx.transaction_witness_set =
|
||||
Decode::decode(&mut Decoder::new(&tx_buf.as_slice()), &mut ()).unwrap();
|
||||
Decode::decode(&mut Decoder::new(tx_buf.as_slice()), &mut ()).unwrap();
|
||||
let metx: MultiEraTx = MultiEraTx::from_alonzo_compatible(&mtx, Era::Shelley);
|
||||
let env: Environment = Environment {
|
||||
prot_params: MultiEraProtParams::Shelley(ShelleyProtParams {
|
||||
|
|
@ -719,10 +719,10 @@ mod shelley_ma_tests {
|
|||
)],
|
||||
);
|
||||
match validate(&metx, &utxos, &env) {
|
||||
Ok(()) => assert!(false, "Missing native script witness"),
|
||||
Ok(()) => panic!("Missing native script witness"),
|
||||
Err(err) => match err {
|
||||
ShelleyMA(ShelleyMAError::MissingScriptWitness) => (),
|
||||
_ => assert!(false, "Unexpected error ({:?})", err),
|
||||
_ => panic!("Unexpected error ({:?})", err),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue