Skip to content

Commit

Permalink
Use hackatom with migrate_version
Browse files Browse the repository at this point in the history
  • Loading branch information
chipshort committed Jun 4, 2024
1 parent 7b8338b commit 3a16ee7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion ibc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ func TestAnalyzeCode(t *testing.T) {
require.NoError(t, err)
require.False(t, report.HasIBCEntryPoints)
require.Equal(t, "", report.RequiredCapabilities)
require.Nil(t, report.ContractMigrateVersion)
require.Equal(t, uint64(42), *report.ContractMigrateVersion)

// Store IBC contract
wasm2, err := os.ReadFile(IBC_TEST_CONTRACT)
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 @@ -405,7 +405,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(0x5088ea), cost.UsedInternally)
assert.Equal(t, uint64(0x540eb6), cost.UsedInternally)

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

// execute with the same store
Expand All @@ -449,7 +449,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(0x8be9c6), cost.UsedInternally)
assert.Equal(t, uint64(0x975216), 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 @@ -557,7 +557,7 @@ func TestExecuteCpuLoop(t *testing.T) {
diff := time.Since(start)
require.NoError(t, err)
requireOkResponse(t, res, 0)
assert.Equal(t, uint64(0x365a42), cost.UsedInternally)
assert.Equal(t, uint64(0x3d997e), cost.UsedInternally)
t.Logf("Time (%d gas): %s\n", cost.UsedInternally, diff)

// execute a cpu loop
Expand Down Expand Up @@ -786,7 +786,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(0x4ffce0), cost.UsedInternally)
assert.Equal(t, uint64(0x53541c), cost.UsedInternally)

// instance2 controlled by mary
gasMeter2 := NewMockGasMeter(TESTING_GAS_LIMIT)
Expand All @@ -797,14 +797,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(0x504dbc), cost.UsedInternally)
assert.Equal(t, uint64(0x53bbb4), cost.UsedInternally)

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

// succeed to execute store1 with fred
resp = exec(t, cache, checksum, "fred", store1, api, querier, 0x8ba826)
resp = exec(t, cache, checksum, "fred", store1, api, querier, 0x970662)
require.Equal(t, "", resp.Err)
require.Equal(t, 1, len(resp.Ok.Messages))
attributes := resp.Ok.Attributes
Expand All @@ -813,7 +813,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, 0x8bc8f6)
resp = exec(t, cache, checksum, "mary", store2, api, querier, 0x972c3c)
require.Equal(t, "", resp.Err)
require.Equal(t, 1, len(resp.Ok.Messages))
attributes = resp.Ok.Attributes
Expand Down
Binary file modified testdata/hackatom.wasm
Binary file not shown.

0 comments on commit 3a16ee7

Please sign in to comment.