Skip to content

Commit

Permalink
fix cosmwasm events test
Browse files Browse the repository at this point in the history
  • Loading branch information
99Kies committed Sep 11, 2023
1 parent 87517aa commit 591fe3a
Showing 1 changed file with 17 additions and 14 deletions.
31 changes: 17 additions & 14 deletions x/wasm/keeper/events_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,23 @@ func TestNewCustomEvents(t *testing.T) {
exp: sdk.Events{sdk.NewEvent("wasm-foo",
sdk.NewAttribute("_contract_address", myContract.String()))},
},
"empty value can be solved": {
src: wasmvmtypes.Events{{
Type: "foo",
Attributes: []wasmvmtypes.EventAttribute{{Key: "myKey", Value: ""}},
}},
exp: sdk.Events{sdk.NewEvent("wasm-foo",
sdk.NewAttribute("_contract_address", myContract.String()),
sdk.NewAttribute("myKey", ""))},
},
"good on whitespace value": {
src: wasmvmtypes.Events{{
Type: "foo",
Attributes: []wasmvmtypes.EventAttribute{{Key: "myKey", Value: "\n\n\n"}},
}}, exp: sdk.Events{sdk.NewEvent("wasm-foo",
sdk.NewAttribute("_contract_address", myContract.String()),
sdk.NewAttribute("myKey", ""))},
},
"error on short event type": {
src: wasmvmtypes.Events{{
Type: "f",
Expand Down Expand Up @@ -158,16 +175,6 @@ func TestNewCustomEvents(t *testing.T) {
}},
isError: true,
},
"error on only whitespace value": {
src: wasmvmtypes.Events{{
Type: "boom",
Attributes: []wasmvmtypes.EventAttribute{
{Key: "some", Value: "data"},
{Key: "myKey", Value: " \t\r\n"},
},
}},
isError: true,
},
"strip out whitespace": {
src: wasmvmtypes.Events{{
Type: " food\n",
Expand Down Expand Up @@ -233,10 +240,6 @@ func TestNewWasmModuleEvent(t *testing.T) {
src: []wasmvmtypes.EventAttribute{{Key: " ", Value: "value"}},
isError: true,
},
"error on whitespace value": {
src: []wasmvmtypes.EventAttribute{{Key: "key", Value: "\n\n\n"}},
isError: true,
},
"strip whitespace": {
src: []wasmvmtypes.EventAttribute{{Key: " my-real-key ", Value: "\n\n\nsome-val\t\t\t"}},
exp: sdk.Events{sdk.NewEvent("wasm",
Expand Down

0 comments on commit 591fe3a

Please sign in to comment.