Skip to content

Adjust multiple elections conclusion.#2553

Merged
kansi merged 1 commit intobigchaindb:masterfrom
ldmberman:coclude-multiple-elections-adjustments
Sep 18, 2018
Merged

Adjust multiple elections conclusion.#2553
kansi merged 1 commit intobigchaindb:masterfrom
ldmberman:coclude-multiple-elections-adjustments

Conversation

@ldmberman
Copy link
Copy Markdown
Contributor

  • 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.

@ldmberman ldmberman requested review from kansi and z-bowen September 18, 2018 09:22
@codecov-io
Copy link
Copy Markdown

Codecov Report

Merging #2553 into master will decrease coverage by 0.02%.
The diff coverage is 94.73%.

@@            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(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I would recommend using replace_one because in an event of a crash the replay won't be successful.


b.store_abci_chain(1, 'chain-X')
b.store_block(Block(height=1,
transactions=[tx.to_dict() for tx in txs],
Copy link
Copy Markdown
Contributor

@kansi kansi Sep 18, 2018

Choose a reason for hiding this comment

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

transactions in Block only store the transaction ids.

total_votes += votes

b.store_block(Block(height=1,
transactions=[tx.to_dict() for tx in txs],
Copy link
Copy Markdown
Contributor

@kansi kansi Sep 18, 2018

Choose a reason for hiding this comment

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

transactions in Block only store the transaction ids.


b.store_abci_chain(1, 'chain-X')
b.store_block(Block(height=1,
transactions=[tx.to_dict() for tx in txs],
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.
@ldmberman ldmberman force-pushed the coclude-multiple-elections-adjustments branch from 0e4c493 to 113065b Compare September 18, 2018 10:23
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.

3 participants