Skip to content

Commit

Permalink
Assert encoding sizes for body id
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidK committed Sep 30, 2024
1 parent 25a7b75 commit 0c411e0
Showing 1 changed file with 39 additions and 1 deletion.
40 changes: 39 additions & 1 deletion substrate/frame/treasury/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -937,4 +937,42 @@ fn try_state_spends_invariant_3_works() {
Err(Other("Spend cannot expire before it becomes valid."))
);
});
}
}

#[test]
fn spend_status_without_body_is_noop_encoding() {
let spend_status_a: SpendStatus<(), (), (), (), (), ()> = SpendStatus {
body: (),
asset_kind: (),
amount: (),
beneficiary: (),
valid_from: (),
expire_at: (),
status: PaymentState::Pending,
};
let spend_status_b: SpendStatus<u32, (), (), (), (), ()> = SpendStatus {
body: 0,
asset_kind: (),
amount: (),
beneficiary: (),
valid_from: (),
expire_at: (),
status: PaymentState::Pending,
};
assert_eq!(
codec::Encode::encoded_size(&spend_status_a),
codec::Encode::encoded_size(&spend_status_b) - codec::Encode::encoded_size(&0u32),
);
}

#[test]
fn proposal_without_body_is_noop_encoding() {
let proposal_a: Proposal<(), (), ()> =
Proposal { body: (), proposer: (), value: (), beneficiary: (), bond: () };
let proposal_b: Proposal<u32, (), ()> =
Proposal { body: 0, proposer: (), value: (), beneficiary: (), bond: () };
assert_eq!(
codec::Encode::encoded_size(&proposal_a),
codec::Encode::encoded_size(&proposal_b) - codec::Encode::encoded_size(&0u32),
);
}

0 comments on commit 0c411e0

Please sign in to comment.