diff --git a/x/crosschain/keeper/msg_server_add_to_intx_tracker_test.go b/x/crosschain/keeper/msg_server_add_to_intx_tracker_test.go index 391b5d2975..013f992fd9 100644 --- a/x/crosschain/keeper/msg_server_add_to_intx_tracker_test.go +++ b/x/crosschain/keeper/msg_server_add_to_intx_tracker_test.go @@ -43,79 +43,6 @@ func setupVerificationParams(zk keepertest.ZetaKeepers, ctx sdk.Context, tx_inde } func TestMsgServer_AddToInTxTracker(t *testing.T) { - t.Skip("add proof based tracker with correct proof", func(t *testing.T) { - k, ctx, _, zk := keepertest.CrosschainKeeper(t) - - chainID := int64(5) - - txIndex, block, header, headerRLP, proof, tx, err := sample.Proof() - require.NoError(t, err) - setupVerificationParams(zk, ctx, txIndex, chainID, header, headerRLP, block) - msgServer := keeper.NewMsgServerImpl(*k) - - _, err = msgServer.AddToInTxTracker(ctx, &types.MsgAddToInTxTracker{ - Creator: sample.AccAddress(), - ChainId: chainID, - TxHash: tx.Hash().Hex(), - CoinType: common.CoinType_Zeta, - Proof: proof, - BlockHash: block.Hash().Hex(), - TxIndex: txIndex, - }) - require.NoError(t, err) - _, found := k.GetInTxTracker(ctx, chainID, tx.Hash().Hex()) - require.True(t, found) - }) - - t.Skip("fail to add proof based tracker with wrong tx hash", func(t *testing.T) { - k, ctx, _, zk := keepertest.CrosschainKeeper(t) - - chainID := getValidEthChainID(t) - - txIndex, block, header, headerRLP, proof, tx, err := sample.Proof() - require.NoError(t, err) - setupVerificationParams(zk, ctx, txIndex, chainID, header, headerRLP, block) - msgServer := keeper.NewMsgServerImpl(*k) - - _, err = msgServer.AddToInTxTracker(ctx, &types.MsgAddToInTxTracker{ - Creator: sample.AccAddress(), - ChainId: chainID, - TxHash: "fake_hash", - CoinType: common.CoinType_Zeta, - Proof: proof, - BlockHash: block.Hash().Hex(), - TxIndex: txIndex, - }) - require.ErrorIs(t, err, types.ErrTxBodyVerificationFail) - _, found := k.GetInTxTracker(ctx, chainID, tx.Hash().Hex()) - require.False(t, found) - }) - - t.Skip("fail to add proof based tracker with wrong chain id", func(t *testing.T) { - k, ctx, _, zk := keepertest.CrosschainKeeper(t) - - chainID := getValidEthChainID(t) - - txIndex, block, header, headerRLP, proof, tx, err := sample.Proof() - require.NoError(t, err) - setupVerificationParams(zk, ctx, txIndex, chainID, header, headerRLP, block) - - msgServer := keeper.NewMsgServerImpl(*k) - - _, err = msgServer.AddToInTxTracker(ctx, &types.MsgAddToInTxTracker{ - Creator: sample.AccAddress(), - ChainId: 97, - TxHash: tx.Hash().Hex(), - CoinType: common.CoinType_Zeta, - Proof: proof, - BlockHash: block.Hash().Hex(), - TxIndex: txIndex, - }) - require.ErrorIs(t, err, observertypes.ErrSupportedChains) - _, found := k.GetInTxTracker(ctx, chainID, tx.Hash().Hex()) - require.False(t, found) - }) - t.Run("fail normal user submit without proof", func(t *testing.T) { k, ctx, _, zk := keepertest.CrosschainKeeper(t) tx_hash := "string" @@ -198,4 +125,78 @@ func TestMsgServer_AddToInTxTracker(t *testing.T) { _, found = k.GetInTxTracker(ctx, chainID, tx_hash) require.False(t, found) }) + + // Commented out as these tests don't work without using RPC + // TODO: Reenable these tests + // https://github.com/zeta-chain/node/issues/1875 + //t.Run("add proof based tracker with correct proof", func(t *testing.T) { + // k, ctx, _, zk := keepertest.CrosschainKeeper(t) + // + // chainID := int64(5) + // + // txIndex, block, header, headerRLP, proof, tx, err := sample.Proof() + // require.NoError(t, err) + // setupVerificationParams(zk, ctx, txIndex, chainID, header, headerRLP, block) + // msgServer := keeper.NewMsgServerImpl(*k) + // + // _, err = msgServer.AddToInTxTracker(ctx, &types.MsgAddToInTxTracker{ + // Creator: sample.AccAddress(), + // ChainId: chainID, + // TxHash: tx.Hash().Hex(), + // CoinType: common.CoinType_Zeta, + // Proof: proof, + // BlockHash: block.Hash().Hex(), + // TxIndex: txIndex, + // }) + // require.NoError(t, err) + // _, found := k.GetInTxTracker(ctx, chainID, tx.Hash().Hex()) + // require.True(t, found) + //}) + //t.Run("fail to add proof based tracker with wrong tx hash", func(t *testing.T) { + // k, ctx, _, zk := keepertest.CrosschainKeeper(t) + // + // chainID := getValidEthChainID(t) + // + // txIndex, block, header, headerRLP, proof, tx, err := sample.Proof() + // require.NoError(t, err) + // setupVerificationParams(zk, ctx, txIndex, chainID, header, headerRLP, block) + // msgServer := keeper.NewMsgServerImpl(*k) + // + // _, err = msgServer.AddToInTxTracker(ctx, &types.MsgAddToInTxTracker{ + // Creator: sample.AccAddress(), + // ChainId: chainID, + // TxHash: "fake_hash", + // CoinType: common.CoinType_Zeta, + // Proof: proof, + // BlockHash: block.Hash().Hex(), + // TxIndex: txIndex, + // }) + // require.ErrorIs(t, err, types.ErrTxBodyVerificationFail) + // _, found := k.GetInTxTracker(ctx, chainID, tx.Hash().Hex()) + // require.False(t, found) + //}) + //t.Run("fail to add proof based tracker with wrong chain id", func(t *testing.T) { + // k, ctx, _, zk := keepertest.CrosschainKeeper(t) + // + // chainID := getValidEthChainID(t) + // + // txIndex, block, header, headerRLP, proof, tx, err := sample.Proof() + // require.NoError(t, err) + // setupVerificationParams(zk, ctx, txIndex, chainID, header, headerRLP, block) + // + // msgServer := keeper.NewMsgServerImpl(*k) + // + // _, err = msgServer.AddToInTxTracker(ctx, &types.MsgAddToInTxTracker{ + // Creator: sample.AccAddress(), + // ChainId: 97, + // TxHash: tx.Hash().Hex(), + // CoinType: common.CoinType_Zeta, + // Proof: proof, + // BlockHash: block.Hash().Hex(), + // TxIndex: txIndex, + // }) + // require.ErrorIs(t, err, observertypes.ErrSupportedChains) + // _, found := k.GetInTxTracker(ctx, chainID, tx.Hash().Hex()) + // require.False(t, found) + //}) } diff --git a/x/crosschain/keeper/msg_server_add_to_outtx_tracker_test.go b/x/crosschain/keeper/msg_server_add_to_outtx_tracker_test.go index 994be1072a..24174733b0 100644 --- a/x/crosschain/keeper/msg_server_add_to_outtx_tracker_test.go +++ b/x/crosschain/keeper/msg_server_add_to_outtx_tracker_test.go @@ -5,8 +5,6 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" - "github.com/zeta-chain/zetacore/common" - "github.com/zeta-chain/zetacore/common/ethereum" keepertest "github.com/zeta-chain/zetacore/testutil/keeper" "github.com/zeta-chain/zetacore/testutil/sample" authoritytypes "github.com/zeta-chain/zetacore/x/authority/types" @@ -20,8 +18,21 @@ func getEthereumChainID() int64 { } -func setupTssAndNonceToCctx(k *keeper.Keeper, ctx sdk.Context, chainId, nonce int64) { +// setEnabledChain sets the chain as enabled in chain params +func setEnabledChain(ctx sdk.Context, zk keepertest.ZetaKeepers, chainID int64) { + zk.ObserverKeeper.SetChainParamsList(ctx, observertypes.ChainParamsList{ChainParams: []*observertypes.ChainParams{ + { + ChainId: chainID, + ConnectorContractAddress: sample.EthAddress().Hex(), + BallotThreshold: sdk.OneDec(), + MinObserverDelegation: sdk.OneDec(), + IsSupported: true, + }, + }}) +} +// setupTssAndNonceToCctx sets tss and nonce to cctx +func setupTssAndNonceToCctx(k *keeper.Keeper, ctx sdk.Context, chainId, nonce int64) { tssPubKey := "zetapub1addwnpepq28c57cvcs0a2htsem5zxr6qnlvq9mzhmm76z3jncsnzz32rclangr2g35p" k.GetObserverKeeper().SetTSS(ctx, observertypes.TSS{ TssPubkey: tssPubKey, @@ -49,7 +60,7 @@ func setupTssAndNonceToCctx(k *keeper.Keeper, ctx sdk.Context, chainId, nonce in } func TestMsgServer_AddToOutTxTracker(t *testing.T) { - t.Skip("add tracker admin", func(t *testing.T) { + t.Run("add tracker admin", func(t *testing.T) { k, ctx, _, zk := keepertest.CrosschainKeeperWithMocks(t, keepertest.CrosschainMockOptions{ UseAuthorityMock: true, }) @@ -59,17 +70,15 @@ func TestMsgServer_AddToOutTxTracker(t *testing.T) { keepertest.MockIsAuthorized(&authorityMock.Mock, admin, authoritytypes.PolicyType_groupEmergency, true) chainID := getEthereumChainID() - txIndex, block, header, headerRLP, _, tx, err := sample.Proof() - require.NoError(t, err) - setupVerificationParams(zk, ctx, txIndex, chainID, header, headerRLP, block) setupTssAndNonceToCctx(k, ctx, chainID, 0) + setEnabledChain(ctx, zk, chainID) msgServer := keeper.NewMsgServerImpl(*k) - _, err = msgServer.AddToOutTxTracker(ctx, &types.MsgAddToOutTxTracker{ + _, err := msgServer.AddToOutTxTracker(ctx, &types.MsgAddToOutTxTracker{ Creator: admin, ChainId: chainID, - TxHash: tx.Hash().Hex(), + TxHash: sample.Hash().Hex(), Proof: nil, BlockHash: "", TxIndex: 0, @@ -80,7 +89,7 @@ func TestMsgServer_AddToOutTxTracker(t *testing.T) { require.True(t, found) }) - t.Skip("unable to add tracker admin exceeding maximum allowed length of hashlist without proof", func(t *testing.T) { + t.Run("unable to add tracker admin exceeding maximum allowed length of hashlist without proof", func(t *testing.T) { k, ctx, _, zk := keepertest.CrosschainKeeperWithMocks(t, keepertest.CrosschainMockOptions{ UseAuthorityMock: true, }) @@ -90,10 +99,8 @@ func TestMsgServer_AddToOutTxTracker(t *testing.T) { keepertest.MockIsAuthorized(&authorityMock.Mock, admin, authoritytypes.PolicyType_groupEmergency, true) chainID := getEthereumChainID() - txIndex, block, header, headerRLP, _, tx, err := sample.Proof() - require.NoError(t, err) - setupVerificationParams(zk, ctx, txIndex, chainID, header, headerRLP, block) setupTssAndNonceToCctx(k, ctx, chainID, 0) + setEnabledChain(ctx, zk, chainID) k.SetOutTxTracker(ctx, types.OutTxTracker{ ChainId: chainID, @@ -114,10 +121,10 @@ func TestMsgServer_AddToOutTxTracker(t *testing.T) { msgServer := keeper.NewMsgServerImpl(*k) - _, err = msgServer.AddToOutTxTracker(ctx, &types.MsgAddToOutTxTracker{ + _, err := msgServer.AddToOutTxTracker(ctx, &types.MsgAddToOutTxTracker{ Creator: admin, ChainId: chainID, - TxHash: tx.Hash().Hex(), + TxHash: sample.Hash().Hex(), Proof: nil, BlockHash: "", TxIndex: 0, @@ -129,220 +136,223 @@ func TestMsgServer_AddToOutTxTracker(t *testing.T) { require.Equal(t, 2, len(tracker.HashList)) }) - t.Skip("fail add proof based tracker with wrong chainID", func(t *testing.T) { - k, ctx, _, zk := keepertest.CrosschainKeeper(t) - - chainID := getEthereumChainID() - - txIndex, block, header, headerRLP, proof, tx, err := sample.Proof() - require.NoError(t, err) - setupVerificationParams(zk, ctx, txIndex, chainID, header, headerRLP, block) - setupTssAndNonceToCctx(k, ctx, chainID, int64(tx.Nonce())) - - msgServer := keeper.NewMsgServerImpl(*k) - - _, err = msgServer.AddToOutTxTracker(ctx, &types.MsgAddToOutTxTracker{ - Creator: sample.AccAddress(), - ChainId: 97, - TxHash: tx.Hash().Hex(), - Proof: proof, - BlockHash: block.Hash().Hex(), - TxIndex: txIndex, - Nonce: tx.Nonce(), - }) - require.ErrorIs(t, err, observertypes.ErrSupportedChains) - _, found := k.GetOutTxTracker(ctx, chainID, tx.Nonce()) - require.False(t, found) - }) - - t.Skip("fail add proof based tracker with wrong nonce", func(t *testing.T) { - k, ctx, _, zk := keepertest.CrosschainKeeper(t) - - chainID := getEthereumChainID() - - txIndex, block, header, headerRLP, proof, tx, err := sample.Proof() - require.NoError(t, err) - setupVerificationParams(zk, ctx, txIndex, chainID, header, headerRLP, block) - setupTssAndNonceToCctx(k, ctx, chainID, 1) - - msgServer := keeper.NewMsgServerImpl(*k) - - _, err = msgServer.AddToOutTxTracker(ctx, &types.MsgAddToOutTxTracker{ - Creator: sample.AccAddress(), - ChainId: chainID, - TxHash: tx.Hash().Hex(), - Proof: proof, - BlockHash: block.Hash().Hex(), - TxIndex: txIndex, - Nonce: 1, - }) - require.ErrorIs(t, err, types.ErrTxBodyVerificationFail) - _, found := k.GetOutTxTracker(ctx, chainID, 1) - require.False(t, found) - }) - - t.Skip("fail add proof based tracker with wrong tx_hash", func(t *testing.T) { - k, ctx, _, zk := keepertest.CrosschainKeeper(t) - - chainID := getEthereumChainID() - - txIndex, block, header, headerRLP, proof, tx, err := sample.Proof() - require.NoError(t, err) - setupVerificationParams(zk, ctx, txIndex, chainID, header, headerRLP, block) - setupTssAndNonceToCctx(k, ctx, chainID, int64(tx.Nonce())) - - msgServer := keeper.NewMsgServerImpl(*k) - _, err = msgServer.AddToOutTxTracker(ctx, &types.MsgAddToOutTxTracker{ - Creator: sample.AccAddress(), - ChainId: chainID, - TxHash: "wrong_hash", - Proof: proof, - BlockHash: block.Hash().Hex(), - TxIndex: txIndex, - Nonce: tx.Nonce(), - }) - require.ErrorIs(t, err, types.ErrTxBodyVerificationFail) - _, found := k.GetOutTxTracker(ctx, chainID, tx.Nonce()) - require.False(t, found) - }) - - t.Skip("fail proof based tracker with incorrect proof", func(t *testing.T) { - - k, ctx, _, zk := keepertest.CrosschainKeeper(t) - chainID := getEthereumChainID() - - txIndex, block, header, headerRLP, _, tx, err := sample.Proof() - require.NoError(t, err) - setupVerificationParams(zk, ctx, txIndex, chainID, header, headerRLP, block) - setupTssAndNonceToCctx(k, ctx, chainID, int64(tx.Nonce())) - - msgServer := keeper.NewMsgServerImpl(*k) - - _, err = msgServer.AddToOutTxTracker(ctx, &types.MsgAddToOutTxTracker{ - Creator: sample.AccAddress(), - ChainId: chainID, - TxHash: tx.Hash().Hex(), - Proof: common.NewEthereumProof(ethereum.NewProof()), - BlockHash: block.Hash().Hex(), - TxIndex: txIndex, - Nonce: tx.Nonce(), - }) - require.ErrorIs(t, err, types.ErrProofVerificationFail) - _, found := k.GetOutTxTracker(ctx, chainID, tx.Nonce()) - require.False(t, found) - }) - - t.Skip("add proof based tracker with correct proof", func(t *testing.T) { - k, ctx, _, zk := keepertest.CrosschainKeeper(t) - - chainID := getEthereumChainID() - txIndex, block, header, headerRLP, proof, tx, err := sample.Proof() - require.NoError(t, err) - setupVerificationParams(zk, ctx, txIndex, chainID, header, headerRLP, block) - setupTssAndNonceToCctx(k, ctx, chainID, int64(tx.Nonce())) - - msgServer := keeper.NewMsgServerImpl(*k) - - _, err = msgServer.AddToOutTxTracker(ctx, &types.MsgAddToOutTxTracker{ - Creator: sample.AccAddress(), - ChainId: chainID, - TxHash: tx.Hash().Hex(), - Proof: proof, - BlockHash: block.Hash().Hex(), - TxIndex: txIndex, - Nonce: tx.Nonce(), - }) - require.NoError(t, err) - _, found := k.GetOutTxTracker(ctx, chainID, tx.Nonce()) - require.True(t, found) - }) - - t.Skip("add proven txHash even if length of hashList is already 2", func(t *testing.T) { - k, ctx, _, zk := keepertest.CrosschainKeeper(t) - - chainID := getEthereumChainID() - - txIndex, block, header, headerRLP, proof, tx, err := sample.Proof() - require.NoError(t, err) - setupVerificationParams(zk, ctx, txIndex, chainID, header, headerRLP, block) - setupTssAndNonceToCctx(k, ctx, chainID, int64(tx.Nonce())) - k.SetOutTxTracker(ctx, types.OutTxTracker{ - ChainId: chainID, - Nonce: tx.Nonce(), - HashList: []*types.TxHashList{ - { - TxHash: "hash1", - TxSigner: sample.AccAddress(), - Proved: false, - }, - { - TxHash: "hash2", - TxSigner: sample.AccAddress(), - Proved: false, - }, - }, - }) - - msgServer := keeper.NewMsgServerImpl(*k) - - _, err = msgServer.AddToOutTxTracker(ctx, &types.MsgAddToOutTxTracker{ - Creator: sample.AccAddress(), - ChainId: chainID, - TxHash: tx.Hash().Hex(), - Proof: proof, - BlockHash: block.Hash().Hex(), - TxIndex: txIndex, - Nonce: tx.Nonce(), - }) - require.NoError(t, err) - tracker, found := k.GetOutTxTracker(ctx, chainID, tx.Nonce()) - require.True(t, found) - require.Equal(t, 3, len(tracker.HashList)) - // Proven tracker is prepended to the list - require.True(t, tracker.HashList[0].Proved) - require.False(t, tracker.HashList[1].Proved) - require.False(t, tracker.HashList[2].Proved) - }) - - t.Skip("add proof for existing txHash", func(t *testing.T) { - k, ctx, _, zk := keepertest.CrosschainKeeper(t) - - chainID := getEthereumChainID() - - txIndex, block, header, headerRLP, proof, tx, err := sample.Proof() - require.NoError(t, err) - setupVerificationParams(zk, ctx, txIndex, chainID, header, headerRLP, block) - setupTssAndNonceToCctx(k, ctx, chainID, int64(tx.Nonce())) - k.SetOutTxTracker(ctx, types.OutTxTracker{ - ChainId: chainID, - Nonce: tx.Nonce(), - HashList: []*types.TxHashList{ - { - TxHash: tx.Hash().Hex(), - TxSigner: sample.AccAddress(), - Proved: false, - }, - }, - }) - tracker, found := k.GetOutTxTracker(ctx, chainID, tx.Nonce()) - require.True(t, found) - require.False(t, tracker.HashList[0].Proved) - - msgServer := keeper.NewMsgServerImpl(*k) - - _, err = msgServer.AddToOutTxTracker(ctx, &types.MsgAddToOutTxTracker{ - Creator: sample.AccAddress(), - ChainId: chainID, - TxHash: tx.Hash().Hex(), - Proof: proof, - BlockHash: block.Hash().Hex(), - TxIndex: txIndex, - Nonce: tx.Nonce(), - }) - require.NoError(t, err) - tracker, found = k.GetOutTxTracker(ctx, chainID, tx.Nonce()) - require.True(t, found) - require.Equal(t, 1, len(tracker.HashList)) - require.True(t, tracker.HashList[0].Proved) - }) + // Commented out as these tests don't work without using RPC + // TODO: Reenable these tests + // https://github.com/zeta-chain/node/issues/1875 + //t.Run("fail add proof based tracker with wrong chainID", func(t *testing.T) { + // k, ctx, _, zk := keepertest.CrosschainKeeper(t) + // + // chainID := getEthereumChainID() + // + // txIndex, block, header, headerRLP, proof, tx, err := sample.Proof() + // require.NoError(t, err) + // setupVerificationParams(zk, ctx, txIndex, chainID, header, headerRLP, block) + // setupTssAndNonceToCctx(k, ctx, chainID, int64(tx.Nonce())) + // + // msgServer := keeper.NewMsgServerImpl(*k) + // + // _, err = msgServer.AddToOutTxTracker(ctx, &types.MsgAddToOutTxTracker{ + // Creator: sample.AccAddress(), + // ChainId: 97, + // TxHash: tx.Hash().Hex(), + // Proof: proof, + // BlockHash: block.Hash().Hex(), + // TxIndex: txIndex, + // Nonce: tx.Nonce(), + // }) + // require.ErrorIs(t, err, observertypes.ErrSupportedChains) + // _, found := k.GetOutTxTracker(ctx, chainID, tx.Nonce()) + // require.False(t, found) + //}) + // + //t.Run("fail add proof based tracker with wrong nonce", func(t *testing.T) { + // k, ctx, _, zk := keepertest.CrosschainKeeper(t) + // + // chainID := getEthereumChainID() + // + // txIndex, block, header, headerRLP, proof, tx, err := sample.Proof() + // require.NoError(t, err) + // setupVerificationParams(zk, ctx, txIndex, chainID, header, headerRLP, block) + // setupTssAndNonceToCctx(k, ctx, chainID, 1) + // + // msgServer := keeper.NewMsgServerImpl(*k) + // + // _, err = msgServer.AddToOutTxTracker(ctx, &types.MsgAddToOutTxTracker{ + // Creator: sample.AccAddress(), + // ChainId: chainID, + // TxHash: tx.Hash().Hex(), + // Proof: proof, + // BlockHash: block.Hash().Hex(), + // TxIndex: txIndex, + // Nonce: 1, + // }) + // require.ErrorIs(t, err, types.ErrTxBodyVerificationFail) + // _, found := k.GetOutTxTracker(ctx, chainID, 1) + // require.False(t, found) + //}) + // + //t.Run("fail add proof based tracker with wrong tx_hash", func(t *testing.T) { + // k, ctx, _, zk := keepertest.CrosschainKeeper(t) + // + // chainID := getEthereumChainID() + // + // txIndex, block, header, headerRLP, proof, tx, err := sample.Proof() + // require.NoError(t, err) + // setupVerificationParams(zk, ctx, txIndex, chainID, header, headerRLP, block) + // setupTssAndNonceToCctx(k, ctx, chainID, int64(tx.Nonce())) + // + // msgServer := keeper.NewMsgServerImpl(*k) + // _, err = msgServer.AddToOutTxTracker(ctx, &types.MsgAddToOutTxTracker{ + // Creator: sample.AccAddress(), + // ChainId: chainID, + // TxHash: "wrong_hash", + // Proof: proof, + // BlockHash: block.Hash().Hex(), + // TxIndex: txIndex, + // Nonce: tx.Nonce(), + // }) + // require.ErrorIs(t, err, types.ErrTxBodyVerificationFail) + // _, found := k.GetOutTxTracker(ctx, chainID, tx.Nonce()) + // require.False(t, found) + //}) + // + //t.Run("fail proof based tracker with incorrect proof", func(t *testing.T) { + // + // k, ctx, _, zk := keepertest.CrosschainKeeper(t) + // chainID := getEthereumChainID() + // + // txIndex, block, header, headerRLP, _, tx, err := sample.Proof() + // require.NoError(t, err) + // setupVerificationParams(zk, ctx, txIndex, chainID, header, headerRLP, block) + // setupTssAndNonceToCctx(k, ctx, chainID, int64(tx.Nonce())) + // + // msgServer := keeper.NewMsgServerImpl(*k) + // + // _, err = msgServer.AddToOutTxTracker(ctx, &types.MsgAddToOutTxTracker{ + // Creator: sample.AccAddress(), + // ChainId: chainID, + // TxHash: tx.Hash().Hex(), + // Proof: common.NewEthereumProof(ethereum.NewProof()), + // BlockHash: block.Hash().Hex(), + // TxIndex: txIndex, + // Nonce: tx.Nonce(), + // }) + // require.ErrorIs(t, err, types.ErrProofVerificationFail) + // _, found := k.GetOutTxTracker(ctx, chainID, tx.Nonce()) + // require.False(t, found) + //}) + // + //t.Run("add proof based tracker with correct proof", func(t *testing.T) { + // k, ctx, _, zk := keepertest.CrosschainKeeper(t) + // + // chainID := getEthereumChainID() + // txIndex, block, header, headerRLP, proof, tx, err := sample.Proof() + // require.NoError(t, err) + // setupVerificationParams(zk, ctx, txIndex, chainID, header, headerRLP, block) + // setupTssAndNonceToCctx(k, ctx, chainID, int64(tx.Nonce())) + // + // msgServer := keeper.NewMsgServerImpl(*k) + // + // _, err = msgServer.AddToOutTxTracker(ctx, &types.MsgAddToOutTxTracker{ + // Creator: sample.AccAddress(), + // ChainId: chainID, + // TxHash: tx.Hash().Hex(), + // Proof: proof, + // BlockHash: block.Hash().Hex(), + // TxIndex: txIndex, + // Nonce: tx.Nonce(), + // }) + // require.NoError(t, err) + // _, found := k.GetOutTxTracker(ctx, chainID, tx.Nonce()) + // require.True(t, found) + //}) + // + //t.Run("add proven txHash even if length of hashList is already 2", func(t *testing.T) { + // k, ctx, _, zk := keepertest.CrosschainKeeper(t) + // + // chainID := getEthereumChainID() + // + // txIndex, block, header, headerRLP, proof, tx, err := sample.Proof() + // require.NoError(t, err) + // setupVerificationParams(zk, ctx, txIndex, chainID, header, headerRLP, block) + // setupTssAndNonceToCctx(k, ctx, chainID, int64(tx.Nonce())) + // k.SetOutTxTracker(ctx, types.OutTxTracker{ + // ChainId: chainID, + // Nonce: tx.Nonce(), + // HashList: []*types.TxHashList{ + // { + // TxHash: "hash1", + // TxSigner: sample.AccAddress(), + // Proved: false, + // }, + // { + // TxHash: "hash2", + // TxSigner: sample.AccAddress(), + // Proved: false, + // }, + // }, + // }) + // + // msgServer := keeper.NewMsgServerImpl(*k) + // + // _, err = msgServer.AddToOutTxTracker(ctx, &types.MsgAddToOutTxTracker{ + // Creator: sample.AccAddress(), + // ChainId: chainID, + // TxHash: tx.Hash().Hex(), + // Proof: proof, + // BlockHash: block.Hash().Hex(), + // TxIndex: txIndex, + // Nonce: tx.Nonce(), + // }) + // require.NoError(t, err) + // tracker, found := k.GetOutTxTracker(ctx, chainID, tx.Nonce()) + // require.True(t, found) + // require.Equal(t, 3, len(tracker.HashList)) + // // Proven tracker is prepended to the list + // require.True(t, tracker.HashList[0].Proved) + // require.False(t, tracker.HashList[1].Proved) + // require.False(t, tracker.HashList[2].Proved) + //}) + // + //t.Run("add proof for existing txHash", func(t *testing.T) { + // k, ctx, _, zk := keepertest.CrosschainKeeper(t) + // + // chainID := getEthereumChainID() + // + // txIndex, block, header, headerRLP, proof, tx, err := sample.Proof() + // require.NoError(t, err) + // setupVerificationParams(zk, ctx, txIndex, chainID, header, headerRLP, block) + // setupTssAndNonceToCctx(k, ctx, chainID, int64(tx.Nonce())) + // k.SetOutTxTracker(ctx, types.OutTxTracker{ + // ChainId: chainID, + // Nonce: tx.Nonce(), + // HashList: []*types.TxHashList{ + // { + // TxHash: tx.Hash().Hex(), + // TxSigner: sample.AccAddress(), + // Proved: false, + // }, + // }, + // }) + // tracker, found := k.GetOutTxTracker(ctx, chainID, tx.Nonce()) + // require.True(t, found) + // require.False(t, tracker.HashList[0].Proved) + // + // msgServer := keeper.NewMsgServerImpl(*k) + // + // _, err = msgServer.AddToOutTxTracker(ctx, &types.MsgAddToOutTxTracker{ + // Creator: sample.AccAddress(), + // ChainId: chainID, + // TxHash: tx.Hash().Hex(), + // Proof: proof, + // BlockHash: block.Hash().Hex(), + // TxIndex: txIndex, + // Nonce: tx.Nonce(), + // }) + // require.NoError(t, err) + // tracker, found = k.GetOutTxTracker(ctx, chainID, tx.Nonce()) + // require.True(t, found) + // require.Equal(t, 1, len(tracker.HashList)) + // require.True(t, tracker.HashList[0].Proved) + //}) }