Skip to content

Commit

Permalink
Replace deprecated types
Browse files Browse the repository at this point in the history
  • Loading branch information
alpe committed May 6, 2022
1 parent 0d16725 commit 3936c7f
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 23 deletions.
36 changes: 18 additions & 18 deletions x/wasm/keeper/gas_register_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,8 @@ func TestReplyCost(t *testing.T) {
}{
"subcall response with events and data - pinned": {
src: wasmvmtypes.Reply{
Result: wasmvmtypes.SubcallResult{
Ok: &wasmvmtypes.SubcallResponse{
Result: wasmvmtypes.SubMsgResult{
Ok: &wasmvmtypes.SubMsgResponse{
Events: []wasmvmtypes.Event{
{Type: "foo", Attributes: []wasmvmtypes.EventAttribute{{Key: "myKey", Value: "myData"}}},
},
Expand All @@ -198,8 +198,8 @@ func TestReplyCost(t *testing.T) {
},
"subcall response with events - pinned": {
src: wasmvmtypes.Reply{
Result: wasmvmtypes.SubcallResult{
Ok: &wasmvmtypes.SubcallResponse{
Result: wasmvmtypes.SubMsgResult{
Ok: &wasmvmtypes.SubMsgResponse{
Events: []wasmvmtypes.Event{
{Type: "foo", Attributes: []wasmvmtypes.EventAttribute{{Key: "myKey", Value: "myData"}}},
},
Expand All @@ -212,8 +212,8 @@ func TestReplyCost(t *testing.T) {
},
"subcall response with events exceeds free tier- pinned": {
src: wasmvmtypes.Reply{
Result: wasmvmtypes.SubcallResult{
Ok: &wasmvmtypes.SubcallResponse{
Result: wasmvmtypes.SubMsgResult{
Ok: &wasmvmtypes.SubMsgResponse{
Events: []wasmvmtypes.Event{
{Type: "foo", Attributes: []wasmvmtypes.EventAttribute{{Key: strings.Repeat("x", DefaultEventAttributeDataFreeTier), Value: "myData"}}},
},
Expand All @@ -226,7 +226,7 @@ func TestReplyCost(t *testing.T) {
},
"subcall response error - pinned": {
src: wasmvmtypes.Reply{
Result: wasmvmtypes.SubcallResult{
Result: wasmvmtypes.SubMsgResult{
Err: "foo",
},
},
Expand All @@ -236,8 +236,8 @@ func TestReplyCost(t *testing.T) {
},
"subcall response with events and data - unpinned": {
src: wasmvmtypes.Reply{
Result: wasmvmtypes.SubcallResult{
Ok: &wasmvmtypes.SubcallResponse{
Result: wasmvmtypes.SubMsgResult{
Ok: &wasmvmtypes.SubMsgResponse{
Events: []wasmvmtypes.Event{
{Type: "foo", Attributes: []wasmvmtypes.EventAttribute{{Key: "myKey", Value: "myData"}}},
},
Expand All @@ -250,8 +250,8 @@ func TestReplyCost(t *testing.T) {
},
"subcall response with events - unpinned": {
src: wasmvmtypes.Reply{
Result: wasmvmtypes.SubcallResult{
Ok: &wasmvmtypes.SubcallResponse{
Result: wasmvmtypes.SubMsgResult{
Ok: &wasmvmtypes.SubMsgResponse{
Events: []wasmvmtypes.Event{
{Type: "foo", Attributes: []wasmvmtypes.EventAttribute{{Key: "myKey", Value: "myData"}}},
},
Expand All @@ -263,8 +263,8 @@ func TestReplyCost(t *testing.T) {
},
"subcall response with events exceeds free tier- unpinned": {
src: wasmvmtypes.Reply{
Result: wasmvmtypes.SubcallResult{
Ok: &wasmvmtypes.SubcallResponse{
Result: wasmvmtypes.SubMsgResult{
Ok: &wasmvmtypes.SubMsgResponse{
Events: []wasmvmtypes.Event{
{Type: "foo", Attributes: []wasmvmtypes.EventAttribute{{Key: strings.Repeat("x", DefaultEventAttributeDataFreeTier), Value: "myData"}}},
},
Expand All @@ -276,7 +276,7 @@ func TestReplyCost(t *testing.T) {
},
"subcall response error - unpinned": {
src: wasmvmtypes.Reply{
Result: wasmvmtypes.SubcallResult{
Result: wasmvmtypes.SubMsgResult{
Err: "foo",
},
},
Expand All @@ -285,8 +285,8 @@ func TestReplyCost(t *testing.T) {
},
"subcall response with empty events": {
src: wasmvmtypes.Reply{
Result: wasmvmtypes.SubcallResult{
Ok: &wasmvmtypes.SubcallResponse{
Result: wasmvmtypes.SubMsgResult{
Ok: &wasmvmtypes.SubMsgResponse{
Events: make([]wasmvmtypes.Event, 10),
},
},
Expand All @@ -296,8 +296,8 @@ func TestReplyCost(t *testing.T) {
},
"subcall response with events unset": {
src: wasmvmtypes.Reply{
Result: wasmvmtypes.SubcallResult{
Ok: &wasmvmtypes.SubcallResponse{},
Result: wasmvmtypes.SubMsgResult{
Ok: &wasmvmtypes.SubMsgResponse{},
},
},
srcConfig: DefaultGasRegisterConfig(),
Expand Down
10 changes: 5 additions & 5 deletions x/wasm/keeper/submsg_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,29 +196,29 @@ func TestDispatchSubMsgErrorHandling(t *testing.T) {
}
}

type assertion func(t *testing.T, ctx sdk.Context, contract, emptyAccount string, response wasmvmtypes.SubcallResult)
type assertion func(t *testing.T, ctx sdk.Context, contract, emptyAccount string, response wasmvmtypes.SubMsgResult)

assertReturnedEvents := func(expectedEvents int) assertion {
return func(t *testing.T, ctx sdk.Context, contract, emptyAccount string, response wasmvmtypes.SubcallResult) {
return func(t *testing.T, ctx sdk.Context, contract, emptyAccount string, response wasmvmtypes.SubMsgResult) {
require.Len(t, response.Ok.Events, expectedEvents)
}
}

assertGasUsed := func(minGas, maxGas uint64) assertion {
return func(t *testing.T, ctx sdk.Context, contract, emptyAccount string, response wasmvmtypes.SubcallResult) {
return func(t *testing.T, ctx sdk.Context, contract, emptyAccount string, response wasmvmtypes.SubMsgResult) {
gasUsed := ctx.GasMeter().GasConsumed()
assert.True(t, gasUsed >= minGas, "Used %d gas (less than expected %d)", gasUsed, minGas)
assert.True(t, gasUsed <= maxGas, "Used %d gas (more than expected %d)", gasUsed, maxGas)
}
}

assertErrorString := func(shouldContain string) assertion {
return func(t *testing.T, ctx sdk.Context, contract, emptyAccount string, response wasmvmtypes.SubcallResult) {
return func(t *testing.T, ctx sdk.Context, contract, emptyAccount string, response wasmvmtypes.SubMsgResult) {
assert.Contains(t, response.Err, shouldContain)
}
}

assertGotContractAddr := func(t *testing.T, ctx sdk.Context, contract, emptyAccount string, response wasmvmtypes.SubcallResult) {
assertGotContractAddr := func(t *testing.T, ctx sdk.Context, contract, emptyAccount string, response wasmvmtypes.SubMsgResult) {
// should get the events emitted on new contract
event := response.Ok.Events[0]
require.Equal(t, event.Type, "instantiate")
Expand Down

0 comments on commit 3936c7f

Please sign in to comment.