Start eth_sendRawTransaction test
This commit is contained in:
parent
9fed750f9d
commit
7eca3e4853
@ -18,7 +18,10 @@ import (
|
||||
|
||||
"github.com/filecoin-project/go-address"
|
||||
"github.com/filecoin-project/go-jsonrpc"
|
||||
"github.com/filecoin-project/go-state-types/big"
|
||||
|
||||
"github.com/filecoin-project/lotus/build"
|
||||
"github.com/filecoin-project/lotus/chain/types"
|
||||
"github.com/filecoin-project/lotus/chain/types/ethtypes"
|
||||
"github.com/filecoin-project/lotus/itests/kit"
|
||||
)
|
||||
@ -97,6 +100,8 @@ func TestEthOpenRPCConformance(t *testing.T) {
|
||||
|
||||
result := client.EVM().DeployContract(ctx, senderAddr, contractBin)
|
||||
|
||||
// set up some standard values for tests
|
||||
|
||||
contractAddr, err := address.NewIDAddress(result.ActorID)
|
||||
require.NoError(t, err)
|
||||
|
||||
@ -129,6 +134,45 @@ func TestEthOpenRPCConformance(t *testing.T) {
|
||||
break
|
||||
}
|
||||
|
||||
// install contract
|
||||
contract2Hex, err := os.ReadFile("./contracts/SimpleCoin.hex")
|
||||
require.NoError(t, err)
|
||||
|
||||
contract, err := hex.DecodeString(string(contract2Hex))
|
||||
require.NoError(t, err)
|
||||
|
||||
// create a new Ethereum account
|
||||
key, ethAddr, deployer := client.EVM().NewAccount()
|
||||
_, ethAddr2, _ := client.EVM().NewAccount()
|
||||
|
||||
kit.SendFunds(ctx, t, client, deployer, types.FromFil(1000))
|
||||
|
||||
gaslimit, err := client.EthEstimateGas(ctx, ethtypes.EthCall{
|
||||
From: ðAddr,
|
||||
Data: contract,
|
||||
})
|
||||
require.NoError(t, err)
|
||||
|
||||
maxPriorityFeePerGas, err := client.EthMaxPriorityFeePerGas(ctx)
|
||||
require.NoError(t, err)
|
||||
|
||||
tx := ethtypes.EthTxArgs{
|
||||
ChainID: build.Eip155ChainId,
|
||||
Value: big.NewInt(100),
|
||||
Nonce: 0,
|
||||
To: ðAddr2,
|
||||
MaxFeePerGas: types.NanoFil,
|
||||
MaxPriorityFeePerGas: big.Int(maxPriorityFeePerGas),
|
||||
GasLimit: int(gaslimit),
|
||||
V: big.Zero(),
|
||||
R: big.Zero(),
|
||||
S: big.Zero(),
|
||||
}
|
||||
|
||||
client.EVM().SignTransaction(&tx, key.PrivateKey)
|
||||
signed, err := tx.ToRlpSignedMsg()
|
||||
require.NoError(t, err)
|
||||
|
||||
// create a json-rpc client that returns raw json responses
|
||||
var ethapi ethAPIRaw
|
||||
|
||||
@ -140,8 +184,6 @@ func TestEthOpenRPCConformance(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
defer closer()
|
||||
|
||||
// maxPriorityFeePerGas, err := client.EthMaxPriorityFeePerGas(ctx)
|
||||
|
||||
testCases := []struct {
|
||||
method string
|
||||
variant string // suffix applied to the test name to distinguish different variants of a method call
|
||||
@ -280,6 +322,13 @@ func TestEthOpenRPCConformance(t *testing.T) {
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
method: "eth_sendRawTransaction",
|
||||
call: func(a *ethAPIRaw) (json.RawMessage, error) {
|
||||
return ethapi.EthSendRawTransaction(context.Background(), signed)
|
||||
},
|
||||
},
|
||||
|
||||
// {
|
||||
// method: "eth_call",
|
||||
// call: func(a *ethAPIRaw) (json.RawMessage, error) {
|
||||
|
Loading…
Reference in New Issue
Block a user