Skip to content

Commit

Permalink
Fix existing tests
Browse files Browse the repository at this point in the history
  • Loading branch information
JuaniRios committed Jul 22, 2024
1 parent 944d94a commit 0e4eb82
Show file tree
Hide file tree
Showing 15 changed files with 8,232 additions and 8,311 deletions.
36 changes: 13 additions & 23 deletions pallets/funding/src/benchmarking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -302,16 +302,6 @@ pub fn fill_projects_to_update<T: Config>(
}
}

pub fn run_blocks_to_execute_next_transition<T: Config>(
project_id: ProjectId,
update_type: UpdateType,
inst: &mut BenchInstantiator<T>,
) {
let update_block = inst.get_update_block(project_id, &update_type).unwrap();
frame_system::Pallet::<T>::set_block_number(update_block - 1u32.into());
inst.advance_time(One::one()).unwrap();
}

#[benchmarks(
where
T: Config + frame_system::Config<RuntimeEvent = <T as Config>::RuntimeEvent> + pallet_balances::Config<Balance = BalanceOf<T>>,
Expand Down Expand Up @@ -1433,7 +1423,7 @@ mod benchmarks {
// * validity checks *
// Storage
let maybe_transition =
inst.get_update_block(project_id, &UpdateType::ProjectDecision(FundingOutcomeDecision::AcceptFunding));
inst.go_to_next_state(project_id);
assert!(maybe_transition.is_some());
}

