Skip to content

Commit

Permalink
Feat: Add race flag to e2e tests
Browse files Browse the repository at this point in the history
Signed-off-by: Emanuel Pargov <[email protected]>
  • Loading branch information
bamzedev committed Aug 11, 2023
1 parent f086701 commit 9de0a56
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 27 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ jobs:

- name: Tests Integration
if: success()
run: go test -tags="e2e" -timeout 9999s -v -coverprofile=e2e.out -covermode=atomic
run: go test -tags="e2e" -timeout 9999s -v -coverprofile=e2e.out -covermode=atomic -race

- name: Tests Testnets
if: success()
Expand Down
34 changes: 8 additions & 26 deletions one_signature_e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,38 +25,20 @@ package hedera

import (
"os"
"sync"
"sync/atomic"
"testing"

"github.com/stretchr/testify/require"
)

type Count struct {
mx *sync.Mutex
count int64
}

func NewCount() *Count {
return &Count{mx: new(sync.Mutex), count: 0}
}
var callCount int64

func (c *Count) Incr() {
c.mx.Lock()
c.count++
c.mx.Unlock()
func incrementCallCount() {
atomic.AddInt64(&callCount, 1)
}

func (c *Count) Count() int64 {
c.mx.Lock()
count := c.count
c.mx.Unlock()
return count
}

var fncCount = NewCount()

func fnc() {
fncCount.Incr()
func getCallCount() int64 {
return atomic.LoadInt64(&callCount)
}

func TestIntegrationOneSignature(t *testing.T) {
Expand All @@ -74,15 +56,15 @@ func TestIntegrationOneSignature(t *testing.T) {
_, err = response.GetReceipt(client)
require.NoError(t, err)

require.Equal(t, int64(1), fncCount.count)
require.Equal(t, int64(1), getCallCount())
client.Close()
err = CloseIntegrationTestEnv(env, nil)
require.NoError(t, err)
}

func signingServiceTwo(txBytes []byte) []byte {
localOperatorPrivateKey, _ := PrivateKeyFromString(os.Getenv("OPERATOR_KEY"))
go fnc()
incrementCallCount()

signature := localOperatorPrivateKey.Sign(txBytes)
return signature
Expand Down

0 comments on commit 9de0a56

Please sign in to comment.