diff --git a/.changelog/unreleased/improvements/3507-decode-asset-types.md b/.changelog/unreleased/improvements/3507-decode-asset-types.md new file mode 100644 index 0000000000..a4ff5882fc --- /dev/null +++ b/.changelog/unreleased/improvements/3507-decode-asset-types.md @@ -0,0 +1,2 @@ +- Decode asset types to addresses when generating test vectors if possible. + ([\#3507](https://github.com/anoma/namada/pull/3507)) diff --git a/crates/sdk/src/signing.rs b/crates/sdk/src/signing.rs index 803d4578c4..5300cf34c7 100644 --- a/crates/sdk/src/signing.rs +++ b/crates/sdk/src/signing.rs @@ -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, @@ -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), @@ -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)); } @@ -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), @@ -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)); @@ -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) @@ -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 @@ -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 @@ -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 : {}", @@ -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!( @@ -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)); } diff --git a/crates/tx/src/data/pgf.rs b/crates/tx/src/data/pgf.rs index 8b2c9f3944..2da23db625 100644 --- a/crates/tx/src/data/pgf.rs +++ b/crates/tx/src/data/pgf.rs @@ -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, diff --git a/examples/generate_txs.rs b/examples/generate_txs.rs index daa91961f2..51727d6361 100644 --- a/examples/generate_txs.rs +++ b/examples/generate_txs.rs @@ -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![];