Skip to content

Commit

Permalink
Add changelog
Browse files Browse the repository at this point in the history
  • Loading branch information
mattverse committed Jul 10, 2024
1 parent 1becaea commit c8abedf
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 28 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* [#8375](https://github.com/osmosis-labs/osmosis/pull/8375) Enforce sub-authenticator to be greater than 1

### State Compatible
* [#8494](https://github.com/osmosis-labs/osmosis/pull/8494) Add additional events in x/lockup, x/superfluid, x/concentratedliquidity

## v25.2.0

Expand Down
61 changes: 34 additions & 27 deletions x/superfluid/keeper/internal/events/emit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,16 @@ func (suite *SuperfluidEventsTestSuite) TestEmitRemoveSuperfluidAsset() {

func (suite *SuperfluidEventsTestSuite) TestEmitSuperfluidDelegateEvent() {
testcases := map[string]struct {
ctx sdk.Context
lockID uint64
valAddr string
ctx sdk.Context
lockID uint64
valAddr string
lockCoins sdk.Coins
}{
"basic valid": {
ctx: suite.CreateTestContext(),
lockID: 1,
valAddr: sdk.AccAddress([]byte(addressString)).String(),
ctx: suite.CreateTestContext(),
lockID: 1,
valAddr: sdk.AccAddress([]byte(addressString)).String(),
lockCoins: sdk.NewCoins(sdk.NewInt64Coin("foo", 10)),
},
"context with no event manager": {
ctx: sdk.Context{},
Expand All @@ -131,25 +133,26 @@ func (suite *SuperfluidEventsTestSuite) TestEmitSuperfluidDelegateEvent() {

for name, tc := range testcases {
suite.Run(name, func() {
expectedEvents := sdk.Events{
sdk.NewEvent(
types.TypeEvtSuperfluidDelegate,
sdk.NewAttribute(types.AttributeLockId, fmt.Sprintf("%d", tc.lockID)),
sdk.NewAttribute(types.AttributeValidator, tc.valAddr),
),
}

hasNoEventManager := tc.ctx.EventManager() == nil

// System under test.
events.EmitSuperfluidDelegateEvent(tc.ctx, tc.lockID, tc.valAddr)
events.EmitSuperfluidDelegateEvent(tc.ctx, tc.lockID, tc.valAddr, tc.lockCoins)

// Assertions
if hasNoEventManager {
// If there is no event manager on context, this is a no-op.
return
}

expectedEvents := sdk.Events{
sdk.NewEvent(
types.TypeEvtSuperfluidDelegate,
sdk.NewAttribute(types.AttributeLockId, fmt.Sprintf("%d", tc.lockID)),
sdk.NewAttribute(types.AttributeLockAmount, tc.lockCoins[0].Amount.String()),
sdk.NewAttribute(types.AttributeLockDenom, tc.lockCoins[0].Denom),
sdk.NewAttribute(types.AttributeValidator, tc.valAddr),
),
}
eventManager := tc.ctx.EventManager()
actualEvents := eventManager.Events()
suite.Equal(expectedEvents, actualEvents)
Expand Down Expand Up @@ -255,12 +258,14 @@ func (suite *SuperfluidEventsTestSuite) TestEmitSuperfluidIncreaseDelegationEven

func (suite *SuperfluidEventsTestSuite) TestEmitSuperfluidUndelegateEvent() {
testcases := map[string]struct {
ctx sdk.Context
lockID uint64
ctx sdk.Context
lockID uint64
lockCoins sdk.Coins
}{
"basic valid": {
ctx: suite.CreateTestContext(),
lockID: 1,
ctx: suite.CreateTestContext(),
lockID: 1,
lockCoins: sdk.NewCoins(sdk.NewInt64Coin("foo", 10)),
},
"context with no event manager": {
ctx: sdk.Context{},
Expand All @@ -269,24 +274,26 @@ func (suite *SuperfluidEventsTestSuite) TestEmitSuperfluidUndelegateEvent() {

for name, tc := range testcases {
suite.Run(name, func() {
expectedEvents := sdk.Events{
sdk.NewEvent(
types.TypeEvtSuperfluidUndelegate,
sdk.NewAttribute(types.AttributeLockId, fmt.Sprintf("%d", tc.lockID)),
),
}

hasNoEventManager := tc.ctx.EventManager() == nil

// System under test.
events.EmitSuperfluidUndelegateEvent(tc.ctx, tc.lockID)
events.EmitSuperfluidUndelegateEvent(tc.ctx, tc.lockID, tc.lockCoins)

// Assertions
if hasNoEventManager {
// If there is no event manager on context, this is a no-op.
return
}

expectedEvents := sdk.Events{
sdk.NewEvent(
types.TypeEvtSuperfluidUndelegate,
sdk.NewAttribute(types.AttributeLockId, fmt.Sprintf("%d", tc.lockID)),
sdk.NewAttribute(types.AttributeLockAmount, tc.lockCoins[0].Amount.String()),
sdk.NewAttribute(types.AttributeLockDenom, tc.lockCoins[0].Denom),
),
}

eventManager := tc.ctx.EventManager()
actualEvents := eventManager.Events()
suite.Equal(expectedEvents, actualEvents)
Expand Down
6 changes: 5 additions & 1 deletion x/superfluid/keeper/msg_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,11 @@ func (server msgServer) SuperfluidUndelegate(goCtx context.Context, msg *types.M

err := server.keeper.SuperfluidUndelegate(ctx, msg.Sender, msg.LockId)
if err == nil {
events.EmitSuperfluidUndelegateEvent(ctx, msg.LockId)
lock, err := server.keeper.lk.GetLockByID(ctx, msg.LockId)
if err != nil {
return &types.MsgSuperfluidUndelegateResponse{}, err
}
events.EmitSuperfluidUndelegateEvent(ctx, msg.LockId, lock.Coins)
}
return &types.MsgSuperfluidUndelegateResponse{}, err
}
Expand Down

0 comments on commit c8abedf

Please sign in to comment.