Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
imstar15 committed Jul 31, 2023
1 parent 8e12676 commit 19e9eec
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 37 deletions.
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion pallets/automation-time/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ 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
16 changes: 0 additions & 16 deletions pallets/automation-time/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,17 +82,6 @@ use sp_std::{boxed::Box, collections::btree_map::BTreeMap, vec, vec::Vec};
pub use weights::WeightInfo;
use xcm::{latest::prelude::*, VersionedMultiLocation};

#[derive(Clone, Eq, PartialEq, Default, RuntimeDebug, Encode, Decode, TypeInfo)]
pub struct DispatchErrorDataMap(BTreeMap<String, String>);
impl sp_runtime::traits::Printable for DispatchErrorDataMap {
fn print(&self) {
for (key, value) in self.0.iter() {
sp_io::misc::print_utf8(format!("{:?}: {:?}, ", key, value).as_bytes());
}
}
}
pub type DispatchErrorWithDataMap = DispatchErrorWithData<DispatchErrorDataMap>;

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

#[frame_support::pallet]
Expand Down Expand Up @@ -324,11 +313,6 @@ pub mod pallet {
task_id: TaskIdV2,
amount: BalanceOf<T>,
},
AutoCompoundDelegatorStakeFailed {
task_id: TaskIdV2,
error_message: Vec<u8>,
error: DispatchErrorWithPostInfo,
},
/// The task could not be run at the scheduled time.
TaskMissed {
who: AccountOf<T>,
Expand Down
14 changes: 7 additions & 7 deletions pallets/automation-time/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2726,7 +2726,7 @@ fn auto_compound_delegated_stake_enough_balance_has_delegation() {
// 1. User's wallet balance < minimum balance + execution fee
// 2. User has a delegation with the specificed collator
// Expected result:
// 1. Emit TaskExecutionFailed event with error: InsufficientBalance
// 1. The current execution will result in failure, triggering the emission of an TaskExecutionFailed event, error: DelegationDNE
// 2. Next execution will be scheduled
#[test]
fn auto_compound_delegated_stake_not_enough_balance_has_delegation() {
Expand Down Expand Up @@ -2788,7 +2788,7 @@ fn auto_compound_delegated_stake_not_enough_balance_has_delegation() {
// 1. User's wallet balance >= minimum balance + execution fee
// 2. User has no delegation with the specificed collator
// Expected result:
// 1. The current execution will result in failure, triggering the emission of an AutoCompoundDelegatorStakeFailed event, error: DelegationNotFound
// 1. The current execution will result in failure, triggering the emission of an TaskExecutionFailed event, error: DelegatorDNE
// 2. Next execution will not be scheduled
#[test]
fn auto_compound_delegated_stake_enough_balance_no_delegator() {
Expand Down Expand Up @@ -2849,10 +2849,10 @@ fn auto_compound_delegated_stake_enough_balance_no_delegator() {
// 2. Next execution will not be scheduled
assert!(AutomationTime::get_scheduled_tasks(SCHEDULED_TIME + frequency)
.filter(|scheduled| {
scheduled.tasks.iter().any(|t| *t == (AccountId32::new(ALICE), task_id.clone()))
scheduled.tasks.iter().any(|t| *t == (delegator.clone(), task_id.clone()))
})
.is_none());
assert!(AutomationTime::get_account_task(AccountId32::new(ALICE), task_id).is_none());
assert!(AutomationTime::get_account_task(delegator, task_id).is_none());
})
}

Expand All @@ -2861,7 +2861,7 @@ fn auto_compound_delegated_stake_enough_balance_no_delegator() {
// 1. User's wallet balance >= minimum balance + execution fee
// 2. User has no delegation with the specificed collator
// Expected result:
// 1. The current execution will result in failure, triggering the emission of an AutoCompoundDelegatorStakeFailed event, error: DelegationNotFound
// 1. The current execution will result in failure, triggering the emission of an TaskExecutionFailed event, error: DelegationDNE
// 2. Next execution will not be scheduled
#[test]
fn auto_compound_delegated_stake_enough_balance_no_delegation() {
Expand Down Expand Up @@ -2925,10 +2925,10 @@ fn auto_compound_delegated_stake_enough_balance_no_delegation() {
scheduled
.tasks
.iter()
.any(|t| *t == (AccountId32::new(DELEGATOR_ACCOUNT), task_id.clone()))
.any(|t| *t == (delegator.clone(), task_id.clone()))
})
.is_none());
assert!(AutomationTime::get_account_task(AccountId32::new(DELEGATOR_ACCOUNT), task_id)
assert!(AutomationTime::get_account_task(delegator, task_id)
.is_none());
})
}
Expand Down
12 changes: 0 additions & 12 deletions pallets/automation-time/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -361,18 +361,6 @@ impl<AccountId, TaskId> ScheduledTasks<AccountId, TaskId> {
}
}

#[derive(Eq, PartialEq, Clone, Encode, Decode, RuntimeDebug, TypeInfo)]
pub struct DispatchErrorWithData<Data>
where
Data: Eq + PartialEq + Clone + Encode + Decode + Printable,
{
/// Additional data
pub data: Data,
pub message: Option<String>,
/// The actual `DispatchResult` indicating whether the dispatch was successful.
pub error: DispatchError,
}

#[cfg(test)]
mod tests {
use super::*;
Expand Down

0 comments on commit 19e9eec

Please sign in to comment.