Commit ae15972a authored by Nicolas Lara's avatar Nicolas Lara
Browse files

added missing helpers

parent a800e9b7
Showing with 17 additions and 1 deletion
+17 -1
package apptesting
import sdk "github.com/cosmos/cosmos-sdk/types"
import (
sdk "github.com/cosmos/cosmos-sdk/types"
"golang.org/x/exp/slices"
)
// AssertEventEmitted asserts that ctx's event manager has emitted the given number of events
// of the given type.
......@@ -15,3 +18,16 @@ func (s *KeeperTestHelper) AssertEventEmitted(ctx sdk.Context, eventTypeExpected
}
s.Equal(numEventsExpected, len(actualEvents))
}
func (s *KeeperTestHelper) FindEvent(events []sdk.Event, name string) sdk.Event {
index := slices.IndexFunc(events, func(e sdk.Event) bool { return e.Type == name })
return events[index]
}
func (s *KeeperTestHelper) ExtractAttributes(event sdk.Event) map[string]string {
attrs := make(map[string]string)
for _, a := range event.Attributes {
attrs[string(a.Key)] = string(a.Value)
}
return attrs
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment