From 285540b84f35f5d526cf3d3004909788a1f06218 Mon Sep 17 00:00:00 2001 From: Madhur Shrimal Date: Wed, 7 Dec 2022 14:48:03 -0800 Subject: [PATCH 1/2] bootstrap balances should be done only for genesis block testing --- pkg/tester/data.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pkg/tester/data.go b/pkg/tester/data.go index 0d8f6033..d3d9f568 100644 --- a/pkg/tester/data.go +++ b/pkg/tester/data.go @@ -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: From 1352eba6bfd72bd57a3e216d215e5a8f54c49927 Mon Sep 17 00:00:00 2001 From: Madhur Shrimal Date: Wed, 7 Dec 2022 15:07:25 -0800 Subject: [PATCH 2/2] add header timeout --- pkg/tester/general.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pkg/tester/general.go b/pkg/tester/general.go index 776070ce..0edc1a3f 100644 --- a/pkg/tester/general.go +++ b/pkg/tester/general.go @@ -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. @@ -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() {