Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix executor middleware #786

Merged
merged 2 commits into from
Oct 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added test/contracts/bad-extra/output/bad-extra.wasm
Binary file not shown.
44 changes: 44 additions & 0 deletions vmhost/hosttest/bad_test.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
package hostCoretest

import (
"context"
"testing"
"time"

"github.com/multiversx/mx-chain-vm-go/executor"
contextmock "github.com/multiversx/mx-chain-vm-go/mock/context"
test "github.com/multiversx/mx-chain-vm-go/testcommon"
"github.com/multiversx/mx-chain-vm-go/vmhost"
"github.com/multiversx/mx-chain-vm-go/wasmer"
"github.com/multiversx/mx-chain-vm-go/wasmer2"
"github.com/stretchr/testify/require"
)

func TestBadContract_NoPanic_Memoryfault(t *testing.T) {
Expand Down Expand Up @@ -251,3 +256,42 @@ func TestBadContract_NoPanic_NonExistingFunction(t *testing.T) {
HasRuntimeErrorAndInfo(executor.ErrInvalidFunction.Error(), "thisDoesNotExist")
})
}

func TestBadContractExtra_LongIntLoop_Wasmer1(t *testing.T) {
testBadContractExtraLongIntLoop(t, wasmer.ExecutorFactory())
}

func TestBadContractExtra_LongIntLoop_Wasmer2(t *testing.T) {
testBadContractExtraLongIntLoop(t, wasmer2.ExecutorFactory())
}

func testBadContractExtraLongIntLoop(t *testing.T, executorFactory executor.ExecutorAbstractFactory) {
testCase := test.BuildInstanceCallTest(t).WithContracts(
test.CreateInstanceContract(test.ParentAddress).
WithCode(test.GetTestSCCode("bad-extra", "../../"))).
WithInput(test.CreateTestContractCallInputBuilder().
WithRecipientAddr(test.ParentAddress).
WithGasProvided(test.GasProvided).
WithFunction("bigLoop").
Build()).
WithExecutorFactory(executorFactory).
WithWasmerSIGSEGVPassthrough(false)

ctx, cancel := context.WithTimeout(context.Background(), time.Second)
defer cancel()

done := make(chan struct{})
go func() {
testCase.AndAssertResults(func(_ vmhost.VMHost, _ *contextmock.BlockchainHookStub, verify *test.VMOutputVerifier) {
verify.OutOfGas()
})
close(done)
}()

select {
case <-done:
return
case <-ctx.Done():
require.FailNow(t, "test timed out")
}
}
Binary file modified wasmer2/libvmexeccapi.dylib
Binary file not shown.
Binary file modified wasmer2/libvmexeccapi.so
Binary file not shown.
Loading