Merge pull request #10193 from filecoin-project/steb/fix-fevm-tests
itest: fix FEVM tests for upstream changes
This commit is contained in:
commit
91d0e41444
@ -57,7 +57,7 @@ func buildInputFromuint64(number uint64) []byte {
|
|||||||
// recursive delegate calls that fail due to gas limits are currently getting to 229 iterations
|
// recursive delegate calls that fail due to gas limits are currently getting to 229 iterations
|
||||||
// before running out of gas
|
// before running out of gas
|
||||||
func recursiveDelegatecallFail(ctx context.Context, t *testing.T, client *kit.TestFullNode, filename string, count uint64) {
|
func recursiveDelegatecallFail(ctx context.Context, t *testing.T, client *kit.TestFullNode, filename string, count uint64) {
|
||||||
expectedIterationsBeforeFailing := int(229)
|
expectedIterationsBeforeFailing := int(228)
|
||||||
fromAddr, idAddr := client.EVM().DeployContractFromFilename(ctx, filename)
|
fromAddr, idAddr := client.EVM().DeployContractFromFilename(ctx, filename)
|
||||||
t.Log("recursion count - ", count)
|
t.Log("recursion count - ", count)
|
||||||
inputData := buildInputFromuint64(count)
|
inputData := buildInputFromuint64(count)
|
||||||
@ -123,7 +123,7 @@ func TestFEVMRecursiveFail(t *testing.T) {
|
|||||||
t.Run(fmt.Sprintf("TestFEVMRecursiveFail%d", failCallCount), func(t *testing.T) {
|
t.Run(fmt.Sprintf("TestFEVMRecursiveFail%d", failCallCount), func(t *testing.T) {
|
||||||
_, wait, err := client.EVM().InvokeContractByFuncName(ctx, fromAddr, idAddr, "recursiveCall(uint256)", buildInputFromuint64(failCallCount))
|
_, wait, err := client.EVM().InvokeContractByFuncName(ctx, fromAddr, idAddr, "recursiveCall(uint256)", buildInputFromuint64(failCallCount))
|
||||||
require.Error(t, err)
|
require.Error(t, err)
|
||||||
require.Equal(t, exitcode.ExitCode(23), wait.Receipt.ExitCode)
|
require.Equal(t, exitcode.ExitCode(37), wait.Receipt.ExitCode)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -150,8 +150,8 @@ func TestFEVMRecursive2(t *testing.T) {
|
|||||||
require.Equal(t, 2, len(events))
|
require.Equal(t, 2, len(events))
|
||||||
}
|
}
|
||||||
|
|
||||||
// TestFEVMBasic does a basic fevm contract installation and invocation
|
// TestFEVMRecursiveDelegateCall tests the maximum delegatecall recursion depth. It currently
|
||||||
// recursive delegate call succeeds up to 238 times
|
// succeeds succeeds up to 228 times.
|
||||||
func TestFEVMRecursiveDelegatecall(t *testing.T) {
|
func TestFEVMRecursiveDelegatecall(t *testing.T) {
|
||||||
|
|
||||||
ctx, cancel, client := kit.SetupFEVMTest(t)
|
ctx, cancel, client := kit.SetupFEVMTest(t)
|
||||||
@ -159,11 +159,11 @@ func TestFEVMRecursiveDelegatecall(t *testing.T) {
|
|||||||
|
|
||||||
filename := "contracts/RecursiveDelegeatecall.hex"
|
filename := "contracts/RecursiveDelegeatecall.hex"
|
||||||
|
|
||||||
//success with 238 or fewer calls
|
//success with 228 or fewer calls
|
||||||
for i := uint64(1); i <= 238; i += 30 {
|
for i := uint64(1); i <= 228; i += 30 {
|
||||||
recursiveDelegatecallSuccess(ctx, t, client, filename, i)
|
recursiveDelegatecallSuccess(ctx, t, client, filename, i)
|
||||||
}
|
}
|
||||||
recursiveDelegatecallSuccess(ctx, t, client, filename, uint64(238))
|
recursiveDelegatecallSuccess(ctx, t, client, filename, uint64(228))
|
||||||
|
|
||||||
for i := uint64(239); i <= 800; i += 40 {
|
for i := uint64(239); i <= 800; i += 40 {
|
||||||
recursiveDelegatecallFail(ctx, t, client, filename, i)
|
recursiveDelegatecallFail(ctx, t, client, filename, i)
|
||||||
@ -470,10 +470,9 @@ func TestFEVMSendGasLimit(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TestFEVMDelegateCall deploys the two contracts in TestFEVMDelegateCall but instead of A calling B, A calls A which should cause A to cause A in an infinite loop and should give a reasonable error
|
// TestFEVMDelegateCall deploys the two contracts in TestFEVMDelegateCall but instead of A calling B, A calls A which should cause A to cause A in an infinite loop and should give a reasonable error
|
||||||
// XXX should not be fatal errors
|
|
||||||
func TestFEVMDelegateCallRecursiveFail(t *testing.T) {
|
func TestFEVMDelegateCallRecursiveFail(t *testing.T) {
|
||||||
//TODO change the gas limit of this invocation and confirm that the number of errors is different
|
//TODO change the gas limit of this invocation and confirm that the number of errors is
|
||||||
//also TODO should we not have fatal error show up here?
|
// different
|
||||||
ctx, cancel, client := kit.SetupFEVMTest(t)
|
ctx, cancel, client := kit.SetupFEVMTest(t)
|
||||||
defer cancel()
|
defer cancel()
|
||||||
|
|
||||||
@ -486,17 +485,16 @@ func TestFEVMDelegateCallRecursiveFail(t *testing.T) {
|
|||||||
inputDataValue := inputDataFromArray([]byte{7})
|
inputDataValue := inputDataFromArray([]byte{7})
|
||||||
inputData := append(inputDataContract, inputDataValue...)
|
inputData := append(inputDataContract, inputDataValue...)
|
||||||
|
|
||||||
//verify that the returned value of the call to setvars is 7
|
//verify that we run out of gas then revert.
|
||||||
_, wait, err := client.EVM().InvokeContractByFuncName(ctx, fromAddr, actorAddr, "setVarsSelf(address,uint256)", inputData)
|
_, wait, err := client.EVM().InvokeContractByFuncName(ctx, fromAddr, actorAddr, "setVarsSelf(address,uint256)", inputData)
|
||||||
require.Error(t, err)
|
require.Error(t, err)
|
||||||
require.Equal(t, exitcode.SysErrorIllegalArgument, wait.Receipt.ExitCode)
|
require.Equal(t, exitcode.ExitCode(33), wait.Receipt.ExitCode)
|
||||||
|
|
||||||
//assert no fatal errors but still there are errors::
|
//assert no fatal errors but still there are errors::
|
||||||
errorAny := "fatal error"
|
errorAny := "fatal error"
|
||||||
require.NotContains(t, err.Error(), errorAny)
|
require.NotContains(t, err.Error(), errorAny)
|
||||||
}
|
}
|
||||||
|
|
||||||
// XXX Currently fails as self destruct has a bug
|
|
||||||
// TestFEVMTestSendValueThroughContracts creates A and B contract and exchanges value
|
// TestFEVMTestSendValueThroughContracts creates A and B contract and exchanges value
|
||||||
// and self destructs and accounts for value sent
|
// and self destructs and accounts for value sent
|
||||||
func TestFEVMTestSendValueThroughContractsAndDestroy(t *testing.T) {
|
func TestFEVMTestSendValueThroughContractsAndDestroy(t *testing.T) {
|
||||||
|
Loading…
Reference in New Issue
Block a user