fix tx check and test

This commit is contained in:
vyzo 2022-11-11 05:49:06 +02:00
parent 1d8ebe96bc
commit 7664e0691c
2 changed files with 6 additions and 6 deletions

View File

@ -120,7 +120,7 @@ func (tx *EthTxArgs) ToSignedMessage() (*types.SignedMessage, error) {
var to address.Address
var params []byte
if tx.To == nil && len(tx.Input) == 0 {
if len(tx.To) == 0 && len(tx.Input) == 0 {
return nil, fmt.Errorf("to and input cannot both be empty")
}

View File

@ -40,21 +40,21 @@ func TestTxArgs(t *testing.T) {
// parse txargs
txArgs, err := ParseEthTxArgs(tc.Input)
require.Nil(t, err, comment)
require.NoError(t, err)
msgRecovered, err := txArgs.OriginalRlpMsg()
require.Nil(t, err, comment)
require.NoError(t, err)
require.Equal(t, tc.NosigTx, "0x"+hex.EncodeToString(msgRecovered), comment)
// verify signatures
from, err := txArgs.Sender()
require.Nil(t, err, comment)
require.NoError(t, err)
smsg, err := txArgs.ToSignedMessage()
require.Nil(t, err, comment)
require.NoError(t, err)
err = sigs.Verify(&smsg.Signature, from, msgRecovered)
require.Nil(t, err, comment)
require.NoError(t, err)
// verify data
require.Equal(t, tc.Output.ChainID, txArgs.ChainID)