Skip to content

Commit

Permalink
Move tested pieces into variables.
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew Witkowski committed Sep 5, 2023
1 parent 3782a95 commit 2903377
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions x/oracle/keeper/msg_server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,14 @@ func (s *KeeperTestSuite) TestUpdateOracle() {
for _, tc := range tests {
s.Run(tc.name, func() {
res, err := s.msgServer.UpdateOracle(s.ctx, tc.req)
events := s.ctx.EventManager().Events()
numEvents := len(events)

if tc.event != nil {
s.Assert().Equal(1, len(s.ctx.EventManager().Events()), "should emit the correct number of events")
s.Assert().Equal(*tc.event, s.ctx.EventManager().Events()[0], "should emit the correct event")
s.Assert().Equal(1, numEvents, "should emit the correct number of events")
s.Assert().Equal(*tc.event, events[0], "should emit the correct event")
} else {
s.Assert().Empty(s.ctx.EventManager().Events(), "should not emit events")
s.Assert().Empty(events, "should not emit events")
}

if len(tc.err) > 0 {
Expand Down Expand Up @@ -112,12 +114,14 @@ func (s *KeeperTestSuite) TestSendQueryOracle() {
s.app.OracleKeeper = s.app.OracleKeeper.WithMockChannelKeeper(&keeper.MockChannelKeeper{})
}
res, err := s.msgServer.SendQueryOracle(s.ctx, tc.req)
events := s.ctx.EventManager().Events()
numEvents := len(events)

if tc.event != nil {
s.Assert().Equal(1, len(s.ctx.EventManager().Events()), "should emit the correct number of events")
s.Assert().Equal(*tc.event, s.ctx.EventManager().Events()[0], "should emit the correct event")
s.Assert().Equal(1, numEvents, "should emit the correct number of events")
s.Assert().Equal(*tc.event, events[0], "should emit the correct event")
} else {
s.Assert().Empty(s.ctx.EventManager().Events(), "should not emit events")
s.Assert().Empty(events, "should not emit events")
}

if len(tc.err) > 0 {
Expand Down

0 comments on commit 2903377

Please sign in to comment.