Skip to content

Commit

Permalink
Update unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Kbhat1 committed Mar 17, 2024
1 parent 440d3ba commit acfd5e9
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions x/evm/ante/preprocess_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,16 @@ func TestPreprocessAssociateTx(t *testing.T) {
privKey := testkeeper.MockPrivateKey()
testPrivHex := hex.EncodeToString(privKey.Bytes())
key, _ := crypto.HexToECDSA(testPrivHex)
emptyHash := common.Hash{}
sig, err := crypto.Sign(emptyHash[:], key)

emptyData := make([]byte, 32)
prefixedMessage := fmt.Sprintf("\x19Ethereum Signed Message:\n%d", len(emptyData)) + string(emptyData)
hash := crypto.Keccak256Hash([]byte(prefixedMessage))
sig, err := crypto.Sign(hash.Bytes(), key)
require.Nil(t, err)
R, S, _, _ := ethtx.DecodeSignature(sig)
V := big.NewInt(int64(sig[64]))
txData := ethtx.AssociateTx{V: V.Bytes(), R: R.Bytes(), S: S.Bytes()}

txData := ethtx.AssociateTx{V: V.Bytes(), R: R.Bytes(), S: S.Bytes(), CustomMessage: prefixedMessage}
msg, err := types.NewMsgEVMTransaction(&txData)
require.Nil(t, err)
ctx, err = handler.AnteHandle(ctx, mockTx{msgs: []sdk.Msg{msg}}, false, func(ctx sdk.Context, _ sdk.Tx, _ bool) (sdk.Context, error) {
Expand Down

0 comments on commit acfd5e9

Please sign in to comment.