Skip to content

Commit

Permalink
Update cosmwasm version
Browse files Browse the repository at this point in the history
  • Loading branch information
chipshort committed Aug 28, 2023
1 parent e054c74 commit 94b6319
Show file tree
Hide file tree
Showing 5 changed files with 318 additions and 327 deletions.
32 changes: 16 additions & 16 deletions internal/api/lib_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ func TestGetMetrics(t *testing.T) {
require.Equal(t, uint32(0), metrics.HitsMemoryCache)
require.Equal(t, uint32(1), metrics.HitsFsCache)
require.Equal(t, uint64(1), metrics.ElementsMemoryCache)
require.InEpsilon(t, 4075417, metrics.SizeMemoryCache, 0.2)
require.InEpsilon(t, 2282344, metrics.SizeMemoryCache, 0.2)

// Instantiate 2
msg2 := []byte(`{"verifier": "fred", "beneficiary": "susi"}`)
Expand All @@ -273,7 +273,7 @@ func TestGetMetrics(t *testing.T) {
require.Equal(t, uint32(1), metrics.HitsMemoryCache)
require.Equal(t, uint32(1), metrics.HitsFsCache)
require.Equal(t, uint64(1), metrics.ElementsMemoryCache)
require.InEpsilon(t, 4075417, metrics.SizeMemoryCache, 0.2)
require.InEpsilon(t, 2282344, metrics.SizeMemoryCache, 0.2)

// Pin
err = Pin(cache, checksum)
Expand All @@ -282,12 +282,12 @@ func TestGetMetrics(t *testing.T) {
// GetMetrics 5
metrics, err = GetMetrics(cache)
assert.NoError(t, err)
require.Equal(t, uint32(2), metrics.HitsMemoryCache)
require.Equal(t, uint32(1), metrics.HitsFsCache)
require.Equal(t, uint32(1), metrics.HitsMemoryCache)
require.Equal(t, uint32(2), metrics.HitsFsCache)
require.Equal(t, uint64(1), metrics.ElementsPinnedMemoryCache)
require.Equal(t, uint64(1), metrics.ElementsMemoryCache)
require.InEpsilon(t, 4075417, metrics.SizePinnedMemoryCache, 0.2)
require.InEpsilon(t, 4075417, metrics.SizeMemoryCache, 0.2)
require.InEpsilon(t, 2282344, metrics.SizePinnedMemoryCache, 0.2)
require.InEpsilon(t, 2282344, metrics.SizeMemoryCache, 0.2)

// Instantiate 3
msg3 := []byte(`{"verifier": "fred", "beneficiary": "bert"}`)
Expand All @@ -298,12 +298,12 @@ func TestGetMetrics(t *testing.T) {
metrics, err = GetMetrics(cache)
assert.NoError(t, err)
require.Equal(t, uint32(1), metrics.HitsPinnedMemoryCache)
require.Equal(t, uint32(2), metrics.HitsMemoryCache)
require.Equal(t, uint32(1), metrics.HitsFsCache)
require.Equal(t, uint32(1), metrics.HitsMemoryCache)
require.Equal(t, uint32(2), metrics.HitsFsCache)
require.Equal(t, uint64(1), metrics.ElementsPinnedMemoryCache)
require.Equal(t, uint64(1), metrics.ElementsMemoryCache)
require.InEpsilon(t, 4075417, metrics.SizePinnedMemoryCache, 0.2)
require.InEpsilon(t, 4075417, metrics.SizeMemoryCache, 0.2)
require.InEpsilon(t, 2282344, metrics.SizePinnedMemoryCache, 0.2)
require.InEpsilon(t, 2282344, metrics.SizeMemoryCache, 0.2)

// Unpin
err = Unpin(cache, checksum)
Expand All @@ -313,12 +313,12 @@ func TestGetMetrics(t *testing.T) {
metrics, err = GetMetrics(cache)
assert.NoError(t, err)
require.Equal(t, uint32(1), metrics.HitsPinnedMemoryCache)
require.Equal(t, uint32(2), metrics.HitsMemoryCache)
require.Equal(t, uint32(1), metrics.HitsFsCache)
require.Equal(t, uint32(1), metrics.HitsMemoryCache)
require.Equal(t, uint32(2), metrics.HitsFsCache)
require.Equal(t, uint64(0), metrics.ElementsPinnedMemoryCache)
require.Equal(t, uint64(1), metrics.ElementsMemoryCache)
require.Equal(t, uint64(0), metrics.SizePinnedMemoryCache)
require.InEpsilon(t, 4075417, metrics.SizeMemoryCache, 0.2)
require.InEpsilon(t, 2282344, metrics.SizeMemoryCache, 0.2)

// Instantiate 4
msg4 := []byte(`{"verifier": "fred", "beneficiary": "jeff"}`)
Expand All @@ -329,12 +329,12 @@ func TestGetMetrics(t *testing.T) {
metrics, err = GetMetrics(cache)
assert.NoError(t, err)
require.Equal(t, uint32(1), metrics.HitsPinnedMemoryCache)
require.Equal(t, uint32(3), metrics.HitsMemoryCache)
require.Equal(t, uint32(1), metrics.HitsFsCache)
require.Equal(t, uint32(2), metrics.HitsMemoryCache)
require.Equal(t, uint32(2), metrics.HitsFsCache)
require.Equal(t, uint64(0), metrics.ElementsPinnedMemoryCache)
require.Equal(t, uint64(1), metrics.ElementsMemoryCache)
require.Equal(t, uint64(0), metrics.SizePinnedMemoryCache)
require.InEpsilon(t, 4075417, metrics.SizeMemoryCache, 0.2)
require.InEpsilon(t, 2282344, metrics.SizeMemoryCache, 0.2)
}

func TestInstantiate(t *testing.T) {
Expand Down
34 changes: 17 additions & 17 deletions lib_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func TestStoreCode(t *testing.T) {

wasm := []byte{0x00, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00}
_, err := vm.StoreCode(wasm)
require.ErrorContains(t, err, "Error during static Wasm validation: Wasm contract doesn't have a memory section")
require.ErrorContains(t, err, "Error during static Wasm validation: Wasm contract must contain exactly one memory")
}

// No Wasm
Expand Down Expand Up @@ -270,7 +270,7 @@ func TestGetMetrics(t *testing.T) {
require.Equal(t, uint32(0), metrics.HitsMemoryCache)
require.Equal(t, uint32(1), metrics.HitsFsCache)
require.Equal(t, uint64(1), metrics.ElementsMemoryCache)
require.InEpsilon(t, 4075417, metrics.SizeMemoryCache, 0.2)
require.InEpsilon(t, 2282344, metrics.SizeMemoryCache, 0.2)

// Instantiate 2
msg2 := []byte(`{"verifier": "fred", "beneficiary": "susi"}`)
Expand All @@ -284,7 +284,7 @@ func TestGetMetrics(t *testing.T) {
require.Equal(t, uint32(1), metrics.HitsMemoryCache)
require.Equal(t, uint32(1), metrics.HitsFsCache)
require.Equal(t, uint64(1), metrics.ElementsMemoryCache)
require.InEpsilon(t, 4075417, metrics.SizeMemoryCache, 0.2)
require.InEpsilon(t, 2282344, metrics.SizeMemoryCache, 0.2)

// Pin
err = vm.Pin(checksum)
Expand All @@ -293,12 +293,12 @@ func TestGetMetrics(t *testing.T) {
// GetMetrics 5
metrics, err = vm.GetMetrics()
assert.NoError(t, err)
require.Equal(t, uint32(2), metrics.HitsMemoryCache)
require.Equal(t, uint32(1), metrics.HitsFsCache)
require.Equal(t, uint32(1), metrics.HitsMemoryCache)
require.Equal(t, uint32(2), metrics.HitsFsCache)
require.Equal(t, uint64(1), metrics.ElementsPinnedMemoryCache)
require.Equal(t, uint64(1), metrics.ElementsMemoryCache)
require.InEpsilon(t, 4075417, metrics.SizePinnedMemoryCache, 0.2)
require.InEpsilon(t, 4075417, metrics.SizeMemoryCache, 0.2)
require.InEpsilon(t, 2282344, metrics.SizePinnedMemoryCache, 0.2)
require.InEpsilon(t, 2282344, metrics.SizeMemoryCache, 0.2)

// Instantiate 3
msg3 := []byte(`{"verifier": "fred", "beneficiary": "bert"}`)
Expand All @@ -310,12 +310,12 @@ func TestGetMetrics(t *testing.T) {
metrics, err = vm.GetMetrics()
assert.NoError(t, err)
require.Equal(t, uint32(1), metrics.HitsPinnedMemoryCache)
require.Equal(t, uint32(2), metrics.HitsMemoryCache)
require.Equal(t, uint32(1), metrics.HitsFsCache)
require.Equal(t, uint32(1), metrics.HitsMemoryCache)
require.Equal(t, uint32(2), metrics.HitsFsCache)
require.Equal(t, uint64(1), metrics.ElementsPinnedMemoryCache)
require.Equal(t, uint64(1), metrics.ElementsMemoryCache)
require.InEpsilon(t, 4075417, metrics.SizePinnedMemoryCache, 0.2)
require.InEpsilon(t, 4075417, metrics.SizeMemoryCache, 0.2)
require.InEpsilon(t, 2282344, metrics.SizePinnedMemoryCache, 0.2)
require.InEpsilon(t, 2282344, metrics.SizeMemoryCache, 0.2)

// Unpin
err = vm.Unpin(checksum)
Expand All @@ -325,12 +325,12 @@ func TestGetMetrics(t *testing.T) {
metrics, err = vm.GetMetrics()
assert.NoError(t, err)
require.Equal(t, uint32(1), metrics.HitsPinnedMemoryCache)
require.Equal(t, uint32(2), metrics.HitsMemoryCache)
require.Equal(t, uint32(1), metrics.HitsFsCache)
require.Equal(t, uint32(1), metrics.HitsMemoryCache)
require.Equal(t, uint32(2), metrics.HitsFsCache)
require.Equal(t, uint64(0), metrics.ElementsPinnedMemoryCache)
require.Equal(t, uint64(1), metrics.ElementsMemoryCache)
require.Equal(t, uint64(0), metrics.SizePinnedMemoryCache)
require.InEpsilon(t, 4075417, metrics.SizeMemoryCache, 0.2)
require.InEpsilon(t, 2282344, metrics.SizeMemoryCache, 0.2)

// Instantiate 4
msg4 := []byte(`{"verifier": "fred", "beneficiary": "jeff"}`)
Expand All @@ -342,10 +342,10 @@ func TestGetMetrics(t *testing.T) {
metrics, err = vm.GetMetrics()
assert.NoError(t, err)
require.Equal(t, uint32(1), metrics.HitsPinnedMemoryCache)
require.Equal(t, uint32(3), metrics.HitsMemoryCache)
require.Equal(t, uint32(1), metrics.HitsFsCache)
require.Equal(t, uint32(2), metrics.HitsMemoryCache)
require.Equal(t, uint32(2), metrics.HitsFsCache)
require.Equal(t, uint64(0), metrics.ElementsPinnedMemoryCache)
require.Equal(t, uint64(1), metrics.ElementsMemoryCache)
require.Equal(t, uint64(0), metrics.SizePinnedMemoryCache)
require.InEpsilon(t, 4075417, metrics.SizeMemoryCache, 0.2)
require.InEpsilon(t, 2282344, metrics.SizeMemoryCache, 0.2)
}
Loading

0 comments on commit 94b6319

Please sign in to comment.