mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 21:31:04 +00:00
BREAKING: Rename Origin (#12258)
* BREAKING: Rename Origin * more renaming * a bit more renaming * fix * more fixing * fix in frame_support * even more fixes * fix * small fix * ... * update .stderr * docs * update docs * update docs * docs
This commit is contained in:
@@ -700,7 +700,7 @@ pub mod pallet {
|
||||
|
||||
/// Origin that can control this pallet. Note that any action taken by this origin (such)
|
||||
/// as providing an emergency solution is not checked. Thus, it must be a trusted origin.
|
||||
type ForceOrigin: EnsureOrigin<Self::Origin>;
|
||||
type ForceOrigin: EnsureOrigin<Self::RuntimeOrigin>;
|
||||
|
||||
/// The configuration of benchmarking.
|
||||
type BenchmarkingConfig: BenchmarkingConfig;
|
||||
@@ -1828,7 +1828,7 @@ mod tests {
|
||||
use crate::{
|
||||
mock::{
|
||||
multi_phase_events, raw_solution, roll_to, AccountId, ExtBuilder, MockWeightInfo,
|
||||
MockedWeightInfo, MultiPhase, Origin, Runtime, SignedMaxSubmissions, System,
|
||||
MockedWeightInfo, MultiPhase, Runtime, RuntimeOrigin, SignedMaxSubmissions, System,
|
||||
TargetIndex, Targets,
|
||||
},
|
||||
Phase,
|
||||
@@ -2030,7 +2030,10 @@ mod tests {
|
||||
score: ElectionScore { minimal_stake: (5 + s).into(), ..Default::default() },
|
||||
..Default::default()
|
||||
};
|
||||
assert_ok!(MultiPhase::submit(crate::mock::Origin::signed(99), Box::new(solution)));
|
||||
assert_ok!(MultiPhase::submit(
|
||||
crate::mock::RuntimeOrigin::signed(99),
|
||||
Box::new(solution)
|
||||
));
|
||||
}
|
||||
|
||||
// an unexpected call to elect.
|
||||
@@ -2057,7 +2060,10 @@ mod tests {
|
||||
assert!(MultiPhase::current_phase().is_signed());
|
||||
|
||||
let solution = raw_solution();
|
||||
assert_ok!(MultiPhase::submit(crate::mock::Origin::signed(99), Box::new(solution)));
|
||||
assert_ok!(MultiPhase::submit(
|
||||
crate::mock::RuntimeOrigin::signed(99),
|
||||
Box::new(solution)
|
||||
));
|
||||
|
||||
roll_to(30);
|
||||
assert_ok!(MultiPhase::elect());
|
||||
@@ -2098,7 +2104,7 @@ mod tests {
|
||||
// ensure this solution is valid.
|
||||
assert!(MultiPhase::queued_solution().is_none());
|
||||
assert_ok!(MultiPhase::submit_unsigned(
|
||||
crate::mock::Origin::none(),
|
||||
crate::mock::RuntimeOrigin::none(),
|
||||
Box::new(solution),
|
||||
witness
|
||||
));
|
||||
@@ -2176,12 +2182,12 @@ mod tests {
|
||||
|
||||
// no single account can trigger this
|
||||
assert_noop!(
|
||||
MultiPhase::governance_fallback(Origin::signed(99), None, None),
|
||||
MultiPhase::governance_fallback(RuntimeOrigin::signed(99), None, None),
|
||||
DispatchError::BadOrigin
|
||||
);
|
||||
|
||||
// only root can
|
||||
assert_ok!(MultiPhase::governance_fallback(Origin::root(), None, None));
|
||||
assert_ok!(MultiPhase::governance_fallback(RuntimeOrigin::root(), None, None));
|
||||
// something is queued now
|
||||
assert!(MultiPhase::queued_solution().is_some());
|
||||
// next election call with fix everything.;
|
||||
|
||||
@@ -199,7 +199,7 @@ pub fn witness() -> SolutionOrSnapshotSize {
|
||||
impl frame_system::Config for Runtime {
|
||||
type SS58Prefix = ();
|
||||
type BaseCallFilter = frame_support::traits::Everything;
|
||||
type Origin = Origin;
|
||||
type RuntimeOrigin = RuntimeOrigin;
|
||||
type Index = u64;
|
||||
type BlockNumber = BlockNumber;
|
||||
type RuntimeCall = RuntimeCall;
|
||||
|
||||
@@ -529,7 +529,7 @@ mod tests {
|
||||
use crate::{
|
||||
mock::{
|
||||
balances, raw_solution, roll_to, Balances, ExtBuilder, MockedWeightInfo, MultiPhase,
|
||||
Origin, Runtime, SignedMaxRefunds, SignedMaxSubmissions, SignedMaxWeight,
|
||||
Runtime, RuntimeOrigin, SignedMaxRefunds, SignedMaxSubmissions, SignedMaxWeight,
|
||||
},
|
||||
Error, Perbill, Phase,
|
||||
};
|
||||
@@ -546,7 +546,7 @@ mod tests {
|
||||
let solution = raw_solution();
|
||||
|
||||
assert_noop!(
|
||||
MultiPhase::submit(Origin::signed(10), Box::new(solution)),
|
||||
MultiPhase::submit(RuntimeOrigin::signed(10), Box::new(solution)),
|
||||
Error::<Runtime>::PreDispatchEarlySubmission,
|
||||
);
|
||||
})
|
||||
@@ -561,7 +561,7 @@ mod tests {
|
||||
let solution = raw_solution();
|
||||
assert_eq!(balances(&99), (100, 0));
|
||||
|
||||
assert_ok!(MultiPhase::submit(Origin::signed(99), Box::new(solution)));
|
||||
assert_ok!(MultiPhase::submit(RuntimeOrigin::signed(99), Box::new(solution)));
|
||||
|
||||
assert_eq!(balances(&99), (95, 5));
|
||||
assert_eq!(MultiPhase::signed_submissions().iter().next().unwrap().deposit, 5);
|
||||
@@ -577,7 +577,7 @@ mod tests {
|
||||
let solution = raw_solution();
|
||||
assert_eq!(balances(&99), (100, 0));
|
||||
|
||||
assert_ok!(MultiPhase::submit(Origin::signed(99), Box::new(solution)));
|
||||
assert_ok!(MultiPhase::submit(RuntimeOrigin::signed(99), Box::new(solution)));
|
||||
assert_eq!(balances(&99), (95, 5));
|
||||
|
||||
assert!(MultiPhase::finalize_signed_phase());
|
||||
@@ -597,7 +597,7 @@ mod tests {
|
||||
// make the solution invalid.
|
||||
solution.score.minimal_stake += 1;
|
||||
|
||||
assert_ok!(MultiPhase::submit(Origin::signed(99), Box::new(solution)));
|
||||
assert_ok!(MultiPhase::submit(RuntimeOrigin::signed(99), Box::new(solution)));
|
||||
assert_eq!(balances(&99), (95, 5));
|
||||
|
||||
// no good solution was stored.
|
||||
@@ -618,11 +618,11 @@ mod tests {
|
||||
assert_eq!(balances(&999), (100, 0));
|
||||
|
||||
// submit as correct.
|
||||
assert_ok!(MultiPhase::submit(Origin::signed(99), Box::new(solution.clone())));
|
||||
assert_ok!(MultiPhase::submit(RuntimeOrigin::signed(99), Box::new(solution.clone())));
|
||||
|
||||
// make the solution invalid and weaker.
|
||||
solution.score.minimal_stake -= 1;
|
||||
assert_ok!(MultiPhase::submit(Origin::signed(999), Box::new(solution)));
|
||||
assert_ok!(MultiPhase::submit(RuntimeOrigin::signed(999), Box::new(solution)));
|
||||
assert_eq!(balances(&99), (95, 5));
|
||||
assert_eq!(balances(&999), (95, 5));
|
||||
|
||||
@@ -648,7 +648,7 @@ mod tests {
|
||||
score: ElectionScore { minimal_stake: (5 + s).into(), ..Default::default() },
|
||||
..Default::default()
|
||||
};
|
||||
assert_ok!(MultiPhase::submit(Origin::signed(99), Box::new(solution)));
|
||||
assert_ok!(MultiPhase::submit(RuntimeOrigin::signed(99), Box::new(solution)));
|
||||
}
|
||||
|
||||
// weaker.
|
||||
@@ -658,7 +658,7 @@ mod tests {
|
||||
};
|
||||
|
||||
assert_noop!(
|
||||
MultiPhase::submit(Origin::signed(99), Box::new(solution)),
|
||||
MultiPhase::submit(RuntimeOrigin::signed(99), Box::new(solution)),
|
||||
Error::<Runtime>::SignedQueueFull,
|
||||
);
|
||||
})
|
||||
@@ -679,7 +679,7 @@ mod tests {
|
||||
let mut solution = raw_solution();
|
||||
solution.score.minimal_stake -= s as u128;
|
||||
|
||||
assert_ok!(MultiPhase::submit(Origin::signed(account), Box::new(solution)));
|
||||
assert_ok!(MultiPhase::submit(RuntimeOrigin::signed(account), Box::new(solution)));
|
||||
assert_eq!(balances(&account), (95, 5));
|
||||
}
|
||||
|
||||
@@ -719,7 +719,7 @@ mod tests {
|
||||
},
|
||||
..Default::default()
|
||||
};
|
||||
assert_ok!(MultiPhase::submit(Origin::signed(99), Box::new(solution)));
|
||||
assert_ok!(MultiPhase::submit(RuntimeOrigin::signed(99), Box::new(solution)));
|
||||
|
||||
// This is 10% better, so does not meet the 20% threshold and is therefore rejected.
|
||||
solution = RawSolution {
|
||||
@@ -732,7 +732,7 @@ mod tests {
|
||||
};
|
||||
|
||||
assert_noop!(
|
||||
MultiPhase::submit(Origin::signed(99), Box::new(solution)),
|
||||
MultiPhase::submit(RuntimeOrigin::signed(99), Box::new(solution)),
|
||||
Error::<Runtime>::SignedQueueFull,
|
||||
);
|
||||
|
||||
@@ -746,7 +746,7 @@ mod tests {
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
assert_ok!(MultiPhase::submit(Origin::signed(99), Box::new(solution)));
|
||||
assert_ok!(MultiPhase::submit(RuntimeOrigin::signed(99), Box::new(solution)));
|
||||
})
|
||||
}
|
||||
|
||||
@@ -764,7 +764,7 @@ mod tests {
|
||||
score: ElectionScore { minimal_stake: (5 + s).into(), ..Default::default() },
|
||||
..Default::default()
|
||||
};
|
||||
assert_ok!(MultiPhase::submit(Origin::signed(account), Box::new(solution)));
|
||||
assert_ok!(MultiPhase::submit(RuntimeOrigin::signed(account), Box::new(solution)));
|
||||
assert_eq!(balances(&account), (95, 5));
|
||||
}
|
||||
|
||||
@@ -781,7 +781,7 @@ mod tests {
|
||||
score: ElectionScore { minimal_stake: 20, ..Default::default() },
|
||||
..Default::default()
|
||||
};
|
||||
assert_ok!(MultiPhase::submit(Origin::signed(999), Box::new(solution)));
|
||||
assert_ok!(MultiPhase::submit(RuntimeOrigin::signed(999), Box::new(solution)));
|
||||
|
||||
// the one with score 5 was rejected, the new one inserted.
|
||||
assert_eq!(
|
||||
@@ -809,14 +809,14 @@ mod tests {
|
||||
score: ElectionScore { minimal_stake: (5 + s).into(), ..Default::default() },
|
||||
..Default::default()
|
||||
};
|
||||
assert_ok!(MultiPhase::submit(Origin::signed(99), Box::new(solution)));
|
||||
assert_ok!(MultiPhase::submit(RuntimeOrigin::signed(99), Box::new(solution)));
|
||||
}
|
||||
|
||||
let solution = RawSolution {
|
||||
score: ElectionScore { minimal_stake: 4, ..Default::default() },
|
||||
..Default::default()
|
||||
};
|
||||
assert_ok!(MultiPhase::submit(Origin::signed(99), Box::new(solution)));
|
||||
assert_ok!(MultiPhase::submit(RuntimeOrigin::signed(99), Box::new(solution)));
|
||||
|
||||
assert_eq!(
|
||||
MultiPhase::signed_submissions()
|
||||
@@ -831,7 +831,7 @@ mod tests {
|
||||
score: ElectionScore { minimal_stake: 5, ..Default::default() },
|
||||
..Default::default()
|
||||
};
|
||||
assert_ok!(MultiPhase::submit(Origin::signed(99), Box::new(solution)));
|
||||
assert_ok!(MultiPhase::submit(RuntimeOrigin::signed(99), Box::new(solution)));
|
||||
|
||||
// the one with score 5 was rejected, the new one inserted.
|
||||
assert_eq!(
|
||||
@@ -856,7 +856,7 @@ mod tests {
|
||||
score: ElectionScore { minimal_stake: (5 + s).into(), ..Default::default() },
|
||||
..Default::default()
|
||||
};
|
||||
assert_ok!(MultiPhase::submit(Origin::signed(99), Box::new(solution)));
|
||||
assert_ok!(MultiPhase::submit(RuntimeOrigin::signed(99), Box::new(solution)));
|
||||
}
|
||||
|
||||
assert_eq!(balances(&99).1, 2 * 5);
|
||||
@@ -867,7 +867,7 @@ mod tests {
|
||||
score: ElectionScore { minimal_stake: 20, ..Default::default() },
|
||||
..Default::default()
|
||||
};
|
||||
assert_ok!(MultiPhase::submit(Origin::signed(999), Box::new(solution)));
|
||||
assert_ok!(MultiPhase::submit(RuntimeOrigin::signed(999), Box::new(solution)));
|
||||
|
||||
// got one bond back.
|
||||
assert_eq!(balances(&99).1, 2 * 4);
|
||||
@@ -886,7 +886,7 @@ mod tests {
|
||||
score: ElectionScore { minimal_stake: (5 + i).into(), ..Default::default() },
|
||||
..Default::default()
|
||||
};
|
||||
assert_ok!(MultiPhase::submit(Origin::signed(99), Box::new(solution)));
|
||||
assert_ok!(MultiPhase::submit(RuntimeOrigin::signed(99), Box::new(solution)));
|
||||
}
|
||||
assert_eq!(
|
||||
MultiPhase::signed_submissions()
|
||||
@@ -902,7 +902,7 @@ mod tests {
|
||||
..Default::default()
|
||||
};
|
||||
assert_noop!(
|
||||
MultiPhase::submit(Origin::signed(99), Box::new(solution)),
|
||||
MultiPhase::submit(RuntimeOrigin::signed(99), Box::new(solution)),
|
||||
Error::<Runtime>::SignedQueueFull,
|
||||
);
|
||||
})
|
||||
@@ -924,18 +924,18 @@ mod tests {
|
||||
let solution = raw_solution();
|
||||
|
||||
// submit a correct one.
|
||||
assert_ok!(MultiPhase::submit(Origin::signed(99), Box::new(solution.clone())));
|
||||
assert_ok!(MultiPhase::submit(RuntimeOrigin::signed(99), Box::new(solution.clone())));
|
||||
|
||||
// make the solution invalidly better and submit. This ought to be slashed.
|
||||
let mut solution_999 = solution.clone();
|
||||
solution_999.score.minimal_stake += 1;
|
||||
assert_ok!(MultiPhase::submit(Origin::signed(999), Box::new(solution_999)));
|
||||
assert_ok!(MultiPhase::submit(RuntimeOrigin::signed(999), Box::new(solution_999)));
|
||||
|
||||
// make the solution invalidly worse and submit. This ought to be suppressed and
|
||||
// returned.
|
||||
let mut solution_9999 = solution.clone();
|
||||
solution_9999.score.minimal_stake -= 1;
|
||||
assert_ok!(MultiPhase::submit(Origin::signed(9999), Box::new(solution_9999)));
|
||||
assert_ok!(MultiPhase::submit(RuntimeOrigin::signed(9999), Box::new(solution_9999)));
|
||||
|
||||
assert_eq!(
|
||||
MultiPhase::signed_submissions().iter().map(|x| x.who).collect::<Vec<_>>(),
|
||||
@@ -975,14 +975,14 @@ mod tests {
|
||||
assert_eq!(raw.solution.voter_count(), 5);
|
||||
assert_eq!(<Runtime as Config>::SignedMaxWeight::get(), Weight::from_ref_time(40));
|
||||
|
||||
assert_ok!(MultiPhase::submit(Origin::signed(99), Box::new(raw.clone())));
|
||||
assert_ok!(MultiPhase::submit(RuntimeOrigin::signed(99), Box::new(raw.clone())));
|
||||
|
||||
<SignedMaxWeight>::set(Weight::from_ref_time(30));
|
||||
|
||||
// note: resubmitting the same solution is technically okay as long as the queue has
|
||||
// space.
|
||||
assert_noop!(
|
||||
MultiPhase::submit(Origin::signed(99), Box::new(raw)),
|
||||
MultiPhase::submit(RuntimeOrigin::signed(99), Box::new(raw)),
|
||||
Error::<Runtime>::SignedTooMuchWeight,
|
||||
);
|
||||
})
|
||||
@@ -998,7 +998,7 @@ mod tests {
|
||||
|
||||
assert_eq!(balances(&123), (0, 0));
|
||||
assert_noop!(
|
||||
MultiPhase::submit(Origin::signed(123), Box::new(solution)),
|
||||
MultiPhase::submit(RuntimeOrigin::signed(123), Box::new(solution)),
|
||||
Error::<Runtime>::SignedCannotPayDeposit,
|
||||
);
|
||||
|
||||
@@ -1020,7 +1020,7 @@ mod tests {
|
||||
score: ElectionScore { minimal_stake: (5 + s).into(), ..Default::default() },
|
||||
..Default::default()
|
||||
};
|
||||
assert_ok!(MultiPhase::submit(Origin::signed(99), Box::new(solution)));
|
||||
assert_ok!(MultiPhase::submit(RuntimeOrigin::signed(99), Box::new(solution)));
|
||||
}
|
||||
|
||||
// this solution has a higher score than any in the queue
|
||||
@@ -1034,7 +1034,7 @@ mod tests {
|
||||
|
||||
assert_eq!(balances(&123), (0, 0));
|
||||
assert_noop!(
|
||||
MultiPhase::submit(Origin::signed(123), Box::new(solution)),
|
||||
MultiPhase::submit(RuntimeOrigin::signed(123), Box::new(solution)),
|
||||
Error::<Runtime>::SignedCannotPayDeposit,
|
||||
);
|
||||
|
||||
@@ -1063,7 +1063,7 @@ mod tests {
|
||||
let solution = raw_solution();
|
||||
|
||||
// submit a correct one.
|
||||
assert_ok!(MultiPhase::submit(Origin::signed(99), Box::new(solution)));
|
||||
assert_ok!(MultiPhase::submit(RuntimeOrigin::signed(99), Box::new(solution)));
|
||||
|
||||
// _some_ good solution was stored.
|
||||
assert!(MultiPhase::finalize_signed_phase());
|
||||
|
||||
@@ -856,7 +856,7 @@ mod tests {
|
||||
use crate::{
|
||||
mock::{
|
||||
roll_to, roll_to_with_ocw, trim_helpers, witness, BlockNumber, ExtBuilder, Extrinsic,
|
||||
MinerMaxWeight, MultiPhase, Origin, Runtime, RuntimeCall as OuterCall, System,
|
||||
MinerMaxWeight, MultiPhase, Runtime, RuntimeCall as OuterCall, RuntimeOrigin, System,
|
||||
TestNposSolution, TrimHelpers, UnsignedPhase,
|
||||
},
|
||||
CurrentPhase, InvalidTransaction, Phase, QueuedSolution, TransactionSource,
|
||||
@@ -1071,7 +1071,7 @@ mod tests {
|
||||
witness: witness(),
|
||||
};
|
||||
let outer_call: OuterCall = call.into();
|
||||
let _ = outer_call.dispatch(Origin::none());
|
||||
let _ = outer_call.dispatch(RuntimeOrigin::none());
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1097,7 +1097,7 @@ mod tests {
|
||||
witness: correct_witness,
|
||||
};
|
||||
let outer_call: OuterCall = call.into();
|
||||
let _ = outer_call.dispatch(Origin::none());
|
||||
let _ = outer_call.dispatch(RuntimeOrigin::none());
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1116,7 +1116,11 @@ mod tests {
|
||||
|
||||
// ensure this solution is valid.
|
||||
assert!(MultiPhase::queued_solution().is_none());
|
||||
assert_ok!(MultiPhase::submit_unsigned(Origin::none(), Box::new(solution), witness));
|
||||
assert_ok!(MultiPhase::submit_unsigned(
|
||||
RuntimeOrigin::none(),
|
||||
Box::new(solution),
|
||||
witness
|
||||
));
|
||||
assert!(MultiPhase::queued_solution().is_some());
|
||||
})
|
||||
}
|
||||
@@ -1215,7 +1219,7 @@ mod tests {
|
||||
let solution = RawSolution { solution: raw, score, round: MultiPhase::round() };
|
||||
assert_ok!(MultiPhase::unsigned_pre_dispatch_checks(&solution));
|
||||
assert_ok!(MultiPhase::submit_unsigned(
|
||||
Origin::none(),
|
||||
RuntimeOrigin::none(),
|
||||
Box::new(solution),
|
||||
witness
|
||||
));
|
||||
@@ -1276,7 +1280,7 @@ mod tests {
|
||||
// and it is fine
|
||||
assert_ok!(MultiPhase::unsigned_pre_dispatch_checks(&solution));
|
||||
assert_ok!(MultiPhase::submit_unsigned(
|
||||
Origin::none(),
|
||||
RuntimeOrigin::none(),
|
||||
Box::new(solution),
|
||||
witness
|
||||
));
|
||||
|
||||
Reference in New Issue
Block a user