Skip to content

Commit

Permalink
Update test contracts
Browse files Browse the repository at this point in the history
  • Loading branch information
webmaster128 committed Nov 19, 2020
1 parent d43e7ba commit 21f2c6b
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions api/lib_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func TestInstantiate(t *testing.T) {
res, cost, err := Instantiate(cache, id, 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(0x113ae), cost)
assert.Equal(t, uint64(0x13860), cost)

var resp types.InitResult
err = json.Unmarshal(res, &resp)
Expand Down Expand Up @@ -123,7 +123,7 @@ func TestHandle(t *testing.T) {
diff := time.Now().Sub(start)
require.NoError(t, err)
requireOkResponse(t, res, 0)
assert.Equal(t, uint64(0x113ae), cost)
assert.Equal(t, uint64(0x13860), cost)
t.Logf("Time (%d gas): %s\n", 0xbb66, diff)

// execute with the same store
Expand All @@ -136,7 +136,7 @@ func TestHandle(t *testing.T) {
res, cost, err = Handle(cache, id, env, info, []byte(`{"release":{}}`), &igasMeter2, store, api, &querier, TESTING_GAS_LIMIT, TESTING_PRINT_DEBUG)
diff = time.Now().Sub(start)
require.NoError(t, err)
assert.Equal(t, uint64(0x1a021), cost)
assert.Equal(t, uint64(0x1d663), cost)
t.Logf("Time (%d gas): %s\n", cost, diff)

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

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

// instance2 controlled by mary
gasMeter2 := NewMockGasMeter(TESTING_GAS_LIMIT)
Expand All @@ -342,14 +342,14 @@ func TestMultipleInstances(t *testing.T) {
res, cost, err = Instantiate(cache, id, 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(0x1134b), cost)
assert.Equal(t, uint64(0x137e1), cost)

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

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

// succeed to execute store2 with mary
resp = exec(t, cache, id, "mary", store2, api, querier, 0x1a021)
resp = exec(t, cache, id, "mary", store2, api, querier, 0x1d663)
require.Equal(t, "", resp.Err)
require.Equal(t, 1, len(resp.Ok.Messages))
attributes = resp.Ok.Attributes
Expand Down
Binary file modified api/testdata/hackatom.wasm
Binary file not shown.
Binary file modified api/testdata/queue.wasm
Binary file not shown.
Binary file modified api/testdata/reflect.wasm
Binary file not shown.

0 comments on commit 21f2c6b

Please sign in to comment.