Skip to content

Commit

Permalink
fix bechmarks & tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Raid5594 committed Nov 8, 2023
1 parent 9be9df7 commit 9dbebe8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
18 changes: 8 additions & 10 deletions pallets/ddc-staking/src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,18 +91,10 @@ impl pallet_timestamp::Config for Test {
type WeightInfo = ();
}

parameter_types! {
pub const BondingDuration: EraIndex = 10;
pub const DdcAccountsPalletId: PalletId = PalletId(*b"accounts");
}

impl crate::pallet::Config for Test {
type BondingDuration = BondingDuration;
type Currency = Balances;
type RuntimeEvent = RuntimeEvent;
type UnixTime = Timestamp;
type WeightInfo = ();
type StakersPayoutSource = DdcAccountsPalletId;
type ClusterVisitor = TestClusterVisitor;
}

Expand All @@ -125,8 +117,14 @@ impl<T: Config> ClusterVisitor<T> for TestClusterVisitor {
fn get_chill_delay(
_cluster_id: &ClusterId,
_node_type: NodeType,
) -> Result<EraIndex, ClusterVisitorError> {
Ok(10)
) -> Result<T::BlockNumber, ClusterVisitorError> {
Ok(T::BlockNumber::from(10u32))
}
fn get_unbonding_delay(
_cluster_id: &ClusterId,
_node_type: NodeType,
) -> Result<T::BlockNumber, ClusterVisitorError> {
Ok(T::BlockNumber::from(10u32))
}
}
pub struct ExtBuilder {
Expand Down
8 changes: 4 additions & 4 deletions pallets/ddc-staking/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,9 @@ fn staking_should_work() {
assert_ok!(DdcStaking::chill(RuntimeOrigin::signed(4)));

// Removal is scheduled, stashed value of 4 is still lock.
let chilling = DdcStaking::current_era().unwrap() +
TestClusterVisitor::get_chill_delay(&ClusterId::from([1; 20]), NodeType::CDN)
.unwrap_or(10_u32);
let chilling = System::block_number() + BlockNumber::from(10u64);
// TestClusterVisitor::get_chill_delay(&ClusterId::from([1; 20]), NodeType::CDN)
// .unwrap_or(10_u64);
assert_eq!(
DdcStaking::ledger(&4),
Some(StakingLedger {
Expand All @@ -131,7 +131,7 @@ fn staking_should_work() {
assert_ok!(Balances::reserve(&3, 409));

// Set `CurrentEra` to the value allows us to chill.
while DdcStaking::current_era().unwrap() < chilling {
while System::block_number() < chilling {
System::set_block_number(System::block_number() + 1);
Timestamp::set_timestamp(System::block_number() * BLOCK_TIME + INIT_TIMESTAMP);
DdcStaking::on_finalize(System::block_number());
Expand Down

0 comments on commit 9dbebe8

Please sign in to comment.