Skip to content

Commit

Permalink
rename SetObervers into SetObserverSet
Browse files Browse the repository at this point in the history
  • Loading branch information
lumtis committed Jan 6, 2024
1 parent 2a13440 commit 4481ff1
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 25 deletions.
1 change: 0 additions & 1 deletion x/crosschain/types/expected_keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ type BankKeeper interface {
}

type ObserverKeeper interface {
SetObservers(ctx sdk.Context, om observertypes.ObserverSet)
GetObserverSet(ctx sdk.Context) (val observertypes.ObserverSet, found bool)
SetBallot(ctx sdk.Context, ballot *observertypes.Ballot)
GetBallot(ctx sdk.Context, index string) (val observertypes.Ballot, found bool)
Expand Down
1 change: 0 additions & 1 deletion x/emissions/types/expected_keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ type AccountKeeper interface {

type ObserverKeeper interface {
GetMaturedBallotList(ctx sdk.Context) []string
SetObservers(ctx sdk.Context, om observertypes.ObserverSet)
GetObserverSet(ctx sdk.Context) (val observertypes.ObserverSet, found bool)
SetBallot(ctx sdk.Context, ballot *observertypes.Ballot)
GetBallot(ctx sdk.Context, index string) (val observertypes.Ballot, found bool)
Expand Down
1 change: 0 additions & 1 deletion x/fungible/types/expected_keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ type BankKeeper interface {
}

type ObserverKeeper interface {
SetObservers(ctx sdk.Context, om observertypes.ObserverSet)
GetObserverSet(ctx sdk.Context) (val observertypes.ObserverSet, found bool)
SetBallot(ctx sdk.Context, ballot *observertypes.Ballot)
GetBallot(ctx sdk.Context, index string) (val observertypes.Ballot, found bool)
Expand Down
2 changes: 1 addition & 1 deletion x/observer/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState)

observerCount := uint64(0)
if genState.Observers.Len() > 0 {
k.SetObservers(ctx, genState.Observers)
k.SetObserverSet(ctx, genState.Observers)
observerCount = uint64(len(genState.Observers.ObserverList))
}
// If core params are defined set them, otherwise set default
Expand Down
2 changes: 1 addition & 1 deletion x/observer/keeper/msg_server_add_block_header_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ func TestMsgServer_AddBlockHeader(t *testing.T) {
t.Run(tc.name, func(t *testing.T) {
k, ctx := keepertest.ObserverKeeper(t)
srv := keeper.NewMsgServerImpl(*k)
k.SetObservers(ctx, types.ObserverSet{
k.SetObserverSet(ctx, types.ObserverSet{
ObserverList: []string{observerAddress.String()},
})
k.GetStakingKeeper().SetValidator(ctx, tc.validator)
Expand Down
16 changes: 8 additions & 8 deletions x/observer/keeper/msg_server_update_observer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func TestMsgServer_UpdateObserver(t *testing.T) {

count := uint64(0)

k.SetObservers(ctx, types.ObserverSet{
k.SetObserverSet(ctx, types.ObserverSet{
ObserverList: []string{accAddressOfValidator.String()},
})
count = 1
Expand Down Expand Up @@ -99,7 +99,7 @@ func TestMsgServer_UpdateObserver(t *testing.T) {
assert.NoError(t, err)

count := uint64(0)
k.SetObservers(ctx, types.ObserverSet{
k.SetObserverSet(ctx, types.ObserverSet{
ObserverList: []string{accAddressOfValidator.String()},
})
count = 1
Expand Down Expand Up @@ -147,7 +147,7 @@ func TestMsgServer_UpdateObserver(t *testing.T) {
assert.NoError(t, err)
count := uint64(0)

k.SetObservers(ctx, types.ObserverSet{
k.SetObserverSet(ctx, types.ObserverSet{
ObserverList: []string{accAddressOfValidator.String()},
})
count += 1
Expand Down Expand Up @@ -197,7 +197,7 @@ func TestMsgServer_UpdateObserver(t *testing.T) {
accAddressOfValidator, err := types.GetAccAddressFromOperatorAddress(validator.OperatorAddress)
assert.NoError(t, err)
count := uint64(0)
k.SetObservers(ctx, types.ObserverSet{
k.SetObserverSet(ctx, types.ObserverSet{
ObserverList: []string{accAddressOfValidator.String()},
})
count += 1
Expand Down Expand Up @@ -247,7 +247,7 @@ func TestMsgServer_UpdateObserver(t *testing.T) {
accAddressOfValidator, err := types.GetAccAddressFromOperatorAddress(validator.OperatorAddress)
assert.NoError(t, err)
count := uint64(0)
k.SetObservers(ctx, types.ObserverSet{
k.SetObserverSet(ctx, types.ObserverSet{
ObserverList: []string{accAddressOfValidator.String()},
})
count += 1
Expand Down Expand Up @@ -293,7 +293,7 @@ func TestMsgServer_UpdateObserver(t *testing.T) {
accAddressOfValidator, err := types.GetAccAddressFromOperatorAddress(validator.OperatorAddress)
assert.NoError(t, err)
count := uint64(0)
k.SetObservers(ctx, types.ObserverSet{
k.SetObserverSet(ctx, types.ObserverSet{
ObserverList: []string{accAddressOfValidator.String()},
})
count += 1
Expand Down Expand Up @@ -341,7 +341,7 @@ func TestMsgServer_UpdateObserver(t *testing.T) {
accAddressOfValidator, err := types.GetAccAddressFromOperatorAddress(validator.OperatorAddress)
assert.NoError(t, err)
count := uint64(0)
k.SetObservers(ctx, types.ObserverSet{
k.SetObserverSet(ctx, types.ObserverSet{
ObserverList: []string{accAddressOfValidator.String()},
})
count += 1
Expand Down Expand Up @@ -394,7 +394,7 @@ func TestMsgServer_UpdateObserver(t *testing.T) {
accAddressOfValidator, err := types.GetAccAddressFromOperatorAddress(validator.OperatorAddress)
assert.NoError(t, err)
count := uint64(0)
k.SetObservers(ctx, types.ObserverSet{
k.SetObserverSet(ctx, types.ObserverSet{
ObserverList: []string{accAddressOfValidator.String()},
})
count += 1
Expand Down
10 changes: 5 additions & 5 deletions x/observer/keeper/observer_set.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/zeta-chain/zetacore/x/observer/types"
)

func (k Keeper) SetObservers(ctx sdk.Context, om types.ObserverSet) {
func (k Keeper) SetObserverSet(ctx sdk.Context, om types.ObserverSet) {
store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.ObserverSetKey))
b := k.cdc.MustMarshal(&om)
store.Set([]byte{0}, b)
Expand Down Expand Up @@ -39,7 +39,7 @@ func (k Keeper) IsAddressPartOfObserverSet(ctx sdk.Context, address string) bool
func (k Keeper) AddObserverToSet(ctx sdk.Context, address string) {
observerSet, found := k.GetObserverSet(ctx)
if !found {
k.SetObservers(ctx, types.ObserverSet{
k.SetObserverSet(ctx, types.ObserverSet{
ObserverList: []string{address},
})
return
Expand All @@ -50,7 +50,7 @@ func (k Keeper) AddObserverToSet(ctx sdk.Context, address string) {
}
}
observerSet.ObserverList = append(observerSet.ObserverList, address)
k.SetObservers(ctx, observerSet)
k.SetObserverSet(ctx, observerSet)
}

func (k Keeper) RemoveObserverFromSet(ctx sdk.Context, address string) {
Expand All @@ -61,7 +61,7 @@ func (k Keeper) RemoveObserverFromSet(ctx sdk.Context, address string) {
for i, addr := range observerSet.ObserverList {
if addr == address {
observerSet.ObserverList = append(observerSet.ObserverList[:i], observerSet.ObserverList[i+1:]...)
k.SetObservers(ctx, observerSet)
k.SetObserverSet(ctx, observerSet)
return
}
}
Expand All @@ -75,7 +75,7 @@ func (k Keeper) UpdateObserverAddress(ctx sdk.Context, oldObserverAddress, newOb
for i, addr := range observerSet.ObserverList {
if addr == oldObserverAddress {
observerSet.ObserverList[i] = newObserverAddress
k.SetObservers(ctx, observerSet)
k.SetObserverSet(ctx, observerSet)
return nil
}
}
Expand Down
8 changes: 4 additions & 4 deletions x/observer/keeper/observer_set_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func TestKeeper_AddObserverToSet(t *testing.T) {
t.Run("add observer to set", func(t *testing.T) {
k, ctx := keepertest.ObserverKeeper(t)
os := sample.ObserverSet(10)
k.SetObservers(ctx, os)
k.SetObserverSet(ctx, os)
newObserver := sample.AccAddress()
k.AddObserverToSet(ctx, newObserver)
assert.True(t, k.IsAddressPartOfObserverSet(ctx, newObserver))
Expand Down Expand Up @@ -64,7 +64,7 @@ func TestKeeper_UpdateObserverAddress(t *testing.T) {
newObserverAddress := sample.AccAddress()
observerSet := sample.ObserverSet(10)
observerSet.ObserverList = append(observerSet.ObserverList, oldObserverAddress)
k.SetObservers(ctx, observerSet)
k.SetObserverSet(ctx, observerSet)
err := k.UpdateObserverAddress(ctx, oldObserverAddress, newObserverAddress)
assert.NoError(t, err)
observerSet, found := k.GetObserverSet(ctx)
Expand All @@ -77,7 +77,7 @@ func TestKeeper_UpdateObserverAddress(t *testing.T) {
newObserverAddress := sample.AccAddress()
observerSet := sample.ObserverSet(10000)
observerSet.ObserverList = append(observerSet.ObserverList, oldObserverAddress)
k.SetObservers(ctx, observerSet)
k.SetObserverSet(ctx, observerSet)
err := k.UpdateObserverAddress(ctx, oldObserverAddress, newObserverAddress)
assert.NoError(t, err)
observerMappers, found := k.GetObserverSet(ctx)
Expand All @@ -90,7 +90,7 @@ func TestKeeper_UpdateObserverAddress(t *testing.T) {
newObserverAddress := sample.AccAddress()
observerSet := sample.ObserverSet(1)
observerSet.ObserverList = append(observerSet.ObserverList, oldObserverAddress)
k.SetObservers(ctx, observerSet)
k.SetObserverSet(ctx, observerSet)
err := k.UpdateObserverAddress(ctx, oldObserverAddress, newObserverAddress)
assert.NoError(t, err)
observerMappers, found := k.GetObserverSet(ctx)
Expand Down
6 changes: 3 additions & 3 deletions x/observer/keeper/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func TestKeeper_IsAuthorized(t *testing.T) {

accAddressOfValidator, err := types.GetAccAddressFromOperatorAddress(validator.OperatorAddress)

k.SetObservers(ctx, types.ObserverSet{
k.SetObserverSet(ctx, types.ObserverSet{
ObserverList: []string{accAddressOfValidator.String()},
})
assert.True(t, k.IsAuthorized(ctx, accAddressOfValidator.String()))
Expand All @@ -57,7 +57,7 @@ func TestKeeper_IsAuthorized(t *testing.T) {
})

accAddressOfValidator, err := types.GetAccAddressFromOperatorAddress(validator.OperatorAddress)
k.SetObservers(ctx, types.ObserverSet{
k.SetObserverSet(ctx, types.ObserverSet{
ObserverList: []string{accAddressOfValidator.String()},
})

Expand All @@ -83,7 +83,7 @@ func TestKeeper_IsAuthorized(t *testing.T) {
})

accAddressOfValidator, err := types.GetAccAddressFromOperatorAddress(validator.OperatorAddress)
k.SetObservers(ctx, types.ObserverSet{
k.SetObserverSet(ctx, types.ObserverSet{
ObserverList: []string{accAddressOfValidator.String()},
})

Expand Down

0 comments on commit 4481ff1

Please sign in to comment.