simplify test.
This commit is contained in:
parent
fce0813821
commit
3d21d71231
@ -280,29 +280,10 @@ func TestGetBlockByNumber(t *testing.T) {
|
|||||||
ctx, cancel := context.WithTimeout(context.Background(), time.Minute)
|
ctx, cancel := context.WithTimeout(context.Background(), time.Minute)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
// install contract
|
|
||||||
contractHex, err := os.ReadFile("./contracts/SimpleCoin.hex")
|
|
||||||
require.NoError(t, err)
|
|
||||||
|
|
||||||
contract, err := hex.DecodeString(string(contractHex))
|
|
||||||
require.NoError(t, err)
|
|
||||||
|
|
||||||
// create a new Ethereum account
|
// create a new Ethereum account
|
||||||
key, ethAddr, deployer := client.EVM().NewAccount()
|
_, ethAddr, filAddr := client.EVM().NewAccount()
|
||||||
// send some funds to the f410 address
|
// send some funds to the f410 address
|
||||||
kit.SendFunds(ctx, t, client, deployer, types.FromFil(10))
|
kit.SendFunds(ctx, t, client, filAddr, types.FromFil(10))
|
||||||
|
|
||||||
// DEPLOY CONTRACT
|
|
||||||
tx, err := deployContractTx(ctx, client, ethAddr, contract)
|
|
||||||
require.NoError(t, err)
|
|
||||||
|
|
||||||
client.EVM().SignTransaction(tx, key.PrivateKey)
|
|
||||||
hash := client.EVM().SubmitTransaction(ctx, tx)
|
|
||||||
|
|
||||||
receipt, err := waitForEthTxReceipt(ctx, client, hash)
|
|
||||||
require.NoError(t, err)
|
|
||||||
require.NotNil(t, receipt)
|
|
||||||
require.EqualValues(t, ethtypes.EthUint64(0x1), receipt.Status)
|
|
||||||
|
|
||||||
latest, err := client.EthBlockNumber(ctx)
|
latest, err := client.EthBlockNumber(ctx)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
@ -338,7 +319,7 @@ func TestGetBlockByNumber(t *testing.T) {
|
|||||||
bal, err := client.EthGetBalance(ctx, ethAddr, (ethtypes.EthUint64(afterNullHeight - 1)).Hex())
|
bal, err := client.EthGetBalance(ctx, ethAddr, (ethtypes.EthUint64(afterNullHeight - 1)).Hex())
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.NotEqual(t, big.Zero(), bal)
|
require.NotEqual(t, big.Zero(), bal)
|
||||||
require.Equal(t, -1, bal.Cmp(types.FromFil(10).Int))
|
require.Equal(t, types.FromFil(10).Int, bal.Int)
|
||||||
}
|
}
|
||||||
|
|
||||||
func deployContractTx(ctx context.Context, client *kit.TestFullNode, ethAddr ethtypes.EthAddress, contract []byte) (*ethtypes.EthTxArgs, error) {
|
func deployContractTx(ctx context.Context, client *kit.TestFullNode, ethAddr ethtypes.EthAddress, contract []byte) (*ethtypes.EthTxArgs, error) {
|
||||||
|
Loading…
Reference in New Issue
Block a user