Skip to content

x/superfluid: ensure events are emitted and tests added #2194

@p0mvn

Description

@p0mvn

Background

There are a few issues with how we emit superfluid events.

First, some of them are not being emitted on success:

if err != nil {
ctx.EventManager().EmitEvent(sdk.NewEvent(
types.TypeEvtSuperfluidDelegate,
sdk.NewAttribute(types.AttributeLockId, fmt.Sprintf("%d", msg.LockId)),
sdk.NewAttribute(types.AttributeValidator, msg.ValAddr),
))
}

The conditional should be the opposite of what it is now.

Second, there are no tests for any superfluid events so we cannot be confident if the rest function as expected.

Third, there is no documentation about what events are for and which attributes they should contain.

Suggested Design

Follow a similar change in x/gamm: #1942

To limit the scope and ease the review, I suggest associating each PR with the following tasks:

  • Task 1 - Core logic + Test TypeEvtSetSuperfluidAsset
  1. Create an internal x/superfluid/internal/events package that contains core logic for emitting events
  2. Keep the event names in types since they might be used by integrators
  3. Follow this PR for an example in GAMM
  4. Test TypeEvtSetSuperfluidAsset
    • test attributes in x/superfluid/internal/events
    • test that the event is emitted in the right location
    • Add docs to the README about what the event is for and which attributes it contains
  • Task 2 - Test TypeEvtRemoveSuperfluidAsset
    Test TypeEvtRemoveSuperfluidAsset
    • test attributes in x/superfluid/internal/events
    • test that the event is emitted in the right location
    • Add docs to the README about what the event is for and which attributes it contains
  • Task 3 - Test TypeEvtSuperfluidDelegate
    Test TypeEvtSuperfluidDelegate
    • test attributes in x/superfluid/internal/events
    • test that the event is emitted in the right location
    • Add docs to the README about what the event is for and which attributes it contains
  • Task 4 - Test TypeEvtSuperfluidIncreaseDelegation
    Test TypeEvtSuperfluidIncreaseDelegation
    • test attributes in x/superfluid/internal/events
    • test that the event is emitted in the right location
    • Add docs to the README about what the event is for and which attributes it contains
  • Task 5 - Test TypeEvtSuperfluidUndelegate
    Test TypeEvtSuperfluidUndelegate
    • test attributes in x/superfluid/internal/events
    • test that the event is emitted in the right location
    • Add docs to the README about what the event is for and which attributes it contains
  • Task 6 - Test TypeEvtSuperfluidUnbondLock
    Test TypeEvtSuperfluidUnbondLock
    • test attributes in x/superfluid/internal/events
    • test that the event is emitted in the right location
    • Add docs to the README about what the event is for and which attributes it contains
  • Task 7 - Test TypeEvtUnpoolId
    Test TypeEvtUnpoolId
    • test attributes in x/superfluid/internal/events
    • test that the event is emitted in the right location
    • Add docs to the README about what the event is for and which attributes it contains

Acceptance Criteria

  • superfluid events are emitted correctly in the right locations
  • tests added for attributes
  • tests added for verifying that events are emitted in the correct locations
  • every event is documented in superfluid README
    • what the events is for / when it is emitted
    • what attributes it contains
  • final design is consistent with x/gamm: x/gamm: test that swap and LP events are emitted #1942

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Done ✅

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions