mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-18 04:51:01 +00:00
Add try-state hook to pallet aura (#14363)
* Add aura try-state hook * Trigger checks after unit tests
This commit is contained in:
committed by
GitHub
parent
cfe5e8a8df
commit
820949d38f
@@ -19,7 +19,7 @@
|
||||
|
||||
#![cfg(test)]
|
||||
|
||||
use crate::mock::{new_test_ext, Aura, MockDisabledValidators, System};
|
||||
use crate::mock::{build_ext_and_execute_test, Aura, MockDisabledValidators, System};
|
||||
use codec::Encode;
|
||||
use frame_support::traits::OnInitialize;
|
||||
use sp_consensus_aura::{Slot, AURA_ENGINE_ID};
|
||||
@@ -27,7 +27,7 @@ use sp_runtime::{Digest, DigestItem};
|
||||
|
||||
#[test]
|
||||
fn initial_values() {
|
||||
new_test_ext(vec![0, 1, 2, 3]).execute_with(|| {
|
||||
build_ext_and_execute_test(vec![0, 1, 2, 3], || {
|
||||
assert_eq!(Aura::current_slot(), 0u64);
|
||||
assert_eq!(Aura::authorities().len(), 4);
|
||||
});
|
||||
@@ -38,7 +38,7 @@ fn initial_values() {
|
||||
expected = "Validator with index 1 is disabled and should not be attempting to author blocks."
|
||||
)]
|
||||
fn disabled_validators_cannot_author_blocks() {
|
||||
new_test_ext(vec![0, 1, 2, 3]).execute_with(|| {
|
||||
build_ext_and_execute_test(vec![0, 1, 2, 3], || {
|
||||
// slot 1 should be authored by validator at index 1
|
||||
let slot = Slot::from(1);
|
||||
let pre_digest =
|
||||
@@ -58,7 +58,7 @@ fn disabled_validators_cannot_author_blocks() {
|
||||
#[test]
|
||||
#[should_panic(expected = "Slot must increase")]
|
||||
fn pallet_requires_slot_to_increase_unless_allowed() {
|
||||
new_test_ext(vec![0, 1, 2, 3]).execute_with(|| {
|
||||
build_ext_and_execute_test(vec![0, 1, 2, 3], || {
|
||||
crate::mock::AllowMultipleBlocksPerSlot::set(false);
|
||||
|
||||
let slot = Slot::from(1);
|
||||
@@ -76,7 +76,7 @@ fn pallet_requires_slot_to_increase_unless_allowed() {
|
||||
|
||||
#[test]
|
||||
fn pallet_can_allow_unchanged_slot() {
|
||||
new_test_ext(vec![0, 1, 2, 3]).execute_with(|| {
|
||||
build_ext_and_execute_test(vec![0, 1, 2, 3], || {
|
||||
let slot = Slot::from(1);
|
||||
let pre_digest =
|
||||
Digest { logs: vec![DigestItem::PreRuntime(AURA_ENGINE_ID, slot.encode())] };
|
||||
@@ -95,7 +95,7 @@ fn pallet_can_allow_unchanged_slot() {
|
||||
#[test]
|
||||
#[should_panic(expected = "Slot must not decrease")]
|
||||
fn pallet_always_rejects_decreasing_slot() {
|
||||
new_test_ext(vec![0, 1, 2, 3]).execute_with(|| {
|
||||
build_ext_and_execute_test(vec![0, 1, 2, 3], || {
|
||||
let slot = Slot::from(2);
|
||||
let pre_digest =
|
||||
Digest { logs: vec![DigestItem::PreRuntime(AURA_ENGINE_ID, slot.encode())] };
|
||||
|
||||
Reference in New Issue
Block a user