Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
imstar15 committed Jul 27, 2023
1 parent 49c19a9 commit af69d5e
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 175 deletions.
1 change: 1 addition & 0 deletions pallets/automation-time/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ pallet-xcmp-handler = { path = "../xcmp-handler", default-features = false }
primitives = { path = "../../primitives", default-features = false }

[dev-dependencies]
env_logger = "0.9"
rand = { version = "0.7.3" }
serde = { version = "1.0.144" }
sp-core = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.38" }
Expand Down
43 changes: 1 addition & 42 deletions pallets/automation-time/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,6 @@ use sp_std::{boxed::Box, collections::btree_map::BTreeMap, vec, vec::Vec};
pub use weights::WeightInfo;
use xcm::{latest::prelude::*, VersionedMultiLocation};

#[macro_export]
macro_rules! ERROR_MESSAGE_DELEGATION_FORMAT {
() => {
"delegator: {:?}, collator: {:?}"
};
}
pub const ERROR_MESSAGE_BALANCE_LOW: &str = "Balance less than minimum";

#[derive(Clone, Eq, PartialEq, Default, RuntimeDebug, Encode, Decode, TypeInfo)]
pub struct DispatchErrorDataMap(BTreeMap<String, String>);
impl sp_runtime::traits::Printable for DispatchErrorDataMap {
Expand All @@ -101,7 +93,7 @@ impl sp_runtime::traits::Printable for DispatchErrorDataMap {
}
pub type DispatchErrorWithDataMap = DispatchErrorWithData<DispatchErrorDataMap>;

const AUTO_COMPOUND_DELEGATION_CANCEL_UPON_ERRORS: [&str; 1] = ["DelegationDNE"];
const AUTO_COMPOUND_DELEGATION_CANCEL_UPON_ERRORS: [&str; 2] = ["DelegatorDNE", "DelegationDNE"];

#[frame_support::pallet]
pub mod pallet {
Expand Down Expand Up @@ -1520,39 +1512,6 @@ pub mod pallet {
};
},
}

// if let Some(err) = dispatch_error if task.cancel_upon_errors.contains(&err.as_str()) {
// Self::deposit_event(Event::<T>::TaskNotRescheduled {
// who: task.owner_id.clone(),
// task_id,
// error: err,
// });
// AccountTasks::<T>::remove(task.owner_id.clone(), task_id);
// } else {
// let owner_id = task.owner_id.clone();
// let action = task.action.clone();
// match Self::reschedule_existing_task(task_id, &mut task) {
// Ok(_) => {
// let schedule_as = match action {
// Action::XCMP { schedule_as, .. } => schedule_as,
// _ => None,
// };
// Self::deposit_event(Event::<T>::TaskRescheduled {
// who: owner_id,
// task_id,
// schedule_as,
// });
// },
// Err(err) => {
// Self::deposit_event(Event::<T>::TaskFailedToReschedule {
// who: task.owner_id.clone(),
// task_id,
// error: err,
// });
// AccountTasks::<T>::remove(task.owner_id.clone(), task_id);
// },
// };
// }
}

fn reschedule_existing_task(task_id: TaskId<T>, task: &mut TaskOf<T>) -> DispatchResult {
Expand Down
8 changes: 5 additions & 3 deletions pallets/automation-time/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,12 +264,14 @@ impl<
candidate: &T::AccountId,
account_minimum: BalanceOf<T>,
) -> Result<BalanceOf<T>, DispatchErrorWithPostInfo> {
log::error!("delegator_bond_till_minimum AAAAAAA");
if *delegator != T::AccountId::decode(&mut DELEGATOR_ACCOUNT.as_ref()).unwrap() {
return Err(DispatchErrorWithPostInfo::from(<pallet_parachain_staking::Error<T>>::DelegatorDNE));
}
if *candidate != T::AccountId::decode(&mut COLLATOR_ACCOUNT.as_ref()).unwrap() {
log::error!("delegator_bond_till_minimum BBBB");
return Err(DispatchErrorWithPostInfo::from(<pallet_parachain_staking::Error<T>>::DelegationDNE));
}
log::error!("delegator_bond_till_minimum CCCCCC");
log::error!("delegator_bond_till_minimum CCCCCC, C::free_balance(&delegator): {:?}", C::free_balance(&delegator));
log::error!("delegator_bond_till_minimum CCCCCC, account_minimum: {:?}", account_minimum);

let delegation = C::free_balance(&delegator)
.checked_sub(&account_minimum)
Expand Down
Loading

0 comments on commit af69d5e

Please sign in to comment.