Skip to content

Commit 1608219

Browse files
authored
FEAT: Fixed both unit tests #457 (#459)
feat: Fixed both unit tests #457
1 parent 799c8bf commit 1608219

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

substrate-node/pallets/pallet-dao/src/lib.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,16 @@ pub mod pallet {
212212
Error::<T>::DuplicateProposal
213213
);
214214

215+
let now = frame_system::Pallet::<T>::block_number();
216+
let mut end = now + T::MotionDuration::get();
217+
if let Some(motion_duration) = duration {
218+
ensure!(
219+
motion_duration < T::BlockNumber::from(constants::time::DAYS * 30),
220+
Error::<T>::InvalidProposalDuration
221+
);
222+
end = now + motion_duration;
223+
}
224+
215225
let index = Self::proposal_count();
216226
<ProposalCount<T>>::mutate(|i| *i += 1);
217227
<ProposalOf<T>>::insert(proposal_hash, *action);
@@ -223,16 +233,6 @@ pub mod pallet {
223233
};
224234
<Proposals<T>>::insert(proposal_hash, p);
225235

226-
let now = frame_system::Pallet::<T>::block_number();
227-
let mut end = now + T::MotionDuration::get();
228-
if let Some(motion_duration) = duration {
229-
ensure!(
230-
motion_duration < T::BlockNumber::from(constants::time::DAYS * 30),
231-
Error::<T>::InvalidProposalDuration
232-
);
233-
end = now + motion_duration;
234-
}
235-
236236
let votes = {
237237
proposal::DaoVotes {
238238
index,

substrate-node/runtime/src/constants.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ pub mod fee {
8686

8787
#[cfg(test)]
8888
mod tests {
89-
use super::currency::{CENTS, DOLLARS, MILLICENTS};
89+
use super::currency::{CENTS, MILLICENTS};
9090
use super::fee::WeightToFeeStruct;
9191
use crate::MaximumBlockWeight;
9292
use frame_support::weights::constants::ExtrinsicBaseWeight;
@@ -95,18 +95,18 @@ mod tests {
9595
#[test]
9696
// This function tests that the fee for `MaximumBlockWeight` of weight is correct
9797
fn full_block_fee_is_correct() {
98-
// A full block should cost 16 DOLLARS
99-
println!("Base: {}", ExtrinsicBaseWeight::get());
98+
// A full block should cost 23.3112 DOLLARS
99+
log::info!("MaxBlockWeight: {:?}", MaximumBlockWeight::get());
100100
let x = WeightToFeeStruct::weight_to_fee(&MaximumBlockWeight::get());
101-
let y = 16 * DOLLARS;
101+
let y = 2331120 * MILLICENTS;
102102
assert!(x.max(y) - x.min(y) < MILLICENTS);
103103
}
104104

105105
#[test]
106106
// This function tests that the fee for `ExtrinsicBaseWeight` of weight is correct
107107
fn extrinsic_base_fee_is_correct() {
108108
// `ExtrinsicBaseWeight` should cost 1/10 of a CENT
109-
println!("Base: {}", ExtrinsicBaseWeight::get());
109+
log::info!("Base: {}", ExtrinsicBaseWeight::get());
110110
let x = WeightToFeeStruct::weight_to_fee(&ExtrinsicBaseWeight::get());
111111
let y = CENTS / 10;
112112
assert!(x.max(y) - x.min(y) < MILLICENTS);

0 commit comments

Comments
 (0)