-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add oracle flag & flag checker to msgupdateoracle of opchild #105
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -95,6 +95,7 @@ | |
sdk.NewAttribute(types.AttributeKeyBatchChainType, req.Config.BatchInfo.ChainType.StringWithoutPrefix()), | ||
sdk.NewAttribute(types.AttributeKeyBatchSubmitter, req.Config.BatchInfo.Submitter), | ||
sdk.NewAttribute(types.AttributeKeyBridgeId, strconv.FormatUint(bridgeId, 10)), | ||
sdk.NewAttribute(types.AttributeKeyOracleEnabled, strconv.FormatBool(req.Config.OracleEnabled)), | ||
)) | ||
|
||
if err := ms.bridgeHook.BridgeCreated(ctx, bridgeId, req.Config); err != nil { | ||
|
@@ -497,6 +498,36 @@ | |
}, nil | ||
} | ||
|
||
func (ms MsgServer) UpdateOracleConfig(ctx context.Context, req *types.MsgUpdateOracleConfig) (*types.MsgUpdateOracleConfigResponse, error) { | ||
if err := req.Validate(ms.authKeeper.AddressCodec()); err != nil { | ||
return nil, err | ||
} | ||
Comment on lines
+501
to
+504
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ensure validation errors are covered by tests. The validation check for the request is not covered by tests. Add a test case to cover validation errors for the request. ToolsGitHub Check: codecov/patch
|
||
|
||
bridgeId := req.BridgeId | ||
config, err := ms.GetBridgeConfig(ctx, bridgeId) | ||
if err != nil { | ||
return nil, err | ||
} | ||
Comment on lines
+506
to
+510
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ensure error handling for bridge configuration retrieval is covered by tests. The error handling for retrieving the bridge configuration is not covered by tests. Add a test case to cover errors when retrieving the bridge configuration. ToolsGitHub Check: codecov/patch
|
||
|
||
// gov or current proposer can update metadata. | ||
if ms.authority != req.Authority && config.Proposer != req.Authority { | ||
return nil, govtypes.ErrInvalidSigner.Wrapf("invalid authority; expected %s or %s, got %s", ms.authority, config.Proposer, req.Authority) | ||
} | ||
Comment on lines
+512
to
+515
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ensure permission checks are covered by tests. The permission check for updating the Oracle configuration is correctly implemented but not covered by tests. Add a test case to cover permission checks for updating the Oracle configuration. |
||
|
||
config.OracleEnabled = req.OracleEnabled | ||
|
||
if err := ms.SetBridgeConfig(ctx, bridgeId, config); err != nil { | ||
return nil, err | ||
} | ||
Comment on lines
+517
to
+521
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ensure setting the bridge configuration is covered by tests. The process of setting the bridge configuration is not covered by tests. Add a test case to cover setting the bridge configuration. ToolsGitHub Check: codecov/patch
|
||
|
||
sdk.UnwrapSDKContext(ctx).EventManager().EmitEvent(sdk.NewEvent( | ||
types.EventTypeUpdateBatchInfo, | ||
sdk.NewAttribute(types.AttributeKeyBridgeId, strconv.FormatUint(bridgeId, 10)), | ||
sdk.NewAttribute(types.AttributeKeyOracleEnabled, strconv.FormatBool(config.OracleEnabled)), | ||
)) | ||
Comment on lines
+523
to
+527
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ensure event emission is covered by tests. The event emission for updating the Oracle configuration is correctly implemented but not covered by tests. Add a test case to cover event emission for updating the Oracle configuration. |
||
return &types.MsgUpdateOracleConfigResponse{}, nil | ||
} | ||
|
||
func (ms MsgServer) UpdateMetadata(ctx context.Context, req *types.MsgUpdateMetadata) (*types.MsgUpdateMetadataResponse, error) { | ||
if err := req.Validate(ms.authKeeper.AddressCodec()); err != nil { | ||
return nil, err | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -380,6 +380,33 @@ | |
return nil | ||
} | ||
|
||
/* MsgUpdateOracleConfig */ | ||
|
||
// NewMsgUpdateOracleConfig creates a new MsgUpdateOracleConfig instance. | ||
func NewMsgUpdateOracleConfig( | ||
authority string, | ||
bridgeId uint64, | ||
oracleEnabled bool, | ||
) *MsgUpdateOracleConfig { | ||
return &MsgUpdateOracleConfig{ | ||
Authority: authority, | ||
BridgeId: bridgeId, | ||
OracleEnabled: oracleEnabled, | ||
} | ||
} | ||
|
||
// Validate performs basic MsgUpdateOracleConfig message validation. | ||
func (msg MsgUpdateOracleConfig) Validate(accAddressCodec address.Codec) error { | ||
if _, err := accAddressCodec.StringToBytes(msg.Authority); err != nil { | ||
return err | ||
} | ||
|
||
if msg.BridgeId == 0 { | ||
return ErrInvalidBridgeId | ||
} | ||
return nil | ||
Comment on lines
+398
to
+407
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. LGTM! But add tests for validation. The validation logic is correct. However, the added lines are not covered by tests. The code changes are approved. Do you want me to generate the unit testing code or open a GitHub issue to track this task? ToolsGitHub Check: codecov/patch
|
||
} | ||
|
||
/* MsgUpdateMetadata */ | ||
|
||
// NewMsgUpdateMetadata creates a new MsgUpdateMetadata instance. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! But add tests for the configuration check.
The added configuration check enhances the robustness of the function. However, the added lines are not covered by tests.
The code changes are approved.
Do you want me to generate the unit testing code or open a GitHub issue to track this task?
Tools
GitHub Check: codecov/patch