From 0baaa784551c8f89ad8ba7e1cee01dddbc4fc2bb Mon Sep 17 00:00:00 2001 From: Murisi Tarusenga Date: Wed, 24 Apr 2024 13:19:58 +0200 Subject: [PATCH 1/2] Corrected the printing of test vectors to match serialization order. --- crates/governance/src/storage/proposal.rs | 3 ++- crates/sdk/src/signing.rs | 31 ++--------------------- 2 files changed, 4 insertions(+), 30 deletions(-) diff --git a/crates/governance/src/storage/proposal.rs b/crates/governance/src/storage/proposal.rs index 2ced316360..ccef1eb9ec 100644 --- a/crates/governance/src/storage/proposal.rs +++ b/crates/governance/src/storage/proposal.rs @@ -461,7 +461,7 @@ impl Display for ProposalType { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { ProposalType::Default => write!(f, "Default"), - ProposalType::DefaultWithWasm(_) => write!(f, "DefaultWithWasm"), + ProposalType::DefaultWithWasm(_) => write!(f, "Default with Wasm"), ProposalType::PGFSteward(_) => write!(f, "PGF steward"), ProposalType::PGFPayment(_) => write!(f, "PGF funding"), } @@ -732,6 +732,7 @@ pub mod testing { /// Generate an arbitrary proposal type pub fn arb_proposal_type() -> impl Strategy { prop_oneof![ + Just(ProposalType::Default), arb_hash().prop_map(ProposalType::DefaultWithWasm), collection::btree_set( arb_add_remove(arb_non_internal_address()), diff --git a/crates/sdk/src/signing.rs b/crates/sdk/src/signing.rs index cd01dca1c5..938f53c0fc 100644 --- a/crates/sdk/src/signing.rs +++ b/crates/sdk/src/signing.rs @@ -910,30 +910,6 @@ impl<'a> Display for LedgerProposalVote<'a> { } } -/// A ProposalType wrapper that prints the hash of the contained WASM code if it -/// is present. -struct LedgerProposalType<'a>(&'a ProposalType, &'a Tx); - -impl<'a> Display for LedgerProposalType<'a> { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { - match self.0 { - ProposalType::Default => write!(f, "Default"), - ProposalType::DefaultWithWasm(hash) => { - let extra = self - .1 - .get_section(hash) - .and_then(|x| Section::extra_data_sec(x.as_ref())) - .expect("unable to load vp code") - .code - .hash(); - write!(f, "{}", HEXLOWER.encode(&extra.0)) - } - ProposalType::PGFSteward(_) => write!(f, "PGF Steward"), - ProposalType::PGFPayment(_) => write!(f, "PGF Payment"), - } - } -} - fn proposal_type_to_ledger_vector( proposal_type: &ProposalType, tx: &Tx, @@ -1787,17 +1763,14 @@ pub async fn to_ledger_vector( format!("Type : Update Steward Commission"), format!("Steward : {}", update.steward), ]); - let mut commission = update.commission.iter().collect::>(); - // Print the test vectors in the same order as the serializations - commission.sort_by(|(a, _), (b, _)| a.cmp(b)); - for (address, dec) in &commission { + for (address, dec) in update.commission.iter() { tv.output.push(format!("Validator : {}", address)); tv.output.push(format!("Commission Rate : {}", dec)); } tv.output_expert .push(format!("Steward : {}", update.steward)); - for (address, dec) in &commission { + for (address, dec) in update.commission.iter() { tv.output_expert.push(format!("Validator : {}", address)); tv.output_expert.push(format!("Commission Rate : {}", dec)); } From 2559d34219e136e59b2d03536c816a3e33210eee Mon Sep 17 00:00:00 2001 From: Murisi Tarusenga Date: Wed, 24 Apr 2024 13:59:03 +0200 Subject: [PATCH 2/2] Added changelog entry. --- .changelog/unreleased/improvements/3122-test-vectors-0.33.0.md | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .changelog/unreleased/improvements/3122-test-vectors-0.33.0.md diff --git a/.changelog/unreleased/improvements/3122-test-vectors-0.33.0.md b/.changelog/unreleased/improvements/3122-test-vectors-0.33.0.md new file mode 100644 index 0000000000..bc66726b57 --- /dev/null +++ b/.changelog/unreleased/improvements/3122-test-vectors-0.33.0.md @@ -0,0 +1,2 @@ +- Adjusted hardware wallet test vectors to simplify hardware wallet app + ([\#3122](https://github.com/anoma/namada/pull/3122)) \ No newline at end of file