Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
chipshort committed Sep 23, 2024
1 parent e0be4c5 commit de10592
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 = 2 * TESTING_GAS_LIMIT
gasLimit = 3 * 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 * 7
gasLimit = TESTING_GAS_LIMIT * 8
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(0x252528f74), cost.UsedInternally)
assert.Equal(t, uint64(0x2d4998b04), 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(0x252528f74), cost.UsedInternally)
assert.Equal(t, uint64(0x2d4998b04), 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(0x3ffe1e058), cost.UsedInternally)
assert.Equal(t, uint64(0x4f2816338), 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(0x18a753768), cost.UsedInternally)
assert.Equal(t, uint64(0x1dc65a058), 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(0x24e474064), cost.UsedInternally)
assert.Equal(t, uint64(0x2cfaf612c), 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(0x250a66614), cost.UsedInternally)
assert.Equal(t, uint64(0x2d2895c2c), cost.UsedInternally)

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

// succeed to execute store1 with fred
resp = exec(t, cache, checksum, "fred", store1, api, querier, 0x3fe0b99b8)
resp = exec(t, cache, checksum, "fred", store1, api, querier, 0x4f07d7ce8)
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, 0x3fef6bd08)
resp = exec(t, cache, checksum, "mary", store2, api, querier, 0x4f17f7010)
require.Equal(t, "", resp.Err)
require.Equal(t, 1, len(resp.Ok.Messages))
attributes = resp.Ok.Attributes
Expand Down

0 comments on commit de10592

Please sign in to comment.