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

Add initial test checking progress #94

Merged
merged 2 commits into from
Aug 18, 2022
Merged

Conversation

KonradStaniec
Copy link
Contributor

Check epoch progressing.

@SebastianElvis does I understand correctly how epoching works here i.e
block 0 is epoch 0
block 1-10 are epoch 1
block 11 - 20 will be epoch ?

@SebastianElvis
Copy link
Member

@SebastianElvis does I understand correctly how epoching works here i.e
block 0 is epoch 0
block 1-10 are epoch 1
block 11 - 20 will be epoch ?

Yeah your understanding is correct -- block 0 is the only block in epoch 0, and block x to x+interval-1 belongs to epoch x. I had some documentation in https://github.com/babylonchain/babylon/blob/main/x/epoching/keeper/epochs.go and tests in https://github.com/babylonchain/babylon/blob/main/x/epoching/keeper/epochs_test.go

Copy link
Member

@SebastianElvis SebastianElvis left a comment

Choose a reason for hiding this comment

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

Nice work! Just left some minor comments and no blockers from my side.

A question that is less relevant to this PR: I remember some CI environments do not allow the program to use networks (e.g., binding ports). Will this be a problem if we include such tests in CI?

return
}

<-time.After(2 * time.Second)
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps consider using the ticker package for polling? something like https://blog.boot.dev/golang/range-over-ticker-in-go-with-immediate-first-tick/

Copy link
Contributor Author

Choose a reason for hiding this comment

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

tbh for now I would like to keep this as simple and dependency free as possible, this tests will definitly grow in complexity over time

latestResponse, err := tm.NewServiceClient(c).GetLatestBlock(context.Background(), &tm.GetLatestBlockRequest{})

if err != nil {
panic("Integration tests failed, due to node failure")
Copy link
Member

Choose a reason for hiding this comment

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

Would it be helpful to attach the error message in panic?

@@ -13,7 +13,9 @@ import (
appparams "github.com/babylonchain/babylon/app/params"
bbl "github.com/babylonchain/babylon/types"
lightclient "github.com/babylonchain/babylon/x/btclightclient/types"
ec "github.com/babylonchain/babylon/x/epoching/types"
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
ec "github.com/babylonchain/babylon/x/epoching/types"
epochingtypes "github.com/babylonchain/babylon/x/epoching/types"

Nothing but would be good to have some consistency with other code.

@@ -13,7 +13,9 @@ import (
appparams "github.com/babylonchain/babylon/app/params"
bbl "github.com/babylonchain/babylon/types"
Copy link
Member

Choose a reason for hiding this comment

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

I remember @fishermanymc mentioned that bbn will be more widely accepted than bbl.

currentEpochResponse, err := epochingClient.CurrentEpoch(context.Background(), &ec.QueryCurrentEpochRequest{})

if err != nil {
panic("Querry failed, testnet not running")
Copy link
Member

Choose a reason for hiding this comment

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

Same, not sure if attaching the error msg for debugging would be helpful

@KonradStaniec KonradStaniec merged commit 648b804 into main Aug 18, 2022
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