Skip to content

Commit

Permalink
early return for updating same role
Browse files Browse the repository at this point in the history
  • Loading branch information
tkxkd0159 committed May 24, 2024
1 parent 38ee123 commit 1e9244d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions x/fbridge/keeper/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ func (k Keeper) addVote(ctx sdk.Context, proposalID uint64, voter sdk.AccAddress

func (k Keeper) updateRole(ctx sdk.Context, role types.Role, addr sdk.AccAddress) error {
previousRole := k.GetRole(ctx, addr)
if previousRole == role {
return nil
}

roleMeta := k.GetRoleMetadata(ctx)
nInactive := k.GetBridgeInactiveCounter(ctx)

Expand Down
4 changes: 4 additions & 0 deletions x/fbridge/keeper/auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ func TestAssignRole(t *testing.T) {
err = k.updateRole(ctx, types.RoleOperator, addrs[1])
require.NoError(t, err)
require.Equal(t, types.RoleMetadata{Guardian: 1, Operator: 1, Judge: 0}, k.GetRoleMetadata(ctx))

// 4. Guardian assigns an address to a same role
err = k.updateRole(ctx, types.RoleOperator, addrs[1])
require.NoError(t, err)
}

func TestBridgeHaltAndResume(t *testing.T) {
Expand Down

0 comments on commit 1e9244d

Please sign in to comment.