Skip to content

Commit

Permalink
Fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
kingpinXD committed Apr 12, 2024
1 parent 39b9692 commit 26f5e2c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
12 changes: 6 additions & 6 deletions cmd/zetacored/parse_genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import (
observertypes "github.com/zeta-chain/zetacore/x/observer/types"
)

const Max_items_for_list = 10
const MaxItemsForList = 10

var Copy = map[string]bool{
slashingtypes.ModuleName: true,
Expand Down Expand Up @@ -143,9 +143,9 @@ func ImportDataIntoFile(genDoc *types.GenesisDoc, importFile *types.GenesisDoc,

func ModifyCrossChainState(appState map[string]json.RawMessage, importAppState map[string]json.RawMessage, cdc codec.Codec) error {
importedCrossChainGenState := crosschaintypes.GetGenesisStateFromAppState(cdc, importAppState)
importedCrossChainGenState.CrossChainTxs = importedCrossChainGenState.CrossChainTxs[:math.Min(Max_items_for_list, len(importedCrossChainGenState.CrossChainTxs))]
importedCrossChainGenState.InTxHashToCctxList = importedCrossChainGenState.InTxHashToCctxList[:math.Min(Max_items_for_list, len(importedCrossChainGenState.InTxHashToCctxList))]
importedCrossChainGenState.FinalizedInbounds = importedCrossChainGenState.FinalizedInbounds[:math.Min(Max_items_for_list, len(importedCrossChainGenState.FinalizedInbounds))]
importedCrossChainGenState.CrossChainTxs = importedCrossChainGenState.CrossChainTxs[:math.Min(MaxItemsForList, len(importedCrossChainGenState.CrossChainTxs))]
importedCrossChainGenState.InTxHashToCctxList = importedCrossChainGenState.InTxHashToCctxList[:math.Min(MaxItemsForList, len(importedCrossChainGenState.InTxHashToCctxList))]
importedCrossChainGenState.FinalizedInbounds = importedCrossChainGenState.FinalizedInbounds[:math.Min(MaxItemsForList, len(importedCrossChainGenState.FinalizedInbounds))]
importedCrossChainStateBz, err := json.Marshal(importedCrossChainGenState)
if err != nil {
return fmt.Errorf("failed to marshal zetacrosschain genesis state: %w", err)
Expand All @@ -156,8 +156,8 @@ func ModifyCrossChainState(appState map[string]json.RawMessage, importAppState m

func ModifyObserverState(appState map[string]json.RawMessage, importAppState map[string]json.RawMessage, cdc codec.Codec) error {
importedObserverGenState := observertypes.GetGenesisStateFromAppState(cdc, importAppState)
importedObserverGenState.Ballots = importedObserverGenState.Ballots[:math.Min(Max_items_for_list, len(importedObserverGenState.Ballots))]
importedObserverGenState.NonceToCctx = importedObserverGenState.NonceToCctx[:math.Min(Max_items_for_list, len(importedObserverGenState.NonceToCctx))]
importedObserverGenState.Ballots = importedObserverGenState.Ballots[:math.Min(MaxItemsForList, len(importedObserverGenState.Ballots))]
importedObserverGenState.NonceToCctx = importedObserverGenState.NonceToCctx[:math.Min(MaxItemsForList, len(importedObserverGenState.NonceToCctx))]

currentGenState := observertypes.GetGenesisStateFromAppState(cdc, appState)
currentGenState.Ballots = importedObserverGenState.Ballots
Expand Down
10 changes: 5 additions & 5 deletions cmd/zetacored/parse_genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ func Test_ModifyObserverState(t *testing.T) {
require.NoError(t, err)

modifiedObserverAppState := observertypes.GetGenesisStateFromAppState(cdc, appState)
require.Len(t, modifiedObserverAppState.Ballots, zetacored.Max_items_for_list)
require.Len(t, modifiedObserverAppState.NonceToCctx, zetacored.Max_items_for_list)
require.Len(t, modifiedObserverAppState.Ballots, zetacored.MaxItemsForList)
require.Len(t, modifiedObserverAppState.NonceToCctx, zetacored.MaxItemsForList)
})

t.Run("successfully modify observer state without changing data when not needed", func(t *testing.T) {
Expand Down Expand Up @@ -104,9 +104,9 @@ func Test_ImportDataIntoFile(t *testing.T) {

// Crosschain module is in Modify list
crosschainStateAfterImport := crosschaintypes.GetGenesisStateFromAppState(cdc, appState)
require.Len(t, crosschainStateAfterImport.CrossChainTxs, zetacored.Max_items_for_list)
require.Len(t, crosschainStateAfterImport.InTxHashToCctxList, zetacored.Max_items_for_list)
require.Len(t, crosschainStateAfterImport.FinalizedInbounds, zetacored.Max_items_for_list)
require.Len(t, crosschainStateAfterImport.CrossChainTxs, zetacored.MaxItemsForList)
require.Len(t, crosschainStateAfterImport.InTxHashToCctxList, zetacored.MaxItemsForList)
require.Len(t, crosschainStateAfterImport.FinalizedInbounds, zetacored.MaxItemsForList)

// Bank module is in Skip list
var bankStateAfterImport banktypes.GenesisState
Expand Down

0 comments on commit 26f5e2c

Please sign in to comment.