Skip to content

Commit

Permalink
resolve issues with goroutine
Browse files Browse the repository at this point in the history
  • Loading branch information
faddat committed Dec 22, 2024
1 parent 1921179 commit f8005f8
Showing 1 changed file with 20 additions and 9 deletions.
29 changes: 20 additions & 9 deletions internal/api/lib_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -845,22 +845,33 @@ func Benchmark100ConcurrentContractCalls(b *testing.B) {
b.ResetTimer()
for n := 0; n < b.N; n++ {
var wg sync.WaitGroup
errChan := make(chan error, callCount)
resChan := make(chan []byte, callCount)
wg.Add(callCount)
testMutex.Lock()
info = MockInfoBin(b, "fred")
testMutex.Unlock()
for i := 0; i < callCount; i++ {
go func() {
defer wg.Done()
gasMeter2 := NewMockGasMeter(TESTING_GAS_LIMIT)
igasMeter2 := types.GasMeter(gasMeter2)
store.SetGasMeter(gasMeter2)
info = MockInfoBin(b, "fred")
msg := []byte(`{"allocate_large_memory":{"pages":0}}`) // replace with noop once we have it
res, _, err = Execute(cache, checksum, env, info, msg, &igasMeter2, store, api, &querier, TESTING_GAS_LIMIT, TESTING_PRINT_DEBUG)
require.NoError(b, err)
requireOkResponse(b, res, 0)

wg.Done()
errChan <- err
resChan <- res
}()
}
wg.Wait()
close(errChan)
close(resChan)

// Now check results in the main test goroutine
for i := 0; i < callCount; i++ {
require.NoError(b, <-errChan)
requireOkResponse(b, <-resChan, 0)
}
}
}

Expand Down Expand Up @@ -1312,10 +1323,6 @@ func TestCustomReflectQuerier(t *testing.T) {
// https://github.com/CosmWasm/cosmwasm/blob/v0.11.0-alpha3/contracts/reflect/src/msg.rs#L18-L28
}

type CapitalizedResponse struct {
Text string `json:"text"`
}

cache, cleanup := withCache(t)
defer cleanup()
checksum := createReflectContract(t, cache)
Expand Down Expand Up @@ -1354,6 +1361,10 @@ func TestCustomReflectQuerier(t *testing.T) {
require.Equal(t, "SMALL FRYS :)", response.Text)
}

type CapitalizedResponse struct {
Text string `json:"text"`
}

// TestFloats is a port of the float_instrs_are_deterministic test in cosmwasm-vm
func TestFloats(t *testing.T) {
type Value struct {
Expand Down

0 comments on commit f8005f8

Please sign in to comment.