Skip to content

Commit

Permalink
[fix] bootstrap balances should be done only for genesis block testing (
Browse files Browse the repository at this point in the history
#375)

* bootstrap balances should be done only for genesis block testing

* add header timeout
  • Loading branch information
shrimalmadhur authored Dec 8, 2022
1 parent 085f95c commit 11cc4ab
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
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

0 comments on commit 11cc4ab

Please sign in to comment.