Expand Down Expand Up @@ -2088,7 +2078,7 @@ mod benchmarks {

inst.bid_for_users(project_id, accepted_bids).unwrap();

let transition_block = inst.get_update_block(project_id, &UpdateType::AuctionClosingStart).unwrap();
let transition_block = inst.go_to_next_state(project_id).unwrap();
inst.jump_to_block(transition_block);
let auction_closing_end_block =
inst.get_project_details(project_id).phase_transition_points.auction_closing.end().unwrap();
Expand Down Expand Up @@ -2714,7 +2704,7 @@ mod benchmarks {
vec![],
);

let settlement_block = inst.get_update_block(project_id, &UpdateType::StartSettlement).unwrap();
let settlement_block = inst.go_to_next_state(project_id).unwrap();
inst.jump_to_block(settlement_block);

inst.settle_project(project_id).unwrap();
Expand Down Expand Up @@ -2764,7 +2754,7 @@ mod benchmarks {
vec![],
);

let settlement_block = inst.get_update_block(project_id, &UpdateType::StartSettlement).unwrap();
let settlement_block = inst.go_to_next_state(project_id).unwrap();
inst.jump_to_block(settlement_block);

inst.settle_project(project_id).unwrap();
Expand Down Expand Up @@ -2835,7 +2825,7 @@ mod benchmarks {
participant_contributions,
);

let settlement_block = inst.get_update_block(project_id, &UpdateType::StartSettlement).unwrap();
let settlement_block = inst.go_to_next_state(project_id).unwrap();
inst.jump_to_block(settlement_block);

inst.settle_project(project_id).unwrap();
Expand Down Expand Up @@ -2881,7 +2871,7 @@ mod benchmarks {
vec![],
);

let settlement_block = inst.get_update_block(project_id, &UpdateType::StartSettlement).unwrap();
let settlement_block = inst.go_to_next_state(project_id).unwrap();
inst.jump_to_block(settlement_block);

inst.settle_project(project_id).unwrap();
Expand Down Expand Up @@ -2940,7 +2930,7 @@ mod benchmarks {
vec![],
);

let settlement_block = inst.get_update_block(project_id, &UpdateType::StartSettlement).unwrap();
let settlement_block = inst.go_to_next_state(project_id).unwrap();
inst.jump_to_block(settlement_block);

inst.settle_project(project_id).unwrap();
Expand Down Expand Up @@ -3003,7 +2993,7 @@ mod benchmarks {
vec![],
);

let settlement_block = inst.get_update_block(project_id, &UpdateType::StartSettlement).unwrap();
let settlement_block = inst.go_to_next_state(project_id).unwrap();
inst.jump_to_block(settlement_block);

inst.settle_project(project_id).unwrap();
Expand Down Expand Up @@ -3084,7 +3074,7 @@ mod benchmarks {
vec![],
);

let settlement_block = inst.get_update_block(project_id, &UpdateType::StartSettlement).unwrap();
let settlement_block = inst.go_to_next_state(project_id).unwrap();
inst.jump_to_block(settlement_block);

inst.settle_project(project_id).unwrap();
Expand Down Expand Up @@ -3206,7 +3196,7 @@ mod benchmarks {
participant_contributions,
);

let settlement_block = inst.get_update_block(project_id, &UpdateType::StartSettlement).unwrap();
let settlement_block = inst.go_to_next_state(project_id).unwrap();
inst.jump_to_block(settlement_block);

inst.settle_project(project_id).unwrap();
Expand Down Expand Up @@ -3301,7 +3291,7 @@ mod benchmarks {
participant_contributions,
);

let settlement_block = inst.get_update_block(project_id, &UpdateType::StartSettlement).unwrap();
let settlement_block = inst.go_to_next_state(project_id).unwrap();
inst.jump_to_block(settlement_block);

inst.settle_project(project_id).unwrap();
Expand Down Expand Up @@ -3377,7 +3367,7 @@ mod benchmarks {
vec![],
);

let settlement_block = inst.get_update_block(project_id, &UpdateType::StartSettlement).unwrap();
let settlement_block = inst.go_to_next_state(project_id).unwrap();
inst.jump_to_block(settlement_block);

inst.settle_project(project_id).unwrap();
Expand Down Expand Up @@ -3427,7 +3417,7 @@ mod benchmarks {
vec![],
);

let settlement_block = inst.get_update_block(project_id, &UpdateType::StartSettlement).unwrap();
let settlement_block = inst.go_to_next_state(project_id).unwrap();
inst.jump_to_block(settlement_block);

inst.settle_project(project_id).unwrap();
Expand Down
6 changes: 3 additions & 3 deletions pallets/funding/src/functions/3_auction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ impl<T: Config> Pallet<T> {
project_id,
project_details,
ProjectStatus::AuctionInitializePeriod,
ProjectStatus::Auction,
ProjectStatus::AuctionRound,
T::AuctionOpeningDuration::get(),
skip_round_end_check,
)
Expand Down Expand Up @@ -69,7 +69,7 @@ impl<T: Config> Pallet<T> {
Self::transition_project(
project_id,
project_details,
ProjectStatus::Auction,
ProjectStatus::AuctionRound,
ProjectStatus::CommunityRound(now.saturating_add(T::CommunityFundingDuration::get())),
T::CommunityFundingDuration::get() + T::RemainderFundingDuration::get(),
false,
Expand Down Expand Up @@ -151,7 +151,7 @@ impl<T: Config> Pallet<T> {

ensure!(ct_amount > Zero::zero(), Error::<T>::TooLow);
ensure!(did != project_details.issuer_did, Error::<T>::ParticipationToOwnProject);
ensure!(matches!(project_details.status, ProjectStatus::Auction), Error::<T>::IncorrectRound);
ensure!(matches!(project_details.status, ProjectStatus::AuctionRound), Error::<T>::IncorrectRound);
ensure!(
project_metadata.participation_currencies.contains(&funding_asset),
Error::<T>::FundingAssetNotAccepted
Expand Down
1 change: 1 addition & 0 deletions pallets/funding/src/functions/5_funding_end.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ impl<T: Config> Pallet<T> {
let round_end = now.saturating_add(duration).saturating_sub(One::one());
project_details.round_duration.update(Some(now), Some(round_end));
project_details.status = next_status;
ProjectsDetails::<T>::insert(project_id, project_details);

Ok(PostDispatchInfo { actual_weight: Some(actual_weight), pays_fee: Pays::Yes })
}
Expand Down
Loading

0 comments on commit 0e4eb82

Please sign in to comment.