Skip to content

Commit

Permalink
Undo accidental reverts
Browse files Browse the repository at this point in the history
  • Loading branch information
tmpolaczyk committed Dec 18, 2023
1 parent d656233 commit 88fb4de
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 38 deletions.
9 changes: 3 additions & 6 deletions client/consensus/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
// You should have received a copy of the GNU General Public License
// along with Tanssi. If not, see <http://www.gnu.org/licenses/>.

#![allow(clippy::await_holding_lock)]

// This tests have been greatly influenced by
// https://github.com/paritytech/substrate/blob/master/client/consensus/aura/src/lib.rs#L832
// Most of the items hereby added are intended to make it work with our current consensus mechanism
Expand Down Expand Up @@ -210,12 +212,7 @@ impl Proposer<TestBlock> for DummyProposer {
_: Duration,
_: Option<usize>,
) -> Self::Proposal {
let r = self
.1
.new_block(digests)
.unwrap()
.build()
.map_err(|e| e.into());
let r = self.1.new_block(digests).unwrap().build();

futures::future::ready(r.map(|b| Proposal {
block: b.block,
Expand Down
2 changes: 1 addition & 1 deletion node/src/container_chain_spawner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -883,7 +883,7 @@ mod tests {
chains_to_start,
need_to_restart,
} = handle_update_assignment_state_change(
&mut *self.state.lock().unwrap(),
&mut self.state.lock().unwrap(),
self.orchestrator_para_id,
self.collate_on_tanssi.clone(),
current,
Expand Down
2 changes: 1 addition & 1 deletion pallets/data-preservers/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ where
MockData::get()
.container_chain_managers
.get(para_id)
.and_then(|inner| inner.clone())
.and_then(|inner| *inner)
.and_then(|manager| {
if manager != u64::from(signed_account.clone()) {
None
Expand Down
14 changes: 7 additions & 7 deletions pallets/pooled-staking/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ pub(crate) fn events() -> Vec<crate::Event<Runtime>> {
macro_rules! assert_last_event {
($event:expr) => {
match &$event {
e => assert_eq!(*e, crate::mock::last_event()),
e => assert_eq!(*e, $crate::mock::last_event()),
}
};
}
Expand All @@ -435,7 +435,7 @@ macro_rules! assert_last_event {
macro_rules! assert_eq_events {
($events:expr) => {
match &$events {
e => similar_asserts::assert_eq!(*e, crate::mock::events()),
e => similar_asserts::assert_eq!(*e, $crate::mock::events()),
}
};
}
Expand All @@ -459,7 +459,7 @@ macro_rules! assert_eq_events {
#[macro_export]
macro_rules! assert_eq_last_events {
($events:expr) => {
crate::assert_tail_eq!($events, crate::mock::events())
$crate::assert_tail_eq!($events, $crate::mock::events())
};
}

Expand Down Expand Up @@ -488,10 +488,10 @@ macro_rules! assert_event_emitted {
match &$event {
e => {
assert!(
crate::mock::events().iter().find(|x| *x == e).is_some(),
$crate::mock::events().iter().find(|x| *x == e).is_some(),
"Event {:?} was not found in events: \n {:?}",
e,
crate::mock::events()
$crate::mock::events()
);
}
}
Expand All @@ -505,10 +505,10 @@ macro_rules! assert_event_not_emitted {
match &$event {
e => {
assert!(
crate::mock::events().iter().find(|x| *x == e).is_none(),
$crate::mock::events().iter().find(|x| *x == e).is_none(),
"Event {:?} was found in events: \n {:?}",
e,
crate::mock::events()
$crate::mock::events()
);
}
}
Expand Down
1 change: 0 additions & 1 deletion pallets/pooled-staking/src/tests/manual_rewards.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ fn second_delegation_transfer_rewards() {
request_amount: amount,
expected_increase: amount,
expected_manual_rewards: expected_rewards,
..default()
}
.test::<pools::ManualRewards<Runtime>>();

Expand Down
12 changes: 4 additions & 8 deletions pallets/pooled-staking/src/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,10 @@ pub(crate) fn operation_stake(
at: u64,
) -> Balance {
let operation_key = match pool {
TargetPool::AutoCompounding => PendingOperationKey::JoiningAutoCompounding {
candidate: candidate.clone(),
at,
},
TargetPool::ManualRewards => PendingOperationKey::JoiningManualRewards {
candidate: candidate.clone(),
at,
},
TargetPool::AutoCompounding => {
PendingOperationKey::JoiningAutoCompounding { candidate, at }
}
TargetPool::ManualRewards => PendingOperationKey::JoiningManualRewards { candidate, at },
};

let shares = PendingOperations::<Runtime>::get(&delegator, &operation_key);
Expand Down
16 changes: 8 additions & 8 deletions pallets/pooled-staking/src/tests/rewards.rs
Original file line number Diff line number Diff line change
Expand Up @@ -592,8 +592,8 @@ fn reward_distribution_is_transactional() {
let request_time = <Runtime as crate::Config>::JoiningRequestTimer::now();

assert_ok!(Staking::request_delegate(
RuntimeOrigin::signed(ACCOUNT_CANDIDATE_1.into()),
ACCOUNT_CANDIDATE_1.into(),
RuntimeOrigin::signed(ACCOUNT_CANDIDATE_1),
ACCOUNT_CANDIDATE_1,
TargetPool::AutoCompounding,
1_000_000_000,
));
Expand All @@ -604,31 +604,31 @@ fn reward_distribution_is_transactional() {
}

assert_ok!(Staking::execute_pending_operations(
RuntimeOrigin::signed(ACCOUNT_CANDIDATE_1.into()),
RuntimeOrigin::signed(ACCOUNT_CANDIDATE_1),
vec![PendingOperationQuery {
delegator: ACCOUNT_CANDIDATE_1.into(),
delegator: ACCOUNT_CANDIDATE_1,
operation: PendingOperationKey::JoiningAutoCompounding {
candidate: ACCOUNT_CANDIDATE_1.into(),
candidate: ACCOUNT_CANDIDATE_1,
at: request_time
},
}]
));

let total_staked_before =
pools::AutoCompounding::<Runtime>::total_staked(&ACCOUNT_CANDIDATE_1.into());
pools::AutoCompounding::<Runtime>::total_staked(&ACCOUNT_CANDIDATE_1);

// Increase ED to make reward destribution fail when resolving
// credit to Staking account.
MockExistentialDeposit::set(u128::MAX);

let rewards = Balances::issue(1_000_000_000);
assert_err!(
Staking::distribute_rewards(ACCOUNT_CANDIDATE_1.into(), rewards),
Staking::distribute_rewards(ACCOUNT_CANDIDATE_1, rewards),
DispatchError::NoProviders
);

let total_staked_after =
pools::AutoCompounding::<Runtime>::total_staked(&ACCOUNT_CANDIDATE_1.into());
pools::AutoCompounding::<Runtime>::total_staked(&ACCOUNT_CANDIDATE_1);
assert_eq!(
total_staked_before, total_staked_after,
"distribution should be reverted"
Expand Down
2 changes: 1 addition & 1 deletion runtime/dancebox/tests/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ pub fn get_aura_id_from_seed(seed: &str) -> NimbusId {
}

pub fn get_orchestrator_current_author() -> Option<AccountId> {
let slot: u64 = current_slot().into();
let slot: u64 = current_slot();
let orchestrator_collators = Runtime::parachain_collators(ParachainInfo::get())?;
let author_index = slot % orchestrator_collators.len() as u64;
let account = orchestrator_collators.get(author_index as usize)?;
Expand Down
6 changes: 3 additions & 3 deletions runtime/dancebox/tests/common/xcm/foreign_sovereigns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ fn using_sovereign_works_from_tanssi() {
let sovereign_account =
westend_runtime::xcm_config::LocationConverter::convert_location(&MultiLocation {
parents: 0,
interior: X1(Parachain(2000u32.into())),
interior: X1(Parachain(2000u32)),
})
.unwrap();

Expand Down Expand Up @@ -119,7 +119,7 @@ fn using_sovereign_works_from_tanssi() {
success,
..
}) => {
success: *success == true,
success: *success,
},
]
);
Expand Down Expand Up @@ -177,7 +177,7 @@ fn using_sovereign_works_from_tanssi_frontier_template() {
let sovereign_account =
container_chain_template_frontier_runtime::xcm_config::LocationToAccountId::convert_location(&MultiLocation {
parents: 1,
interior: X1(Parachain(2000u32.into())),
interior: X1(Parachain(2000u32)),
})
.unwrap();

Expand Down
4 changes: 2 additions & 2 deletions runtime/dancebox/tests/integration_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3860,7 +3860,7 @@ fn test_migration_holds() {
<Runtime as pallet_balances::Config>::Balance,
> = pallet_balances::IdAmount {
id: *b"POOLSTAK",
amount: 100u128.into(),
amount: 100u128,
};
let holds = vec![hold];
let bounded_holds =
Expand Down Expand Up @@ -3914,7 +3914,7 @@ fn test_migration_holds_runtime_enum() {
<Runtime as pallet_balances::Config>::Balance,
> = pallet_balances::IdAmount {
id: OldHoldReason::PooledStake,
amount: 100u128.into(),
amount: 100u128,
};
let holds = vec![hold];
let bounded_holds =
Expand Down

0 comments on commit 88fb4de

Please sign in to comment.