Skip to content

Commit

Permalink
Merge pull request #347 from CosmWasm/upgrade-to-1.1
Browse files Browse the repository at this point in the history
Upgrade to CosmWasm to 1.1
  • Loading branch information
Expotential108 committed Sep 6, 2022
2 parents ca89d7a + b96bd27 commit 9c71cfb
Show file tree
Hide file tree
Showing 12 changed files with 310 additions and 171 deletions.
2 changes: 2 additions & 0 deletions ibc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,7 @@ func TestAnalyzeCode(t *testing.T) {
require.NoError(t, err)
require.False(t, report.HasIBCEntryPoints)
require.Equal(t, "", report.RequiredFeatures)
require.Equal(t, "", report.RequiredCapabilities)

// Store IBC contract
wasm2, err := ioutil.ReadFile(IBC_TEST_CONTRACT)
Expand All @@ -295,6 +296,7 @@ func TestAnalyzeCode(t *testing.T) {
require.NoError(t, err)
require.True(t, report2.HasIBCEntryPoints)
require.Equal(t, "iterator,stargate", report2.RequiredFeatures)
require.Equal(t, "iterator,stargate", report2.RequiredCapabilities)
}

func TestIBCMsgGetChannel(t *testing.T) {
Expand Down
8 changes: 4 additions & 4 deletions internal/api/bindings.h
Original file line number Diff line number Diff line change
Expand Up @@ -196,17 +196,17 @@ typedef struct UnmanagedVector {
/**
* The result type of the FFI function analyze_code.
*
* Please note that the unmanaged vector in `required_features`
* Please note that the unmanaged vector in `required_capabilities`
* has to be destroyed exactly once. When calling `analyze_code`
* from Go this is done via `C.destroy_unmanaged_vector`.
*/
typedef struct AnalysisReport {
bool has_ibc_entry_points;
/**
* An UTF-8 encoded comma separated list of reqired features.
* An UTF-8 encoded comma separated list of reqired capabilities.
* This is never None/nil.
*/
struct UnmanagedVector required_features;
struct UnmanagedVector required_capabilities;
} AnalysisReport;

typedef struct Metrics {
Expand Down Expand Up @@ -304,7 +304,7 @@ typedef struct GoQuerier {
} GoQuerier;

struct cache_t *init_cache(struct ByteSliceView data_dir,
struct ByteSliceView supported_features,
struct ByteSliceView available_capabilities,
uint32_t cache_size,
uint32_t instance_memory_limit,
struct UnmanagedVector *error_msg);
Expand Down
6 changes: 4 additions & 2 deletions internal/api/lib.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,11 @@ func AnalyzeCode(cache Cache, checksum []byte) (*types.AnalysisReport, error) {
if err != nil {
return nil, errorWithMessage(err, errmsg)
}
requiredCapabilities := string(copyAndDestroyUnmanagedVector(report.required_capabilities))
res := types.AnalysisReport{
HasIBCEntryPoints: bool(report.has_ibc_entry_points),
RequiredFeatures: string(copyAndDestroyUnmanagedVector(report.required_features)),
HasIBCEntryPoints: bool(report.has_ibc_entry_points),
RequiredFeatures: requiredCapabilities,
RequiredCapabilities: requiredCapabilities,
}
return &res, nil
}
Expand Down
16 changes: 8 additions & 8 deletions internal/api/lib_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ func TestGetMetrics(t *testing.T) {
assert.Equal(t, &types.Metrics{
HitsFsCache: 1,
ElementsMemoryCache: 1,
SizeMemoryCache: 5665691,
SizeMemoryCache: 5602873,
}, metrics)

// Instantiate 2
Expand All @@ -216,7 +216,7 @@ func TestGetMetrics(t *testing.T) {
HitsMemoryCache: 1,
HitsFsCache: 1,
ElementsMemoryCache: 1,
SizeMemoryCache: 5665691,
SizeMemoryCache: 5602873,
}, metrics)

// Pin
Expand All @@ -231,8 +231,8 @@ func TestGetMetrics(t *testing.T) {
HitsFsCache: 1,
ElementsPinnedMemoryCache: 1,
ElementsMemoryCache: 1,
SizePinnedMemoryCache: 5665691,
SizeMemoryCache: 5665691,
SizePinnedMemoryCache: 5602873,
SizeMemoryCache: 5602873,
}, metrics)

// Instantiate 3
Expand All @@ -249,8 +249,8 @@ func TestGetMetrics(t *testing.T) {
HitsFsCache: 1,
ElementsPinnedMemoryCache: 1,
ElementsMemoryCache: 1,
SizePinnedMemoryCache: 5665691,
SizeMemoryCache: 5665691,
SizePinnedMemoryCache: 5602873,
SizeMemoryCache: 5602873,
}, metrics)

// Unpin
Expand All @@ -267,7 +267,7 @@ func TestGetMetrics(t *testing.T) {
ElementsPinnedMemoryCache: 0,
ElementsMemoryCache: 1,
SizePinnedMemoryCache: 0,
SizeMemoryCache: 5665691,
SizeMemoryCache: 5602873,
}, metrics)

// Instantiate 4
Expand All @@ -285,7 +285,7 @@ func TestGetMetrics(t *testing.T) {
ElementsPinnedMemoryCache: 0,
ElementsMemoryCache: 1,
SizePinnedMemoryCache: 0,
SizeMemoryCache: 5665691,
SizeMemoryCache: 5602873,
}, metrics)
}

