From fd96f717e8fa1574b9fe8a941b8a6fc82c752434 Mon Sep 17 00:00:00 2001 From: Aaron Craelius Date: Wed, 10 Jul 2024 12:20:47 +0200 Subject: [PATCH] allow MsgUpdateProjectEnrollment to use status UNSPECIFIED --- .../msg_update_project_enrollment.feature | 22 +++++++++++-------- .../keeper/msg_update_project_enrollment.go | 3 ++- .../msg_update_project_enrollment.feature | 4 ++-- .../types/v1/msg_update_project_enrollment.go | 4 ---- 4 files changed, 17 insertions(+), 16 deletions(-) diff --git a/x/ecocredit/base/keeper/features/msg_update_project_enrollment.feature b/x/ecocredit/base/keeper/features/msg_update_project_enrollment.feature index 41fa36ca89..5a9660f31b 100644 --- a/x/ecocredit/base/keeper/features/msg_update_project_enrollment.feature +++ b/x/ecocredit/base/keeper/features/msg_update_project_enrollment.feature @@ -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 @@ -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 | diff --git a/x/ecocredit/base/keeper/msg_update_project_enrollment.go b/x/ecocredit/base/keeper/msg_update_project_enrollment.go index e94e266420..b225b9fb39 100644 --- a/x/ecocredit/base/keeper/msg_update_project_enrollment.go +++ b/x/ecocredit/base/keeper/msg_update_project_enrollment.go @@ -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: diff --git a/x/ecocredit/base/types/v1/features/msg_update_project_enrollment.feature b/x/ecocredit/base/types/v1/features/msg_update_project_enrollment.feature index ae1dabfcac..90be8be4c4 100644 --- a/x/ecocredit/base/types/v1/features/msg_update_project_enrollment.feature +++ b/x/ecocredit/base/types/v1/features/msg_update_project_enrollment.feature @@ -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" @@ -45,7 +45,7 @@ Feature: MsgUpdateProjectEnrollment Examples: | status | error | - | UNSPECIFIED | new status: invalid | + | UNSPECIFIED | | | ACCEPTED | | | REJECTED | | | CHANGES_REQUESTED | | diff --git a/x/ecocredit/base/types/v1/msg_update_project_enrollment.go b/x/ecocredit/base/types/v1/msg_update_project_enrollment.go index 1356b2fe5e..5df1843db4 100644 --- a/x/ecocredit/base/types/v1/msg_update_project_enrollment.go +++ b/x/ecocredit/base/types/v1/msg_update_project_enrollment.go @@ -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") }