Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Fix test for Substrate#9898 #9907

Merged
merged 1 commit into from
Oct 1, 2021

Conversation

emostov
Copy link
Contributor

@emostov emostov commented Oct 1, 2021

target branch: kiz-improve-ocw-resubmit
target pr: #9898

Prior to #9898, the election OCW cleared its cached solution whenever it saw events from do_elect. Now, the election OCW only clears its solution when run on the first block of the unsigned phase. In this PR the relevant test is updated to try and document the change.

roll_to(25);
assert_eq!(MultiPhase::current_phase(), Phase::Unsigned((true, 25)));
const BLOCK: u64 = 25;
let block_plus = |delta: u64| BLOCK + delta;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is an idiom taken from the other tests in this file

// we must clear the offchain storage to ensure the offchain execution check doesn't get
// in the way.
let mut storage = StorageValueRef::persistent(&OFFCHAIN_LAST_BLOCK);
storage.clear();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

clearing the storage here appears to be irrelevant because it starts out empty

Copy link
Contributor

Choose a reason for hiding this comment

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

I actually always thought it to be an overkill and wanted to remove it :p

// we don't actually care about the result of the election
roll_to(26);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

afaict every call to roll_to after the first is not relevant to the test

Copy link
Contributor

@kianenigma kianenigma left a comment

Choose a reason for hiding this comment

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

thanks!

@emostov emostov merged commit 32b69da into kiz-improve-ocw-resubmit Oct 1, 2021
@emostov emostov deleted the zeke-kiz-improve-ocw-resubmit branch October 1, 2021 06:11
ghost pushed a commit that referenced this pull request Oct 5, 2021
* dont read events in elections anymore.

* Update frame/election-provider-multi-phase/src/lib.rs

* Fix test for Substrate#9898 (#9907)

Co-authored-by: Shawn Tabrizi <shawntabrizi@gmail.com>
Co-authored-by: Zeke Mostov <32168567+emostov@users.noreply.github.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants