Skip to content

Prepare Bor package for testing#416

Merged
JekaMas merged 38 commits into
v0.3.0-devfrom
prepare-bor-for-testing
Jun 8, 2022
Merged

Prepare Bor package for testing#416
JekaMas merged 38 commits into
v0.3.0-devfrom
prepare-bor-for-testing

Conversation

@JekaMas

@JekaMas JekaMas commented May 26, 2022

Copy link
Copy Markdown
Contributor

As a developer I'd like to test Bor consensus. However, it is tightly coupled with a few dependancies, so it is hard to test.
This PR extracts dependancies introducing interfaces

@codecov-commenter

codecov-commenter commented May 27, 2022

Copy link
Copy Markdown

Codecov Report

Merging #416 (200d62e) into v0.3.0-dev (2323f2c) will increase coverage by 0.73%.
The diff coverage is 30.08%.

@@              Coverage Diff               @@
##           v0.3.0-dev     #416      +/-   ##
==============================================
+ Coverage       55.74%   56.48%   +0.73%     
==============================================
  Files             601      589      -12     
  Lines           69602    68434    -1168     
==============================================
- Hits            38803    38656     -147     
+ Misses          27447    26465     -982     
+ Partials         3352     3313      -39     
Impacted Files Coverage Δ
consensus/bor/api.go 0.00% <0.00%> (ø)
consensus/bor/bor.go 7.72% <0.00%> (+1.49%) ⬆️
consensus/bor/errors.go 0.00% <0.00%> (ø)
consensus/bor/genesis_contract_mock.go 0.00% <0.00%> (ø)
consensus/bor/merkle.go 0.00% <0.00%> (ø)
consensus/bor/snapshot.go 14.77% <0.00%> (+0.94%) ⬆️
consensus/bor/span_mock.go 0.00% <0.00%> (ø)
consensus/bor/validators_getter_mock.go 0.00% <0.00%> (ø)
core/blockchain_reader.go 43.44% <0.00%> (-3.23%) ⬇️
core/chain_makers.go 68.21% <0.00%> (-1.87%) ⬇️
... and 80 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4ffdbfe...200d62e. Read the comment docs.

@JekaMas JekaMas force-pushed the prepare-bor-for-testing branch from f179c86 to c8f9cd6 Compare May 30, 2022 14:15
@temaniarpit27

Copy link
Copy Markdown
Contributor

@JekaMas can we split this PR somehow?
difficult to review all at once due to the number of files changed

@JekaMas

JekaMas commented May 31, 2022

Copy link
Copy Markdown
Contributor Author

@JekaMas can we split this PR somehow? difficult to review all at once due to the number of files changed

@temaniarpit27 Unfortunately, I can't find the way to split it.
I'd suggest reviewing with focus on features - start with bor package first.

Comment thread Makefile Outdated
Comment thread internal/cli/server/chains/chain_test.go
Comment thread go.mod
Comment thread consensus/bor/set/error.go Outdated
@temaniarpit27

Copy link
Copy Markdown
Contributor

One thing
Can we move all the tests to one place?
snapshot_test and if there are any other test files to tests/bor?

@JekaMas

JekaMas commented May 31, 2022

Copy link
Copy Markdown
Contributor Author

One thing Can we move all the tests to one place? snapshot_test and if there are any other test files to tests/bor?

Why you would like to do it? My arguments to keep things as they are:

  1. To be able to write unit tests to private functions/methods
  2. To make it obvious to what files we have tests (tests are in the same package)
  3. To separate integration and unit level tests
  4. It is common golang practice

@cffls cffls left a comment

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.

Looks good to me overall. My only concern is that with lots of refactoring in this PR, it is not obviously easy to detect problems and bugs by simply reading the code. What testings do you think we could perform to give us more confidence in merging this change?

Comment thread common/set/slice.go
@@ -0,0 +1,11 @@
package set

func New[T comparable](slice []T) map[T]struct{} {

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.

Where is this function used?

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.

Looks good to me overall. My only concern is that with lots of refactoring in this PR, it is not obviously easy to detect problems and bugs by simply reading the code. What testings do you think we could perform to give us more confidence in merging this change?

I believe the only change in bor package is interaction between bor and Heimdall. So we need to test: getting new spans, state sync.

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.

Where is this function used?

Yes, it is being used in TestRandomAddresses

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 believe the only change in bor package is interaction between bor and Heimdall. So we need to test: getting new spans, state sync.

We can create a local devnet to test this out.

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.

It'd be great to test heimdall+bor on devnet. Check that blocks, checkpoints, state sync, spans are there and keep going.

@JekaMas JekaMas Jun 3, 2022

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.

Could you take testing on you? Just basic one. If no errors I believe we can move further with the task and merge it. @cffls

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.

Sure, I will take this up.

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.

@cffls does it looks good to you in the current state?

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.

Yes, the local devnet looks good after using the latest commits.

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.

I believe we can merge it now.

Comment thread consensus/bor/bor.go
@temaniarpit27

Copy link
Copy Markdown
Contributor

Most of it looks fine to me

@JekaMas JekaMas merged commit 9c8bf51 into v0.3.0-dev Jun 8, 2022
@JekaMas JekaMas deleted the prepare-bor-for-testing branch June 8, 2022 13:39
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.

7 participants