-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
10 changed files
with
268 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
package evm_test | ||
|
||
import ( | ||
"context" | ||
"math/big" | ||
"strings" | ||
"testing" | ||
|
||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/ethereum/go-ethereum/common" | ||
geth "github.com/ethereum/go-ethereum/core/types" | ||
"github.com/stretchr/testify/assert" | ||
|
||
mock2 "github.com/axelarnetwork/axelar-core/sdk-utils/broadcast/mock" | ||
"github.com/axelarnetwork/axelar-core/testutils/rand" | ||
"github.com/axelarnetwork/axelar-core/vald/evm" | ||
evmmock "github.com/axelarnetwork/axelar-core/vald/evm/mock" | ||
evmRpc "github.com/axelarnetwork/axelar-core/vald/evm/rpc" | ||
"github.com/axelarnetwork/axelar-core/vald/evm/rpc/mock" | ||
"github.com/axelarnetwork/axelar-core/x/evm/types" | ||
nexus "github.com/axelarnetwork/axelar-core/x/nexus/exported" | ||
"github.com/axelarnetwork/axelar-core/x/vote/exported" | ||
"github.com/axelarnetwork/utils/monads/results" | ||
) | ||
|
||
func TestMgr_ProcessGatewayTxConfirmationMissingBlockNumberNotPanics(t *testing.T) { | ||
chain := nexus.ChainName(strings.ToLower(rand.NormalizedStr(5))) | ||
receipt := geth.Receipt{Logs: []*geth.Log{{Topics: make([]common.Hash, 0)}}} | ||
rpcClient := &mock.ClientMock{TransactionReceiptsFunc: func(_ context.Context, _ []common.Hash) ([]evmRpc.TxReceiptResult, error) { | ||
return []evmRpc.TxReceiptResult{evmRpc.TxReceiptResult(results.FromOk(receipt))}, nil | ||
}} | ||
cache := &evmmock.LatestFinalizedBlockCacheMock{GetFunc: func(chain nexus.ChainName) *big.Int { | ||
return big.NewInt(100) | ||
}} | ||
|
||
broadcaster := &mock2.BroadcasterMock{BroadcastFunc: func(_ context.Context, _ ...sdk.Msg) (*sdk.TxResponse, error) { | ||
return nil, nil | ||
}} | ||
|
||
valAddr := rand.ValAddr() | ||
mgr := evm.NewMgr(map[string]evmRpc.Client{chain.String(): rpcClient}, broadcaster, valAddr, rand.AccAddr(), cache) | ||
|
||
assert.NotPanics(t, func() { | ||
mgr.ProcessGatewayTxConfirmation(&types.ConfirmGatewayTxStarted{TxID: types.Hash{1}, | ||
PollParticipants: exported.PollParticipants{PollID: 10, Participants: []sdk.ValAddress{valAddr}}, | ||
Chain: chain, | ||
}) | ||
}) | ||
} | ||
|
||
func TestMgr_ProcessGatewayTxConfirmationNoTopicsNotPanics(t *testing.T) { | ||
chain := nexus.ChainName(strings.ToLower(rand.NormalizedStr(5))) | ||
receipt := geth.Receipt{ | ||
Logs: []*geth.Log{{Topics: make([]common.Hash, 0)}}, | ||
BlockNumber: big.NewInt(1), | ||
Status: geth.ReceiptStatusSuccessful, | ||
} | ||
rpcClient := &mock.ClientMock{TransactionReceiptsFunc: func(_ context.Context, _ []common.Hash) ([]evmRpc.TxReceiptResult, error) { | ||
return []evmRpc.TxReceiptResult{evmRpc.TxReceiptResult(results.FromOk(receipt))}, nil | ||
}} | ||
cache := &evmmock.LatestFinalizedBlockCacheMock{GetFunc: func(chain nexus.ChainName) *big.Int { | ||
return big.NewInt(100) | ||
}} | ||
|
||
broadcaster := &mock2.BroadcasterMock{BroadcastFunc: func(_ context.Context, _ ...sdk.Msg) (*sdk.TxResponse, error) { | ||
return nil, nil | ||
}} | ||
|
||
valAddr := rand.ValAddr() | ||
mgr := evm.NewMgr(map[string]evmRpc.Client{chain.String(): rpcClient}, broadcaster, valAddr, rand.AccAddr(), cache) | ||
|
||
assert.NotPanics(t, func() { | ||
mgr.ProcessGatewayTxConfirmation(&types.ConfirmGatewayTxStarted{TxID: types.Hash{1}, | ||
PollParticipants: exported.PollParticipants{PollID: 10, Participants: []sdk.ValAddress{valAddr}}, | ||
Chain: chain, | ||
}) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
package evm_test | ||
|
||
import ( | ||
"context" | ||
"math/big" | ||
"strings" | ||
"testing" | ||
|
||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/ethereum/go-ethereum/common" | ||
geth "github.com/ethereum/go-ethereum/core/types" | ||
"github.com/stretchr/testify/assert" | ||
|
||
mock2 "github.com/axelarnetwork/axelar-core/sdk-utils/broadcast/mock" | ||
"github.com/axelarnetwork/axelar-core/testutils/rand" | ||
"github.com/axelarnetwork/axelar-core/vald/evm" | ||
evmmock "github.com/axelarnetwork/axelar-core/vald/evm/mock" | ||
evmRpc "github.com/axelarnetwork/axelar-core/vald/evm/rpc" | ||
"github.com/axelarnetwork/axelar-core/vald/evm/rpc/mock" | ||
"github.com/axelarnetwork/axelar-core/x/evm/types" | ||
nexus "github.com/axelarnetwork/axelar-core/x/nexus/exported" | ||
"github.com/axelarnetwork/utils/monads/results" | ||
) | ||
|
||
func TestMgr_ProcessGatewayTxsConfirmationMissingBlockNumberNotPanics(t *testing.T) { | ||
chain := nexus.ChainName(strings.ToLower(rand.NormalizedStr(5))) | ||
receipt := geth.Receipt{Logs: []*geth.Log{{Topics: make([]common.Hash, 0)}}} | ||
rpcClient := &mock.ClientMock{TransactionReceiptsFunc: func(_ context.Context, _ []common.Hash) ([]evmRpc.TxReceiptResult, error) { | ||
return []evmRpc.TxReceiptResult{evmRpc.TxReceiptResult(results.FromOk(receipt))}, nil | ||
}} | ||
cache := &evmmock.LatestFinalizedBlockCacheMock{GetFunc: func(chain nexus.ChainName) *big.Int { | ||
return big.NewInt(100) | ||
}} | ||
|
||
broadcaster := &mock2.BroadcasterMock{BroadcastFunc: func(_ context.Context, _ ...sdk.Msg) (*sdk.TxResponse, error) { | ||
return nil, nil | ||
}} | ||
|
||
valAddr := rand.ValAddr() | ||
mgr := evm.NewMgr(map[string]evmRpc.Client{chain.String(): rpcClient}, broadcaster, valAddr, rand.AccAddr(), cache) | ||
|
||
assert.NotPanics(t, func() { | ||
mgr.ProcessGatewayTxsConfirmation(&types.ConfirmGatewayTxsStarted{ | ||
PollMappings: []types.PollMapping{{PollID: 10, TxID: types.Hash{1}}}, | ||
Participants: []sdk.ValAddress{valAddr}, | ||
Chain: chain, | ||
}) | ||
}) | ||
} | ||
|
||
func TestMgr_ProcessGatewayTxsConfirmationNoTopicsNotPanics(t *testing.T) { | ||
chain := nexus.ChainName(strings.ToLower(rand.NormalizedStr(5))) | ||
receipt := geth.Receipt{ | ||
Logs: []*geth.Log{{Topics: make([]common.Hash, 0)}}, | ||
BlockNumber: big.NewInt(1), | ||
Status: geth.ReceiptStatusSuccessful, | ||
} | ||
rpcClient := &mock.ClientMock{TransactionReceiptsFunc: func(_ context.Context, _ []common.Hash) ([]evmRpc.TxReceiptResult, error) { | ||
return []evmRpc.TxReceiptResult{evmRpc.TxReceiptResult(results.FromOk(receipt))}, nil | ||
}} | ||
cache := &evmmock.LatestFinalizedBlockCacheMock{GetFunc: func(chain nexus.ChainName) *big.Int { | ||
return big.NewInt(100) | ||
}} | ||
|
||
broadcaster := &mock2.BroadcasterMock{BroadcastFunc: func(_ context.Context, _ ...sdk.Msg) (*sdk.TxResponse, error) { | ||
return nil, nil | ||
}} | ||
|
||
valAddr := rand.ValAddr() | ||
mgr := evm.NewMgr(map[string]evmRpc.Client{chain.String(): rpcClient}, broadcaster, valAddr, rand.AccAddr(), cache) | ||
|
||
assert.NotPanics(t, func() { | ||
mgr.ProcessGatewayTxsConfirmation(&types.ConfirmGatewayTxsStarted{ | ||
PollMappings: []types.PollMapping{{PollID: 10, TxID: types.Hash{1}}}, | ||
Participants: []sdk.ValAddress{valAddr}, | ||
Chain: chain, | ||
}) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters