api: adds CallWithStack to avoid allocations (#1407)

Signed-off-by: Nuno Cruces <ncruces@users.noreply.github.com>
This commit is contained in:
Nuno Cruces
2023-05-01 00:52:40 +01:00
committed by GitHub
parent 0bfb4b52eb
commit 77e8d72d67
11 changed files with 188 additions and 105 deletions

View File

@@ -488,12 +488,16 @@ func (e *mockModuleEngine) Close(context.Context) {
func (ce *mockCallEngine) Definition() api.FunctionDefinition { return nil }
// Call implements the same method as documented on api.Function.
func (ce *mockCallEngine) Call(_ context.Context, _ ...uint64) (results []uint64, err error) {
func (ce *mockCallEngine) Call(ctx context.Context, _ ...uint64) (results []uint64, err error) {
return nil, ce.CallWithStack(ctx, nil)
}
// CallWithStack implements the same method as documented on api.Function.
func (ce *mockCallEngine) CallWithStack(_ context.Context, _ []uint64) error {
if ce.callFailIndex >= 0 && ce.index == Index(ce.callFailIndex) {
err = errors.New("call failed")
return
return errors.New("call failed")
}
return
return nil
}
func TestStore_getFunctionTypeID(t *testing.T) {