Skip to content

Commit

Permalink
Lint fix
Browse files Browse the repository at this point in the history
  • Loading branch information
goran-ethernal committed Apr 11, 2024
1 parent 71bd46c commit 29a9191
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 36 deletions.
13 changes: 5 additions & 8 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,7 @@ require (
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce
gopkg.in/yaml.v3 v3.0.1
pgregory.net/rapid v1.1.0
)

require (
github.com/mattn/go-runewidth v0.0.15 // indirect
github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/schollz/progressbar/v3 v3.14.2 // indirect
golang.org/x/term v0.19.0 // indirect
github.com/schollz/progressbar/v3 v3.14.2
)

require (
Expand Down Expand Up @@ -231,4 +224,8 @@ require (
google.golang.org/genproto/googleapis/rpc v0.0.0-20240304161311-37d4d3c04a78 // indirect
gotest.tools/v3 v3.0.2 // indirect
lukechampine.com/blake3 v1.2.1 // indirect
github.com/mattn/go-runewidth v0.0.15 // indirect
github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db // indirect
github.com/rivo/uniseg v0.4.7 // indirect
golang.org/x/term v0.19.0 // indirect
)
48 changes: 27 additions & 21 deletions loadtest/runner/base_load_test_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ import (
"golang.org/x/sync/errgroup"
)

const transactionRetryNum = 5

type feeData struct {
gasPrice *big.Int
gasTipCap *big.Int
Expand Down Expand Up @@ -85,7 +83,11 @@ func (r *BaseLoadTestRunner) createVUs() error {

start := time.Now().UTC()
bar := progressbar.Default(int64(r.cfg.VUs), "Creating virtual users")
defer bar.Close()

defer func() {
_ = bar.Close()
fmt.Println("Creating virtual users took", time.Since(start))

Check failure on line 89 in loadtest/runner/base_load_test_runner.go

View workflow job for this annotation

GitHub Actions / Lint / Run Lint

only cuddled expressions if assigning variable or using from line above (wsl)
}()

for i := 0; i < r.cfg.VUs; i++ {
key, err := crypto.GenerateECDSAKey()
Expand All @@ -94,11 +96,9 @@ func (r *BaseLoadTestRunner) createVUs() error {
}

r.vus = append(r.vus, &account{key: key})
bar.Add(1)
_ = bar.Add(1)
}

fmt.Println("Creating virtual users took", time.Since(start))

return nil
}

Expand All @@ -112,7 +112,11 @@ func (r *BaseLoadTestRunner) fundVUs() error {

start := time.Now().UTC()
bar := progressbar.Default(int64(r.cfg.VUs), "Funding virtual users with native tokens")
defer bar.Close()

defer func() {
_ = bar.Close()
fmt.Println("Funding took", time.Since(start))

Check failure on line 118 in loadtest/runner/base_load_test_runner.go

View workflow job for this annotation

GitHub Actions / Lint / Run Lint

only cuddled expressions if assigning variable or using from line above (wsl)
}()

amountToFund := ethgo.Ether(1000)

Expand Down Expand Up @@ -159,7 +163,7 @@ func (r *BaseLoadTestRunner) fundVUs() error {
return fmt.Errorf("failed to mint ERC20 tokens to %s", vu.key.Address())
}

bar.Add(1)
_ = bar.Add(1)

return nil
}
Expand All @@ -170,8 +174,6 @@ func (r *BaseLoadTestRunner) fundVUs() error {
return err
}

fmt.Println("Funding took", time.Since(start))

return nil
}

Expand Down Expand Up @@ -214,21 +216,24 @@ func (r *BaseLoadTestRunner) waitForTxPoolToEmpty() error {
// a map of block information, transaction statistics, and an error if any.
func (r *BaseLoadTestRunner) waitForReceipts(txHashes []types.Hash) (map[uint64]blockInfo, []txStats) {
fmt.Println("=============================================================")
start := time.Now().UTC()

start := time.Now().UTC()
blockInfoMap := make(map[uint64]blockInfo)
txToBlockMap := make(map[types.Hash]uint64)
txnStats := make([]txStats, 0, len(txHashes))

bar := progressbar.Default(int64(len(txHashes)), "Gathering receipts")
defer bar.Close()

defer func() {
_ = bar.Close()
fmt.Println("Waiting for receipts took", time.Since(start))

Check failure on line 228 in loadtest/runner/base_load_test_runner.go

View workflow job for this annotation

GitHub Actions / Lint / Run Lint

only cuddled expressions if assigning variable or using from line above (wsl)
}()

foundErrors := make([]error, 0)

for _, txHash := range txHashes {
if blockNum, exists := txToBlockMap[txHash]; exists {
txnStats = append(txnStats, txStats{txHash, blockNum})
bar.Add(1)
_ = bar.Add(1)

continue
}
Expand All @@ -241,7 +246,7 @@ func (r *BaseLoadTestRunner) waitForReceipts(txHashes []types.Hash) (map[uint64]
}

txnStats = append(txnStats, txStats{txHash, receipt.BlockNumber})
bar.Add(1)
_ = bar.Add(1)

block, err := r.client.GetBlockByNumber(jsonrpc.BlockNumber(receipt.BlockNumber), true)
if err != nil {
Expand Down Expand Up @@ -271,10 +276,9 @@ func (r *BaseLoadTestRunner) waitForReceipts(txHashes []types.Hash) (map[uint64]
}
}

fmt.Println("Waiting for receipts took", time.Since(start))

if len(foundErrors) > 0 {
fmt.Println("Errors found while waiting for receipts:")

for _, err := range foundErrors {
fmt.Println(err)
}
Expand Down Expand Up @@ -467,9 +471,12 @@ func (r *BaseLoadTestRunner) sendTransactions(
start := time.Now().UTC()
totalTxs := r.cfg.VUs * r.cfg.TxsPerUser
foundErrs := make([]error, 0)

bar := progressbar.Default(int64(totalTxs), "Sending transactions")
defer bar.Close()

defer func() {
_ = bar.Close()
fmt.Println("Sending transactions took", time.Since(start))
}()

allTxnHashes := make([]types.Hash, 0)

Expand Down Expand Up @@ -501,10 +508,9 @@ func (r *BaseLoadTestRunner) sendTransactions(
return nil, err
}

fmt.Println("Sending transactions took", time.Since(start))

if len(foundErrs) > 0 {
fmt.Println("Errors found while sending transactions:")

for _, err := range foundErrs {
fmt.Println(err)
}
Expand Down
2 changes: 1 addition & 1 deletion loadtest/runner/eoa_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ func (e *EOARunner) sendTransactionsForUser(account *account, chainID *big.Int,
}

account.nonce++
bar.Add(1)
_ = bar.Add(1)
}

return txRelayer.GetTxnHashes(), sendErrs, nil
Expand Down
13 changes: 7 additions & 6 deletions loadtest/runner/erc20_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,12 @@ func (e *ERC20Runner) mintERC20TokenToVUs() error {
fmt.Println("=============================================================")

start := time.Now().UTC()

bar := progressbar.Default(int64(e.cfg.VUs), "Minting ERC20 tokens to VUs")
defer bar.Close()

defer func() {
_ = bar.Close()
fmt.Printf("Minting ERC20 tokens took %s\n", time.Since(start))
}()

txRelayer, err := txrelayer.NewTxRelayer(
txrelayer.WithClient(e.client),
Expand Down Expand Up @@ -193,7 +196,7 @@ func (e *ERC20Runner) mintERC20TokenToVUs() error {
return fmt.Errorf("failed to mint ERC20 tokens to %s", vu.key.Address())
}

bar.Add(1)
_ = bar.Add(1)

return nil
}
Expand All @@ -204,8 +207,6 @@ func (e *ERC20Runner) mintERC20TokenToVUs() error {
return err
}

fmt.Printf("Minting ERC20 tokens took %s\n", time.Since(start))

return nil
}

Expand Down Expand Up @@ -280,7 +281,7 @@ func (e *ERC20Runner) sendTransactionsForUser(account *account, chainID *big.Int
}

account.nonce++
bar.Add(1)
_ = bar.Add(1)
}

return txRelayer.GetTxnHashes(), sendErrs, nil
Expand Down
2 changes: 2 additions & 0 deletions loadtest/runner/load_test_runner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ func TestMnemonic(t *testing.T) {
}

func TestLoadRunner(t *testing.T) {
t.Skip("this is only added for the sake of the example and running it in local")

cfg := LoadTestConfig{
Mnemonnic: "code code code code code code code code code code code quality",
LoadTestType: "eoa",
Expand Down

0 comments on commit 29a9191

Please sign in to comment.