Adjust multiple elections conclusion.#2553
Conversation
Codecov Report
@@ Coverage Diff @@
## master #2553 +/- ##
==========================================
- Coverage 93.67% 93.65% -0.03%
==========================================
Files 45 45
Lines 2626 2630 +4
==========================================
+ Hits 2460 2463 +3
- Misses 166 167 +1 |
| return conn.run( | ||
| conn.collection('elections').replace_one( | ||
| {'height': height}, | ||
| conn.collection('elections').insert_one( |
There was a problem hiding this comment.
I would recommend using replace_one because in an event of a crash the replay won't be successful.
tests/elections/test_election.py
Outdated
|
|
||
| b.store_abci_chain(1, 'chain-X') | ||
| b.store_block(Block(height=1, | ||
| transactions=[tx.to_dict() for tx in txs], |
There was a problem hiding this comment.
transactions in Block only store the transaction ids.
tests/elections/test_election.py
Outdated
| total_votes += votes | ||
|
|
||
| b.store_block(Block(height=1, | ||
| transactions=[tx.to_dict() for tx in txs], |
There was a problem hiding this comment.
transactions in Block only store the transaction ids.
tests/elections/test_election.py
Outdated
|
|
||
| b.store_abci_chain(1, 'chain-X') | ||
| b.store_block(Block(height=1, | ||
| transactions=[tx.to_dict() for tx in txs], |
There was a problem hiding this comment.
transactions in Block only store the transaction ids.
| mock_chain_migration, mock_store_validator = run_approved_elections(b, txns) | ||
| mock_chain_migration.assert_called_once() | ||
| mock_store_validator.assert_called_once() | ||
| def test_approved_elections_concludes_all_elections(b): |
There was a problem hiding this comment.
I would also suggest writing a test wherein the order of validator election and migration witnessed is reversed. This will allow us to assert the rule that a block with validator and migration election concludes both regardless of their order.
There was a problem hiding this comment.
Good point! But I would do it in the next PR where I implement this.
- Do not conclude migration election if there is a migration in progress. - Rewrite election tests to not use mocks and assert many different things. - Record concluded elections in the `election` collection.
0e4c493 to
113065b
Compare
electioncollection.