package evm

import (
	"math/big"
	"strings"
	"testing"

	"github.com/ethereum/go-ethereum"
	"github.com/ethereum/go-ethereum/common"
	"github.com/stretchr/testify/require"
)

func TestTronEstimateCallUsesData(t *testing.T) {
	from := common.HexToAddress("0xfa89b4d534bdeb2713d4ffd893e79d6535fb58f8")
	to := common.HexToAddress("0xa614f803b6fd780986a42c78ec9c7f77e6ded13c")
	callMsg := ethereum.CallMsg{
		From:     from,
		To:       &to,
		GasPrice: big.NewInt(100),
		Data:     []byte{0xa9, 0x05, 0x9c, 0xbb},
	}

	call := tronEstimateCall(callMsg)

	require.Equal(t, strings.ToLower(from.Hex()), call["from"])
	require.Equal(t, strings.ToLower(to.Hex()), call["to"])
	require.Equal(t, "0x64", call["gasPrice"])
	require.Equal(t, "0xa9059cbb", call["data"])
	_, hasInput := call["input"]
	require.False(t, hasInput)
}
