Skip to content

Commit

Permalink
allow MsgUpdateProjectEnrollment to use status UNSPECIFIED
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronc committed Jul 10, 2024
1 parent 5146a89 commit fd96f71
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,19 @@ Feature: Msg/UpdateProjectEnrollment
}
"""
Examples:
| scenario | cur_status | cur_metadata | issuer | new_status | new_metadata | err | expected_status | expected_metadata |
| I01 unspecified to accepted | UNSPECIFIED | abc | I01 | ACCEPTED | foo123 | | ACCEPTED | foo123 |
| Bob unspecified to accepted | UNSPECIFIED | abc | Bob | ACCEPTED | foo123 | unauthorized | UNSPECIFIED | abc |
| I01 changes requested to accepted | CHANGES_REQUESTED | bar456 | I01 | ACCEPTED | foo123 | | ACCEPTED | foo123 |
| Bob changes requested to accepted | CHANGES_REQUESTED | bar456 | Bob | ACCEPTED | foo123 | unauthorized | CHANGES_REQUESTED | bar456 |
| I01 update accepted metadata | ACCEPTED | foo123 | I01 | ACCEPTED | bar357 | | ACCEPTED | bar357 |
| Bob updated accepted metadata | ACCEPTED | foo123 | Bob | ACCEPTED | bar357 | unauthorized | ACCEPTED | foo123 |
| scenario | cur_status | cur_metadata | issuer | new_status | new_metadata | err | expected_status | expected_metadata |
| I01 unspecified to accepted | UNSPECIFIED | abc | I01 | ACCEPTED | foo123 | | ACCEPTED | foo123 |
| Bob unspecified to accepted | UNSPECIFIED | abc | Bob | ACCEPTED | foo123 | unauthorized | UNSPECIFIED | abc |
| I01 unspecified to changes requested | UNSPECIFIED | abc | I01 | CHANGES_REQUESTED | foo123 | | CHANGES_REQUESTED | foo123 |
| Bob unspecified to changes requested | UNSPECIFIED | abc | Bob | CHANGES_REQUESTED | foo123 | unauthorized | UNSPECIFIED | abc |
| I01 changes requested to accepted | CHANGES_REQUESTED | bar456 | I01 | ACCEPTED | foo123 | | ACCEPTED | foo123 |
| Bob changes requested to accepted | CHANGES_REQUESTED | bar456 | Bob | ACCEPTED | foo123 | unauthorized | CHANGES_REQUESTED | bar456 |
| I01 update accepted metadata | ACCEPTED | foo123 | I01 | ACCEPTED | bar357 | | ACCEPTED | bar357 |
| Bob updated accepted metadata | ACCEPTED | foo123 | Bob | ACCEPTED | bar357 | unauthorized | ACCEPTED | foo123 |
| I01 unspecified to unspecified | UNSPECIFIED | abc | I01 | UNSPECIFIED | foo123 | | UNSPECIFIED | foo123 |
| Bob unspecified to unspecified | UNSPECIFIED | abc | Bob | UNSPECIFIED | foo123 | unauthorized | UNSPECIFIED | abc |
| I01 changes requested to unspecified | CHANGES_REQUESTED | abc | I01 | UNSPECIFIED | foo123 | | UNSPECIFIED | foo123 |
| Bob changes requested to unspecified | CHANGES_REQUESTED | abc | Bob | UNSPECIFIED | foo123 | unauthorized | CHANGES_REQUESTED | abc |

Rule: valid state transitions performed by issuers which remove enrollment entries are:
UNSPECIFIED -> REJECTED
Expand Down Expand Up @@ -67,8 +73,6 @@ Feature: Msg/UpdateProjectEnrollment
| Bob accepted to terminated | ACCEPTED | foo123 | Bob | TERMINATED | baz789 | unauthorized | true |
| I01 accepted to unspecified | ACCEPTED | foo123 | I01 | UNSPECIFIED | baz789 | invalid | true |
| Bob accepted to unspecified | ACCEPTED | foo123 | Bob | UNSPECIFIED | baz789 | unauthorized | true |
| I01 changes requested to unspecified | CHANGES_REQUESTED | bar456 | I01 | UNSPECIFIED | baz789 | invalid | true |
| Bob changes requested to unspecified | CHANGES_REQUESTED | bar456 | Bob | UNSPECIFIED | baz789 | unauthorized | true |
| I01 accepted to changes requested | ACCEPTED | foo123 | I01 | CHANGES_REQUESTED | baz789 | invalid | true |
| Bob accepted to changes requested | ACCEPTED | foo123 | Bob | CHANGES_REQUESTED | baz789 | unauthorized | true |

Expand Down
3 changes: 2 additions & 1 deletion x/ecocredit/base/keeper/msg_update_project_enrollment.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ func (k Keeper) UpdateProjectEnrollment(ctx context.Context, msg *types.MsgUpdat
case ecocreditv1.ProjectEnrollmentStatus_PROJECT_ENROLLMENT_STATUS_UNSPECIFIED,
ecocreditv1.ProjectEnrollmentStatus_PROJECT_ENROLLMENT_STATUS_CHANGES_REQUESTED:
switch newStatus {
case ecocreditv1.ProjectEnrollmentStatus_PROJECT_ENROLLMENT_STATUS_CHANGES_REQUESTED,
case ecocreditv1.ProjectEnrollmentStatus_PROJECT_ENROLLMENT_STATUS_UNSPECIFIED,
ecocreditv1.ProjectEnrollmentStatus_PROJECT_ENROLLMENT_STATUS_CHANGES_REQUESTED,
ecocreditv1.ProjectEnrollmentStatus_PROJECT_ENROLLMENT_STATUS_ACCEPTED:
// Valid case
case ecocreditv1.ProjectEnrollmentStatus_PROJECT_ENROLLMENT_STATUS_REJECTED:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ Feature: MsgUpdateProjectEnrollment
| P001 | C01 | |
| P001 | | class id: empty |

Rule: new_status is specified and valid
Rule: new_status is valid
Scenario Outline: validate status
Given issuer "regen1depk54cuajgkzea6zpgkq36tnjwdzv4ak663u6"
* project ID "P001"
Expand All @@ -45,7 +45,7 @@ Feature: MsgUpdateProjectEnrollment

Examples:
| status | error |
| UNSPECIFIED | new status: invalid |
| UNSPECIFIED | |
| ACCEPTED | |
| REJECTED | |
| CHANGES_REQUESTED | |
Expand Down
4 changes: 0 additions & 4 deletions x/ecocredit/base/types/v1/msg_update_project_enrollment.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,6 @@ func (m *MsgUpdateProjectEnrollment) ValidateBasic() error {
return sdkerrors.ErrInvalidRequest.Wrapf("class id: %s", err)
}

if m.NewStatus == ProjectEnrollmentStatus_PROJECT_ENROLLMENT_STATUS_UNSPECIFIED {
return sdkerrors.ErrInvalidRequest.Wrapf("new status: invalid")
}

if _, ok := ProjectEnrollmentStatus_name[int32(m.NewStatus)]; !ok {
return sdkerrors.ErrInvalidRequest.Wrapf("new status: invalid")
}
Expand Down

0 comments on commit fd96f71

Please sign in to comment.