Skip to content

Commit

Permalink
Wait for all goroutines to exit in test
Browse files Browse the repository at this point in the history
  • Loading branch information
kidambisrinivas committed Sep 30, 2024
1 parent 9b6d66b commit ecd045e
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"testing"
"time"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/require"

Expand Down Expand Up @@ -61,10 +62,13 @@ func TestLogEventTriggerEVMHappyPath(t *testing.T) {
expectedLogVal := int64(10)

// Send a blockchain transaction that emits logs
done := make(chan struct{})
t.Cleanup(func() { <-done })
go func() {
defer close(done)
_, err =
th.LogEmitterContract.EmitLog1(th.BackendTH.ContractsOwner, []*big.Int{big.NewInt(expectedLogVal)})
require.NoError(t, err)
assert.NoError(t, err)
th.BackendTH.Backend.Commit()
th.BackendTH.Backend.Commit()
th.BackendTH.Backend.Commit()
Expand Down

0 comments on commit ecd045e

Please sign in to comment.