Skip to content

Commit

Permalink
Merge pull request #3507 from anoma/murisi/decode-asset-types
Browse files Browse the repository at this point in the history
Murisi/decode asset types
  • Loading branch information
mergify[bot] authored Aug 13, 2024
2 parents 63cba7a + 704af7a commit e2a1331
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 11 deletions.
2 changes: 2 additions & 0 deletions .changelog/unreleased/improvements/3507-decode-asset-types.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Decode asset types to addresses when generating test vectors if possible.
([\#3507](https://github.com/anoma/namada/pull/3507))
39 changes: 30 additions & 9 deletions crates/sdk/src/signing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -586,7 +586,7 @@ async fn make_ledger_amount_asset(
));
} else {
output.extend(vec![
format!("{}Token : {}", prefix, token),
format!("{}Token : {}", prefix, decoded.token),
format!(
"{}Amount : {}",
prefix,
Expand Down Expand Up @@ -1020,9 +1020,10 @@ pub async fn to_ledger_vector(
Error::from(EncodingError::Conversion(err.to_string()))
})?;

tv.name = "Init_Validator_0".to_string();
tv.name = "Become_Validator_0".to_string();

tv.output.extend(vec!["Type : Init Validator".to_string()]);
tv.output
.extend(vec!["Type : Become Validator".to_string()]);
tv.output.extend(vec![
format!("Address : {}", init_validator.address),
format!("Consensus key : {}", init_validator.consensus_key),
Expand All @@ -1036,6 +1037,9 @@ pub async fn to_ledger_vector(
),
format!("Email : {}", init_validator.email),
]);
if let Some(name) = &init_validator.name {
tv.output.push(format!("Name : {}", name));
}
if let Some(description) = &init_validator.description {
tv.output.push(format!("Description : {}", description));
}
Expand All @@ -1046,6 +1050,9 @@ pub async fn to_ledger_vector(
tv.output
.push(format!("Discord handle : {}", discord_handle));
}
if let Some(avatar) = &init_validator.avatar {
tv.output.push(format!("Avatar : {}", avatar));
}

tv.output_expert.extend(vec![
format!("Address : {}", init_validator.address),
Expand All @@ -1060,6 +1067,9 @@ pub async fn to_ledger_vector(
),
format!("Email : {}", init_validator.email),
]);
if let Some(name) = &init_validator.name {
tv.output_expert.push(format!("Name : {}", name));
}
if let Some(description) = &init_validator.description {
tv.output_expert
.push(format!("Description : {}", description));
Expand All @@ -1071,6 +1081,9 @@ pub async fn to_ledger_vector(
tv.output_expert
.push(format!("Discord handle : {}", discord_handle));
}
if let Some(avatar) = &init_validator.avatar {
tv.output_expert.push(format!("Avatar : {}", avatar));
}
} else if code_sec.tag == Some(TX_INIT_PROPOSAL.to_string()) {
let init_proposal_data = InitProposalData::try_from_slice(
&tx.data(cmt)
Expand Down Expand Up @@ -1302,7 +1315,6 @@ pub async fn to_ledger_vector(
"Receiver : {}",
transfer.message.packet_data.receiver
),
format!("Memo : {}", transfer.message.packet_data.memo),
format!(
"Timeout height : {}",
transfer.message.timeout_height_on_b
Expand All @@ -1329,7 +1341,14 @@ pub async fn to_ledger_vector(
"Receiver : {}",
transfer.message.packet_data.receiver
),
format!("Memo : {}", transfer.message.packet_data.memo),
]);
if !transfer.message.packet_data.memo.to_string().is_empty() {
tv.output_expert.push(format!(
"Memo : {}",
transfer.message.packet_data.memo
));
}
tv.output_expert.extend(vec![
format!(
"Timeout height : {}",
transfer.message.timeout_height_on_b
Expand Down Expand Up @@ -1427,9 +1446,6 @@ pub async fn to_ledger_vector(
transfer.message.packet_data.receiver
),
]);
if let Some(memo) = &transfer.message.packet_data.memo {
tv.output.push(format!("Memo: {}", memo));
}
tv.output.extend(vec![
format!(
"Timeout height : {}",
Expand Down Expand Up @@ -1499,7 +1515,9 @@ pub async fn to_ledger_vector(
),
]);
if let Some(memo) = &transfer.message.packet_data.memo {
tv.output_expert.push(format!("Memo: {}", memo));
if !memo.to_string().is_empty() {
tv.output_expert.push(format!("Memo: {}", memo));
}
}
tv.output_expert.extend(vec![
format!(
Expand Down Expand Up @@ -1693,6 +1711,9 @@ pub async fn to_ledger_vector(
let mut other_items = vec![];
other_items
.push(format!("Validator : {}", metadata_change.validator));
if let Some(name) = metadata_change.name {
other_items.push(format!("Name : {}", name));
}
if let Some(email) = metadata_change.email {
other_items.push(format!("Email : {}", email));
}
Expand Down
2 changes: 1 addition & 1 deletion crates/tx/src/data/pgf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ pub mod tests {
/// Generate an arbitraary steward commission update
pub fn arb_update_steward_commission()(
steward in arb_non_internal_address(),
commission in collection::hash_map(arb_non_internal_address(), arb_dec(), 0..10),
commission in collection::btree_map(arb_non_internal_address(), arb_dec(), 0..10),
) -> UpdateStewardCommission {
UpdateStewardCommission {
steward,
Expand Down
2 changes: 1 addition & 1 deletion examples/generate_txs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use proptest::test_runner::{Reason, TestRunner};

#[tokio::main]
async fn main() -> Result<(), Reason> {
let mut runner = TestRunner::default();
let mut runner = TestRunner::deterministic();
let wallet = FsWalletUtils::new(PathBuf::from("wallet.toml"));
let mut debug_vectors = vec![];
let mut test_vectors = vec![];
Expand Down

0 comments on commit e2a1331

Please sign in to comment.