diff --git a/e2e/utils/zetacore.go b/e2e/utils/zetacore.go index 8f169688b4..681e3bca7d 100644 --- a/e2e/utils/zetacore.go +++ b/e2e/utils/zetacore.go @@ -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( @@ -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( diff --git a/x/crosschain/keeper/cctx.go b/x/crosschain/keeper/cctx.go index 91d1735604..f93994587e 100644 --- a/x/crosschain/keeper/cctx.go +++ b/x/crosschain/keeper/cctx.go @@ -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, ) { @@ -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, ) { @@ -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, diff --git a/x/crosschain/keeper/export_private_functions_test.go b/x/crosschain/keeper/export_private_functions_test.go new file mode 100644 index 0000000000..b75e6b2c4d --- /dev/null +++ b/x/crosschain/keeper/export_private_functions_test.go @@ -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) +} diff --git a/x/crosschain/keeper/msg_server_abort_stuck_cctx.go b/x/crosschain/keeper/msg_server_abort_stuck_cctx.go index 94eee89b1d..7e2505b01e 100644 --- a/x/crosschain/keeper/msg_server_abort_stuck_cctx.go +++ b/x/crosschain/keeper/msg_server_abort_stuck_cctx.go @@ -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 } diff --git a/x/crosschain/types/status.go b/x/crosschain/types/status.go index d5eb303ab9..2df0444f6a 100644 --- a/x/crosschain/types/status.go +++ b/x/crosschain/types/status.go @@ -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 } diff --git a/x/crosschain/types/status_test.go b/x/crosschain/types/status_test.go index 526a4e74a4..f808f6e296 100644 --- a/x/crosschain/types/status_test.go +++ b/x/crosschain/types/status_test.go @@ -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()) }) } } @@ -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()) }) } }