chore_: Validate multi tx type (#5619)
This commit is contained in:
parent
bacd4f5e5c
commit
daef6ee030
|
@ -45,6 +45,10 @@ func (tm *TransactionManager) CreateMultiTransactionFromCommand(command *MultiTr
|
|||
if multiTransaction.FromNetworkID == wallet_common.UnknownChainID && len(data) == 1 {
|
||||
multiTransaction.FromNetworkID = data[0].ChainID
|
||||
}
|
||||
case MultiTransactionBridge:
|
||||
break
|
||||
default:
|
||||
return nil, fmt.Errorf("unsupported multi transaction type: %v", multiTransaction.Type)
|
||||
}
|
||||
|
||||
return multiTransaction, nil
|
||||
|
|
|
@ -319,7 +319,7 @@ func TestCreateMultiTransactionFromCommand(t *testing.T) {
|
|||
var command *MultiTransactionCommand
|
||||
|
||||
// Test types that should get chainID from the data
|
||||
mtTypes := []MultiTransactionType{MultiTransactionSend, MultiTransactionApprove, MultiTransactionSwap}
|
||||
mtTypes := []MultiTransactionType{MultiTransactionSend, MultiTransactionApprove, MultiTransactionSwap, MultiTransactionType(7)}
|
||||
|
||||
for _, mtType := range mtTypes {
|
||||
fromAmount := hexutil.Big(*big.NewInt(1000000000000000000))
|
||||
|
@ -340,6 +340,11 @@ func TestCreateMultiTransactionFromCommand(t *testing.T) {
|
|||
})
|
||||
|
||||
multiTransaction, err := tm.CreateMultiTransactionFromCommand(command, data)
|
||||
if mtType > MultiTransactionApprove {
|
||||
// Unsupported type
|
||||
require.Error(t, err)
|
||||
break
|
||||
}
|
||||
require.NoError(t, err)
|
||||
require.NotNil(t, multiTransaction)
|
||||
require.Equal(t, command.FromAddress, multiTransaction.FromAddress)
|
||||
|
|
Loading…
Reference in New Issue