Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mpapierski committed Nov 19, 2024
1 parent c196452 commit e48014c
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 25 deletions.
4 changes: 2 additions & 2 deletions lib/cli/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -927,7 +927,7 @@ pub(super) fn pricing_mode(
error,
}
})?;
Ok(PricingMode::Classic {
Ok(PricingMode::PaymentLimited {
payment_amount,
gas_price_tolerance,
standard_payment,
Expand Down Expand Up @@ -1894,7 +1894,7 @@ mod tests {
.unwrap();
assert_eq!(
parsed,
PricingMode::Classic {
PricingMode::PaymentLimited {
payment_amount: 10,
gas_price_tolerance: 10,
standard_payment: true,
Expand Down
76 changes: 58 additions & 18 deletions lib/cli/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ mod transaction {
use super::*;
use crate::Error::TransactionBuild;
use casper_types::{
bytesrepr::Bytes, PackageAddr, RuntimeArgs, TransactionEntryPoint,
bytesrepr::Bytes, PackageAddr, TransactionArgs, TransactionEntryPoint,
TransactionInvocationTarget, TransactionRuntime, TransactionTarget,
TransactionV1BuilderError, TransferTarget,
};
Expand Down Expand Up @@ -549,7 +549,9 @@ mod transaction {
transaction
.as_ref()
.unwrap()
.deserialize_field::<RuntimeArgs>(ARGS_MAP_KEY)
.deserialize_field::<TransactionArgs>(ARGS_MAP_KEY)
.unwrap()
.into_named()
.unwrap()
.get("public_key")
.unwrap(),
Expand All @@ -558,15 +560,19 @@ mod transaction {
assert!(transaction
.as_ref()
.unwrap()
.deserialize_field::<RuntimeArgs>(ARGS_MAP_KEY)
.deserialize_field::<TransactionArgs>(ARGS_MAP_KEY)
.unwrap()
.into_named()
.unwrap()
.get("delegation_rate")
.is_some());
assert_eq!(
transaction
.as_ref()
.unwrap()
.deserialize_field::<RuntimeArgs>(ARGS_MAP_KEY)
.deserialize_field::<TransactionArgs>(ARGS_MAP_KEY)
.unwrap()
.into_named()
.unwrap()
.get("amount")
.unwrap(),
Expand Down Expand Up @@ -618,7 +624,9 @@ mod transaction {
transaction
.as_ref()
.unwrap()
.deserialize_field::<RuntimeArgs>(ARGS_MAP_KEY)
.deserialize_field::<TransactionArgs>(ARGS_MAP_KEY)
.unwrap()
.into_named()
.unwrap()
.get("amount")
.unwrap(),
Expand All @@ -628,7 +636,9 @@ mod transaction {
transaction
.as_ref()
.unwrap()
.deserialize_field::<RuntimeArgs>(ARGS_MAP_KEY)
.deserialize_field::<TransactionArgs>(ARGS_MAP_KEY)
.unwrap()
.into_named()
.unwrap()
.get("delegator")
.unwrap(),
Expand All @@ -638,7 +648,9 @@ mod transaction {
transaction
.as_ref()
.unwrap()
.deserialize_field::<RuntimeArgs>(ARGS_MAP_KEY)
.deserialize_field::<TransactionArgs>(ARGS_MAP_KEY)
.unwrap()
.into_named()
.unwrap()
.get("validator")
.unwrap(),
Expand Down Expand Up @@ -685,7 +697,9 @@ mod transaction {
transaction
.as_ref()
.unwrap()
.deserialize_field::<RuntimeArgs>(ARGS_MAP_KEY)
.deserialize_field::<TransactionArgs>(ARGS_MAP_KEY)
.unwrap()
.into_named()
.unwrap()
.get("amount")
.unwrap(),
Expand All @@ -695,7 +709,9 @@ mod transaction {
transaction
.as_ref()
.unwrap()
.deserialize_field::<RuntimeArgs>(ARGS_MAP_KEY)
.deserialize_field::<TransactionArgs>(ARGS_MAP_KEY)
.unwrap()
.into_named()
.unwrap()
.get("public_key")
.unwrap(),
Expand Down Expand Up @@ -748,7 +764,9 @@ mod transaction {
transaction
.as_ref()
.unwrap()
.deserialize_field::<RuntimeArgs>(ARGS_MAP_KEY)
.deserialize_field::<TransactionArgs>(ARGS_MAP_KEY)
.unwrap()
.into_named()
.unwrap()
.get("amount")
.unwrap(),
Expand All @@ -758,7 +776,9 @@ mod transaction {
transaction
.as_ref()
.unwrap()
.deserialize_field::<RuntimeArgs>(ARGS_MAP_KEY)
.deserialize_field::<TransactionArgs>(ARGS_MAP_KEY)
.unwrap()
.into_named()
.unwrap()
.get("delegator")
.unwrap(),
Expand All @@ -768,7 +788,9 @@ mod transaction {
transaction
.as_ref()
.unwrap()
.deserialize_field::<RuntimeArgs>(ARGS_MAP_KEY)
.deserialize_field::<TransactionArgs>(ARGS_MAP_KEY)
.unwrap()
.into_named()
.unwrap()
.get("validator")
.unwrap(),
Expand Down Expand Up @@ -823,7 +845,9 @@ mod transaction {
transaction
.as_ref()
.unwrap()
.deserialize_field::<RuntimeArgs>(ARGS_MAP_KEY)
.deserialize_field::<TransactionArgs>(ARGS_MAP_KEY)
.unwrap()
.into_named()
.unwrap()
.get("amount")
.unwrap(),
Expand All @@ -833,7 +857,9 @@ mod transaction {
transaction
.as_ref()
.unwrap()
.deserialize_field::<RuntimeArgs>(ARGS_MAP_KEY)
.deserialize_field::<TransactionArgs>(ARGS_MAP_KEY)
.unwrap()
.into_named()
.unwrap()
.get("delegator")
.unwrap(),
Expand All @@ -843,7 +869,9 @@ mod transaction {
transaction
.as_ref()
.unwrap()
.deserialize_field::<RuntimeArgs>(ARGS_MAP_KEY)
.deserialize_field::<TransactionArgs>(ARGS_MAP_KEY)
.unwrap()
.into_named()
.unwrap()
.get("validator")
.unwrap(),
Expand All @@ -853,7 +881,9 @@ mod transaction {
transaction
.as_ref()
.unwrap()
.deserialize_field::<RuntimeArgs>(ARGS_MAP_KEY)
.deserialize_field::<TransactionArgs>(ARGS_MAP_KEY)
.unwrap()
.into_named()
.unwrap()
.get("new_validator")
.unwrap(),
Expand All @@ -869,6 +899,7 @@ mod transaction {
let target = &TransactionTarget::Stored {
id: TransactionInvocationTarget::ByHash(entity_hash),
runtime: TransactionRuntime::VmCasperV1,
transferred_value: 0,
};

let entry_point_ref = &TransactionEntryPoint::Custom(entry_point);
Expand Down Expand Up @@ -925,6 +956,7 @@ mod transaction {
let target = &TransactionTarget::Stored {
id: TransactionInvocationTarget::ByName(alias),
runtime: TransactionRuntime::VmCasperV1,
transferred_value: 0,
};
let transaction_string_params = TransactionStrParams {
secret_key: "",
Expand Down Expand Up @@ -982,6 +1014,7 @@ mod transaction {
version: maybe_entity_version,
},
runtime: TransactionRuntime::VmCasperV1,
transferred_value: 0,
};
let transaction_string_params = TransactionStrParams {
secret_key: "",
Expand Down Expand Up @@ -1037,6 +1070,7 @@ mod transaction {
version: maybe_entity_version,
},
runtime: TransactionRuntime::VmCasperV1,
transferred_value: 0,
};
let transaction_string_params = TransactionStrParams {
secret_key: "",
Expand Down Expand Up @@ -1089,6 +1123,8 @@ mod transaction {
is_install_upgrade,
runtime: TransactionRuntime::VmCasperV1,
module_bytes: transaction_bytes.clone(),
transferred_value: 0,
seed: None,
};
let transaction_string_params = TransactionStrParams {
secret_key: "",
Expand Down Expand Up @@ -1189,7 +1225,9 @@ mod transaction {
transaction
.as_ref()
.unwrap()
.deserialize_field::<RuntimeArgs>(ARGS_MAP_KEY)
.deserialize_field::<TransactionArgs>(ARGS_MAP_KEY)
.unwrap()
.into_named()
.unwrap()
.get("source")
.unwrap(),
Expand All @@ -1199,7 +1237,9 @@ mod transaction {
transaction
.as_ref()
.unwrap()
.deserialize_field::<RuntimeArgs>(ARGS_MAP_KEY)
.deserialize_field::<TransactionArgs>(ARGS_MAP_KEY)
.unwrap()
.into_named()
.unwrap()
.get("target")
.unwrap(),
Expand Down
26 changes: 21 additions & 5 deletions lib/cli/transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ use crate::{
SuccessResponse,
};
use casper_types::{
Digest, InitiatorAddr, SecretKey, Transaction, TransactionV1, TransactionV1Builder,
Digest, InitiatorAddr, SecretKey, Transaction, TransactionRuntime, TransactionV1,
TransactionV1Builder,
};

pub fn create_transaction(
Expand Down Expand Up @@ -265,8 +266,12 @@ pub fn make_transaction_builder(
entity_hash,
entry_point,
} => {
let transaction_builder =
TransactionV1Builder::new_targeting_invocable_entity(entity_hash, entry_point);
let transaction_builder = TransactionV1Builder::new_targeting_invocable_entity(
entity_hash,
entry_point,
TransactionRuntime::VmCasperV1,
0,
);
Ok(transaction_builder)
}
TransactionBuilderParams::InvocableEntityAlias {
Expand All @@ -277,6 +282,8 @@ pub fn make_transaction_builder(
TransactionV1Builder::new_targeting_invocable_entity_via_alias(
entity_alias,
entry_point,
TransactionRuntime::VmCasperV1,
0,
);
Ok(transaction_builder)
}
Expand All @@ -289,6 +296,8 @@ pub fn make_transaction_builder(
package_hash,
maybe_entity_version,
entry_point,
TransactionRuntime::VmCasperV1,
0,
);
Ok(transaction_builder)
}
Expand All @@ -301,15 +310,22 @@ pub fn make_transaction_builder(
package_alias,
maybe_entity_version,
entry_point,
TransactionRuntime::VmCasperV1,
0,
);
Ok(transaction_builder)
}
TransactionBuilderParams::Session {
is_install_upgrade,
transaction_bytes,
} => {
let transaction_builder =
TransactionV1Builder::new_session(is_install_upgrade, transaction_bytes);
let transaction_builder = TransactionV1Builder::new_session(
is_install_upgrade,
transaction_bytes,
TransactionRuntime::VmCasperV1,
0,
None,
);
Ok(transaction_builder)
}
TransactionBuilderParams::Transfer {
Expand Down

0 comments on commit e48014c

Please sign in to comment.