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

[fix] bootstrap balances should be done only for genesis block testing #375

Merged
merged 2 commits into from
Dec 8, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion pkg/tester/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,12 @@ func InitializeData(
//
// We need to do this after instantiating the balance storage handler
// because it is invoked within BootstrapBalances.
if len(config.Data.BootstrapBalances) > 0 {
//
// We only need to bootstrap balances when we run this test from
// genesis block. If it is not genesis block, we use the balances from
// previous block
if (config.Data.StartIndex == nil || *config.Data.StartIndex == genesisBlock.Index) &&
len(config.Data.BootstrapBalances) > 0 {
_, err := blockStorage.GetHeadBlockIdentifier(ctx)
switch {
case err == storageErrs.ErrHeadBlockNotFound:
Expand Down
8 changes: 6 additions & 2 deletions pkg/tester/general.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ const (
// MemoryLoggingFrequency is the frequency that memory
// usage stats are logged to the terminal.
MemoryLoggingFrequency = 10 * time.Second

// ReadHeaderTimeout is the header timeout for server
ReadHeaderTimeout = 5 * time.Second
)

// LogMemoryLoop runs a loop that logs memory usage.
Expand Down Expand Up @@ -57,8 +60,9 @@ func StartServer(
port uint,
) error {
server := &http.Server{
Addr: fmt.Sprintf(":%d", port),
Handler: handler,
Addr: fmt.Sprintf(":%d", port),
Handler: handler,
ReadHeaderTimeout: ReadHeaderTimeout,
}

go func() {
Expand Down