Skip to content

Commit

Permalink
make functions private
Browse files Browse the repository at this point in the history
  • Loading branch information
kingpinXD committed Dec 3, 2024
1 parent c50a6ea commit 40fade6
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 15 deletions.
4 changes: 2 additions & 2 deletions e2e/utils/zetacore.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ func WaitCctxsMinedByInboundHash(
allFound := true
for j, cctx := range res.CrossChainTxs {
cctx := cctx
if !cctx.CctxStatus.Status.IsTerminalStatus() {
if !cctx.CctxStatus.Status.IsTerminal() {
// prevent spamming logs
if i%20 == 0 {
logger.Info(
Expand Down Expand Up @@ -170,7 +170,7 @@ func WaitCCTXMinedByIndex(
}

cctx := res.CrossChainTx
if !cctx.CctxStatus.Status.IsTerminalStatus() {
if !cctx.CctxStatus.Status.IsTerminal() {
// prevent spamming logs
if i%20 == 0 {
logger.Info(
Expand Down
16 changes: 8 additions & 8 deletions x/crosschain/keeper/cctx.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ func (k Keeper) SetCctxAndNonceToCctxAndInboundHashToCctx(
cctx types.CrossChainTx,
tssPubkey string,
) {
k.SetNonceToCCTXMapping(ctx, cctx, tssPubkey)
k.setNonceToCCTXMapping(ctx, cctx, tssPubkey)
k.SetCrossChainTx(ctx, cctx)
k.UpdateInboundHashToCCTX(ctx, cctx)
k.UpdateZetaAccounting(ctx, cctx)
k.updateInboundHashToCCTX(ctx, cctx)
k.updateZetaAccounting(ctx, cctx)
}

// UpdateInboundHashToCCTX updates the mapping between an inbound hash and a cctx index.
// updateInboundHashToCCTX updates the mapping between an inbound hash and a cctx index.
// A new index is added to the list of cctx indexes if it is not already present
func (k Keeper) UpdateInboundHashToCCTX(
func (k Keeper) updateInboundHashToCCTX(
ctx sdk.Context,
cctx types.CrossChainTx,
) {
Expand All @@ -61,7 +61,7 @@ func (k Keeper) UpdateInboundHashToCCTX(
k.SetInboundHashToCctx(ctx, in)
}

func (k Keeper) UpdateZetaAccounting(
func (k Keeper) updateZetaAccounting(
ctx sdk.Context,
cctx types.CrossChainTx,
) {
Expand All @@ -70,8 +70,8 @@ func (k Keeper) UpdateZetaAccounting(
}
}

// SetNonceToCCTXMapping updates the mapping between a nonce and a cctx index if the cctx is in a PendingOutbound or PendingRevert state
func (k Keeper) SetNonceToCCTXMapping(
// setNonceToCCTXMapping updates the mapping between a nonce and a cctx index if the cctx is in a PendingOutbound or PendingRevert state
func (k Keeper) setNonceToCCTXMapping(
ctx sdk.Context,
cctx types.CrossChainTx,
tssPubkey string,
Expand Down
20 changes: 20 additions & 0 deletions x/crosschain/keeper/export_private_functions_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package keeper

import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/zeta-chain/node/x/crosschain/types"
)

// These functions are exported for testing purposes

func (k Keeper) UpdateZetaAccounting(ctx sdk.Context, cctx types.CrossChainTx) {
k.updateZetaAccounting(ctx, cctx)
}

func (k Keeper) UpdateInboundHashToCCTX(ctx sdk.Context, cctx types.CrossChainTx) {
k.updateInboundHashToCCTX(ctx, cctx)
}

func (k Keeper) SetNonceToCCTXMapping(ctx sdk.Context, cctx types.CrossChainTx, tssPubkey string) {
k.setNonceToCCTXMapping(ctx, cctx, tssPubkey)
}
2 changes: 1 addition & 1 deletion x/crosschain/keeper/msg_server_abort_stuck_cctx.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func (k msgServer) AbortStuckCCTX(
}

// check if the cctx is pending
if !cctx.CctxStatus.Status.IsPendingStatus() {
if !cctx.CctxStatus.Status.IsPending() {
return nil, types.ErrStatusNotPending
}

Expand Down
4 changes: 2 additions & 2 deletions x/crosschain/types/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,10 @@ func stateTransitionMap() map[CctxStatus][]CctxStatus {
return stateTransitionMap
}

func (c CctxStatus) IsTerminalStatus() bool {
func (c CctxStatus) IsTerminal() bool {
return c == CctxStatus_Aborted || c == CctxStatus_Reverted || c == CctxStatus_OutboundMined
}

func (c CctxStatus) IsPendingStatus() bool {
func (c CctxStatus) IsPending() bool {
return c == CctxStatus_PendingInbound || c == CctxStatus_PendingOutbound || c == CctxStatus_PendingRevert
}
4 changes: 2 additions & 2 deletions x/crosschain/types/status_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ func TestCctxStatus_IsTerminalStatus(t *testing.T) {

for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
assert.Equal(t, tc.expected, tc.status.IsTerminalStatus())
assert.Equal(t, tc.expected, tc.status.IsTerminal())
})
}
}
Expand All @@ -212,7 +212,7 @@ func TestCctxStatus_IsPendingStatus(t *testing.T) {

for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
assert.Equal(t, tc.expected, tc.status.IsPendingStatus())
assert.Equal(t, tc.expected, tc.status.IsPending())
})
}
}

0 comments on commit 40fade6

Please sign in to comment.