Skip to content

Commit

Permalink
async loadgen
Browse files Browse the repository at this point in the history
  • Loading branch information
anirudhwarrier committed Dec 21, 2023
1 parent c5c4db5 commit 428b650
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions integration-tests/load/automationv2_1/gun.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package automationv2_1

import (
"math/big"
"sync"

"github.com/rs/zerolog"
"github.com/smartcontractkit/wasp"
Expand Down Expand Up @@ -45,7 +46,6 @@ func NewLogTriggerUser(
evmClient blockchain.EVMClient,
multicallAddress string,
) *LogTriggerGun {

var data1, data2, data3 [][]byte
var addresses []string

Expand Down Expand Up @@ -82,7 +82,7 @@ func NewLogTriggerUser(
}

func (m *LogTriggerGun) Call(_ *wasp.Generator) *wasp.Response {

var wg sync.WaitGroup
for _, d := range m.data {
var dividedData [][][]byte
chunkSize := 100
Expand All @@ -93,14 +93,18 @@ func (m *LogTriggerGun) Call(_ *wasp.Generator) *wasp.Response {
}
dividedData = append(dividedData, d[i:end])
}

for _, a := range dividedData {
_, err := contracts.MultiCallLogTriggerLoadGen(m.evmClient, m.multiCallAddress, m.addresses, a)
if err != nil {
return &wasp.Response{Error: err.Error(), Failed: true}
}
wg.Add(1)
go func(a [][]byte, m *LogTriggerGun) *wasp.Response {
defer wg.Done()
_, err := contracts.MultiCallLogTriggerLoadGen(m.evmClient, m.multiCallAddress, m.addresses, a)
if err != nil {
return &wasp.Response{Error: err.Error(), Failed: true}
}
return &wasp.Response{}
}(a, m)
}
}

wg.Wait()
return &wasp.Response{}
}

0 comments on commit 428b650

Please sign in to comment.