mirror of https://github.com/status-im/evmc.git
Do not allow set_tracer function to be null
This commit is contained in:
parent
2c7ad06072
commit
d2ac75f6a8
|
@ -9,6 +9,8 @@ struct examplevm
|
|||
{
|
||||
struct evmc_instance instance;
|
||||
int verbose;
|
||||
evmc_trace_callback trace_callback;
|
||||
struct evmc_tracer_context* tracer_context;
|
||||
};
|
||||
|
||||
static void destroy(struct evmc_instance* evm)
|
||||
|
@ -113,6 +115,15 @@ static struct evmc_result execute(struct evmc_instance* instance,
|
|||
return ret;
|
||||
}
|
||||
|
||||
static void set_tracer(struct evmc_instance* instance,
|
||||
evmc_trace_callback callback,
|
||||
struct evmc_tracer_context* context)
|
||||
{
|
||||
struct examplevm* vm = (struct examplevm*)instance;
|
||||
vm->trace_callback = callback;
|
||||
vm->tracer_context = context;
|
||||
}
|
||||
|
||||
struct evmc_instance* evmc_create_examplevm()
|
||||
{
|
||||
struct evmc_instance init = {
|
||||
|
@ -122,6 +133,7 @@ struct evmc_instance* evmc_create_examplevm()
|
|||
.destroy = destroy,
|
||||
.execute = execute,
|
||||
.set_option = set_option,
|
||||
.set_tracer = set_tracer,
|
||||
};
|
||||
struct examplevm* vm = calloc(1, sizeof(struct examplevm));
|
||||
struct evmc_instance* interface = &vm->instance;
|
||||
|
|
|
@ -59,4 +59,13 @@ TEST_F(evmc_vm_test, version)
|
|||
{
|
||||
ASSERT_NE(vm->version, nullptr);
|
||||
EXPECT_GT(std::strlen(vm->version), 0) << "VM name cannot be empty";
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(evmc_vm_test, set_tracer)
|
||||
{
|
||||
static constexpr auto tracer_callback = [](evmc_tracer_context*, int, size_t, evmc_status_code,
|
||||
int64_t, size_t, const evmc_uint256be*, size_t,
|
||||
size_t, size_t, const uint8_t*) noexcept {};
|
||||
ASSERT_NE(vm->set_tracer, nullptr);
|
||||
vm->set_tracer(vm, tracer_callback, nullptr);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue