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

refactor: revise and add tests for exporter/modules/genesis_deposit.go #1354

Open
wants to merge 28 commits into
base: staging
Choose a base branch
from

Conversation

Monika-Bitfly
Copy link
Contributor

No description provided.

@Monika-Bitfly Monika-Bitfly marked this pull request as ready for review February 26, 2025 12:50
Copy link
Contributor

@Tangui-Bitfly Tangui-Bitfly left a comment

Choose a reason for hiding this comment

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

Your tests are taking too long to execute

ok  	github.com/gobitfly/beaconchain/pkg/exporter/modules	71.193s	coverage: 0.7% of statements

It should not be over, let say, 5s (and it's very generous)

client: client,
db: db,
offset: time.Minute,
ctx: context.Background(),
Copy link
Contributor

Choose a reason for hiding this comment

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

ctx should be a param of Export
The usage would be

// in main.go
ctx, cancel := context.WithCancel(context.Background())
go modules.StartAll(ctx, ...)
// wait for something
cancel()

// in backend/pkg/exporter/modules/base.go
func StartAll(ctx context.Context, ...) {
...
	go newGenesisDepositsExporter(context.ConsClient, dbs).Export(ctx)

This a good change but I think it's too soon.

Copy link
Contributor

Choose a reason for hiding this comment

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

In the end this is probably not needed, we have an exit condition on this go routine with

if genesisDepositCount > 0 {
	return
}

type ConsensusDBI interface {
GetLatestEpoch() (uint64, error)
GetDepositsCountForBlockSlot() (uint64, error)
SaveBlockDeposits(validatorIndex uint64, pubkey []byte, withdrawalCredentials []byte, balance uint64) error
Copy link
Contributor

Choose a reason for hiding this comment

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

this should accept types.StandardValidator

Copy link
Contributor Author

Choose a reason for hiding this comment

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

using types.StandardValidator triggers a lint error due to a dependency rule tho

Copy link
Contributor

Choose a reason for hiding this comment

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

Even with this syntax ?

import (
	constypes "github.com/gobitfly/beaconchain/pkg/consapi/types"
)


func (d *ConsensusDB) SaveBlockDeposits(validator constypes.StandardValidator) error {
	...
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah

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