mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 21:37:56 +00:00
Add try_state check to Pallet MessageQueue (#13502)
* feat: Add try_state for message_queue * Update frame/message-queue/src/lib.rs change if let to while let and modify bump_service_head function Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * feat: update try_state, add checks for storage * fix: add try_state builder for remaining tests * Update frame/message-queue/src/mock.rs Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * chore: assert statement to ensure * Fix tests Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Use ensure instead of assert Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Fix function signature and feature gate Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> * Cleanup code Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> --------- Signed-off-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> Co-authored-by: Oliver Tale-Yazdi <oliver.tale-yazdi@parity.io> Co-authored-by: Juan <juangirini@gmail.com>
This commit is contained in:
@@ -89,7 +89,7 @@ pub fn page<T: Config>(msg: &[u8]) -> PageOf<T> {
|
||||
}
|
||||
|
||||
pub fn single_page_book<T: Config>() -> BookStateOf<T> {
|
||||
BookState { begin: 0, end: 1, count: 1, ..Default::default() }
|
||||
BookState { begin: 0, end: 1, count: 1, message_count: 1, size: 1, ..Default::default() }
|
||||
}
|
||||
|
||||
pub fn empty_book<T: Config>() -> BookStateOf<T> {
|
||||
@@ -139,10 +139,8 @@ pub fn setup_bump_service_head<T: Config>(
|
||||
current: <<T as Config>::MessageProcessor as ProcessMessage>::Origin,
|
||||
next: <<T as Config>::MessageProcessor as ProcessMessage>::Origin,
|
||||
) {
|
||||
let mut book = single_page_book::<T>();
|
||||
book.ready_neighbours = Some(Neighbours::<MessageOriginOf<T>> { prev: next.clone(), next });
|
||||
ServiceHead::<T>::put(¤t);
|
||||
BookStateFor::<T>::insert(¤t, &book);
|
||||
crate::Pallet::<T>::enqueue_message(msg("1"), current);
|
||||
crate::Pallet::<T>::enqueue_message(msg("1"), next);
|
||||
}
|
||||
|
||||
/// Knit a queue into the ready-ring and write it back to storage.
|
||||
@@ -164,11 +162,8 @@ pub fn unknit<T: Config>(o: &<<T as Config>::MessageProcessor as ProcessMessage>
|
||||
pub fn build_ring<T: Config>(
|
||||
queues: &[<<T as Config>::MessageProcessor as ProcessMessage>::Origin],
|
||||
) {
|
||||
for queue in queues {
|
||||
BookStateFor::<T>::insert(queue, empty_book::<T>());
|
||||
}
|
||||
for queue in queues {
|
||||
knit::<T>(queue);
|
||||
for queue in queues.iter() {
|
||||
crate::Pallet::<T>::enqueue_message(msg("1"), queue.clone());
|
||||
}
|
||||
assert_ring::<T>(queues);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user