Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes all tests and removes a few nits #6595

Merged
merged 1 commit into from
Nov 21, 2024

Conversation

gpestana
Copy link
Contributor

No description provided.

@gpestana gpestana requested a review from a team as a code owner November 21, 2024 16:16
@@ -128,10 +128,6 @@ pub use types::*;

pub use crate::{unsigned::miner, verifier::Verifier, weights::WeightInfo};

/// Internal crate re-exports to use across benchmarking and tests.
#[cfg(any(test, feature = "runtime-benchmarks"))]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not really needed anymore.

@@ -291,7 +291,7 @@ pub struct ExtBuilder {

impl Default for ExtBuilder {
fn default() -> Self {
Self { core_try_state: true, signed_try_state: true, minimum_score: Some(Default::default()) }
Self { core_try_state: true, signed_try_state: true, minimum_score: None }
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so that the default Election score passes, simplifies tests

@@ -438,6 +438,7 @@ impl ExtBuilder {

pub(crate) fn build_and_execute(self, test: impl FnOnce() -> ()) {
let mut ext = self.build();
ext.execute_with(|| roll_one());
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

starts by rolling one block so that the System events are initialized. Otherwise they won't be catched and don't show up in the tests.

@@ -281,7 +276,7 @@ mod calls {

assert_err!(
SignedPallet::register(RuntimeOrigin::signed(account_id), Default::default()),
NotAcceptingSubmissions::<Runtime>,
Error::<T>::NotAcceptingSubmissions
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

easier to read

}

#[test]
fn force_clear_submission_fails_if_called_by_account_none() {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really relevant.

);
})
}

#[test]
fn force_clear_submission_fails_if_called_in_phase_other_than_off() {
ExtBuilder::default().build_and_execute(|| {
let some_bn = 0;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doesn't need to be a separate variable, otherwise the developer will think this is important value to the tests.

}

#[test]
fn force_clear_submission_removes_both_metadata_and_submission_pages() {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a test that covers all these cases, so we can drop this one.

@@ -273,51 +273,6 @@ mod miner {
});
}

#[test]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not very relevant, we should test the case that the signed/unsigned phases pass without a solution and that's it.

/// A verificaction failed at the given page.
VerificationFailed(PageIndex, FeasibilityError),
VerificationFailed { page: PageIndex, error: FeasibilityError },
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just a refactor needed from the base PR

@@ -535,17 +538,8 @@ mod hooks {
use frame_support::traits::Hooks;

#[test]
fn on_initialize_status_nothing_returns_default_value() {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not very relevant.

@paritytech-workflow-stopper
Copy link

All GitHub workflows were cancelled due to failure one of the required jobs.
Failed workflow url: https://github.com/paritytech/polkadot-sdk/actions/runs/11957272821
Failed job name: test-linux-stable

@paritytech-workflow-stopper
Copy link

All GitHub workflows were cancelled due to failure one of the required jobs.
Failed workflow url: https://github.com/paritytech/polkadot-sdk/actions/runs/11957272808
Failed job name: test-doc

@gpestana gpestana merged commit d0252be into zebedeusz/pallet-epm-mb-unit-tests Nov 21, 2024
73 of 154 checks passed
@gpestana gpestana deleted the gpestana/fixes-tests branch November 21, 2024 16:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants