Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
chipshort committed Aug 8, 2024
1 parent cb00566 commit 6d4e359
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions internal/api/iterator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ func TestQueueIteratorLimit(t *testing.T) {
var gasLimit uint64

// Open 5000 iterators
gasLimit = TESTING_GAS_LIMIT
gasLimit = 2 * TESTING_GAS_LIMIT
gasMeter := NewMockGasMeter(gasLimit)
igasMeter := types.GasMeter(gasMeter)
store := setup.Store(gasMeter)
Expand All @@ -279,7 +279,7 @@ func TestQueueIteratorLimit(t *testing.T) {
require.Equal(t, `{}`, string(qres.Ok))

// Open 35000 iterators
gasLimit = TESTING_GAS_LIMIT * 4
gasLimit = TESTING_GAS_LIMIT * 7
gasMeter = NewMockGasMeter(gasLimit)
igasMeter = types.GasMeter(gasMeter)
store = setup.Store(gasMeter)
Expand Down
18 changes: 9 additions & 9 deletions internal/api/lib_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ func TestInstantiate(t *testing.T) {
res, cost, err := Instantiate(cache, checksum, env, info, msg, &igasMeter, store, api, &querier, TESTING_GAS_LIMIT, TESTING_PRINT_DEBUG)
require.NoError(t, err)
requireOkResponse(t, res, 0)
assert.Equal(t, uint64(0x13a78a36c), cost.UsedInternally)
assert.Equal(t, uint64(0x252528f74), cost.UsedInternally)

var result types.ContractResult
err = json.Unmarshal(res, &result)
Expand Down Expand Up @@ -394,7 +394,7 @@ func TestExecute(t *testing.T) {
diff := time.Since(start)
require.NoError(t, err)
requireOkResponse(t, res, 0)
assert.Equal(t, uint64(0x13a78a36c), cost.UsedInternally)
assert.Equal(t, uint64(0x252528f74), cost.UsedInternally)
t.Logf("Time (%d gas): %s\n", cost.UsedInternally, diff)

// execute with the same store
Expand All @@ -407,7 +407,7 @@ func TestExecute(t *testing.T) {
res, cost, err = Execute(cache, checksum, env, info, []byte(`{"release":{}}`), &igasMeter2, store, api, &querier, TESTING_GAS_LIMIT, TESTING_PRINT_DEBUG)
diff = time.Since(start)
require.NoError(t, err)
assert.Equal(t, uint64(0x222892d70), cost.UsedInternally)
assert.Equal(t, uint64(0x3ffe1e058), cost.UsedInternally)
t.Logf("Time (%d gas): %s\n", cost.UsedInternally, diff)

// make sure it read the balance properly and we got 250 atoms
Expand Down Expand Up @@ -515,7 +515,7 @@ func TestExecuteCpuLoop(t *testing.T) {
diff := time.Since(start)
require.NoError(t, err)
requireOkResponse(t, res, 0)
assert.Equal(t, uint64(0xd45091d0), cost.UsedInternally)
assert.Equal(t, uint64(0x18a753768), cost.UsedInternally)
t.Logf("Time (%d gas): %s\n", cost.UsedInternally, diff)

// execute a cpu loop
Expand Down Expand Up @@ -666,7 +666,7 @@ func TestMultipleInstances(t *testing.T) {
require.NoError(t, err)
requireOkResponse(t, res, 0)
// we now count wasm gas charges and db writes
assert.Equal(t, uint64(0x138559c5c), cost.UsedInternally)
assert.Equal(t, uint64(0x24e474064), cost.UsedInternally)

// instance2 controlled by mary
gasMeter2 := NewMockGasMeter(TESTING_GAS_LIMIT)
Expand All @@ -677,14 +677,14 @@ func TestMultipleInstances(t *testing.T) {
res, cost, err = Instantiate(cache, checksum, env, info, msg, &igasMeter2, store2, api, &querier, TESTING_GAS_LIMIT, TESTING_PRINT_DEBUG)
require.NoError(t, err)
requireOkResponse(t, res, 0)
assert.Equal(t, uint64(0x1399177bc), cost.UsedInternally)
assert.Equal(t, uint64(0x250a66614), cost.UsedInternally)

// fail to execute store1 with mary
resp := exec(t, cache, checksum, "mary", store1, api, querier, 0x1218ff5d0)
resp := exec(t, cache, checksum, "mary", store1, api, querier, 0x220d6e990)
require.Equal(t, "Unauthorized", resp.Err)

// succeed to execute store1 with fred
resp = exec(t, cache, checksum, "fred", store1, api, querier, 0x22188d470)
resp = exec(t, cache, checksum, "fred", store1, api, querier, 0x3fe0b99b8)
require.Equal(t, "", resp.Err)
require.Equal(t, 1, len(resp.Ok.Messages))
attributes := resp.Ok.Attributes
Expand All @@ -693,7 +693,7 @@ func TestMultipleInstances(t *testing.T) {
require.Equal(t, "bob", attributes[1].Value)

// succeed to execute store2 with mary
resp = exec(t, cache, checksum, "mary", store2, api, querier, 0x2220900f0)
resp = exec(t, cache, checksum, "mary", store2, api, querier, 0x3fef6bd08)
require.Equal(t, "", resp.Err)
require.Equal(t, 1, len(resp.Ok.Messages))
attributes = resp.Ok.Attributes
Expand Down

0 comments on commit 6d4e359

Please sign in to comment.