Expand Down
16 changes: 8 additions & 8 deletions lib_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ func TestGetMetrics(t *testing.T) {
assert.Equal(t, &types.Metrics{
HitsFsCache: 1,
ElementsMemoryCache: 1,
SizeMemoryCache: 5665691,
SizeMemoryCache: 5602873,
}, metrics)

// Instantiate 2
Expand All @@ -214,7 +214,7 @@ func TestGetMetrics(t *testing.T) {
HitsMemoryCache: 1,
HitsFsCache: 1,
ElementsMemoryCache: 1,
SizeMemoryCache: 5665691,
SizeMemoryCache: 5602873,
}, metrics)

// Pin
Expand All @@ -229,8 +229,8 @@ func TestGetMetrics(t *testing.T) {
HitsFsCache: 1,
ElementsPinnedMemoryCache: 1,
ElementsMemoryCache: 1,
SizePinnedMemoryCache: 5665691,
SizeMemoryCache: 5665691,
SizePinnedMemoryCache: 5602873,
SizeMemoryCache: 5602873,
}, metrics)

// Instantiate 3
Expand All @@ -248,8 +248,8 @@ func TestGetMetrics(t *testing.T) {
HitsFsCache: 1,
ElementsPinnedMemoryCache: 1,
ElementsMemoryCache: 1,
SizePinnedMemoryCache: 5665691,
SizeMemoryCache: 5665691,
SizePinnedMemoryCache: 5602873,
SizeMemoryCache: 5602873,
}, metrics)

// Unpin
Expand All @@ -266,7 +266,7 @@ func TestGetMetrics(t *testing.T) {
ElementsPinnedMemoryCache: 0,
ElementsMemoryCache: 1,
SizePinnedMemoryCache: 0,
SizeMemoryCache: 5665691,
SizeMemoryCache: 5602873,
}, metrics)

// Instantiate 4
Expand All @@ -285,6 +285,6 @@ func TestGetMetrics(t *testing.T) {
ElementsPinnedMemoryCache: 0,
ElementsMemoryCache: 1,
SizePinnedMemoryCache: 0,
SizeMemoryCache: 5665691,
SizeMemoryCache: 5602873,
}, metrics)
}
Loading

0 comments on commit 9c71cfb

Please sign in to comment.