tg_test_utils/
rules_builder.rs1use cosmwasm_std::Decimal;
2use tg_voting_contract::state::VotingRules;
3
4pub struct RulesBuilder {
5 pub voting_period: u32,
6 pub quorum: Decimal,
7 pub threshold: Decimal,
8 pub allow_end_early: bool,
9}
10
11impl RulesBuilder {
12 pub fn new() -> Self {
13 Self {
14 voting_period: 14,
15 quorum: Decimal::percent(1),
16 threshold: Decimal::percent(50),
17 allow_end_early: true,
18 }
19 }
20
21 pub fn with_threshold(mut self, threshold: impl Into<Decimal>) -> Self {
22 self.threshold = threshold.into();
23 self
24 }
25
26 pub fn with_quorum(mut self, quorum: impl Into<Decimal>) -> Self {
27 self.quorum = quorum.into();
28 self
29 }
30
31 pub fn build(&self) -> VotingRules {
32 VotingRules {
33 voting_period: self.voting_period,
34 quorum: self.quorum,
35 threshold: self.threshold,
36 allow_end_early: self.allow_end_early,
37 }
38 }
39}
40
41impl Default for RulesBuilder {
42 fn default() -> Self {
43 Self::new()
44 }
45}