Skip to content

Commit

Permalink
Merge branch 'murisi/test-vectors-0.33.0' (#3122)
Browse files Browse the repository at this point in the history
* murisi/test-vectors-0.33.0:
  Added changelog entry.
  Corrected the printing of test vectors to match serialization order.
  • Loading branch information
brentstone committed Apr 25, 2024
2 parents a568d29 + 2559d34 commit 9c7e0e8
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 30 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Adjusted hardware wallet test vectors to simplify hardware wallet app
([\#3122](https://github.com/anoma/namada/pull/3122))
3 changes: 2 additions & 1 deletion crates/governance/src/storage/proposal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
}
Expand Down Expand Up @@ -732,6 +732,7 @@ pub mod testing {
/// Generate an arbitrary proposal type
pub fn arb_proposal_type() -> impl Strategy<Value = ProposalType> {
prop_oneof![
Just(ProposalType::Default),
arb_hash().prop_map(ProposalType::DefaultWithWasm),
collection::btree_set(
arb_add_remove(arb_non_internal_address()),
Expand Down
31 changes: 2 additions & 29 deletions crates/sdk/src/signing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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::<Vec<_>>();
// 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));
}
Expand Down

0 comments on commit 9c7e0e8

Please sign in to comment.