-
Notifications
You must be signed in to change notification settings - Fork 310
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
Add vm test for execute #94
Conversation
Oh, well great, this uses |
test/vmtester/tests.cpp
Outdated
@@ -31,6 +31,25 @@ TEST_F(evmc_vm_test, abi_version_match) | |||
ASSERT_EQ(vm->abi_version, EVMC_ABI_VERSION); | |||
} | |||
|
|||
TEST_F(evmc_vm_test, execute) | |||
{ | |||
struct evmc_context context{}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to populate this with callbacks.
I'm rebasing this... |
13ee37a
to
fb41fe7
Compare
It is broken now:
|
test/vmtester/mock_context.cpp
Outdated
(void)topics_count; | ||
} | ||
|
||
extern const struct evmc_context_fn_table mock_context_fn_table = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the future we could extend this to have a factory which instantiates a context with certain values.
c558940
to
35da9ae
Compare
@chfast this is ready now |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice.
I'm just thinking about renaming "context" to "host"...
test/vmtester/mock_context.cpp
Outdated
#include <stdlib.h> | ||
#include <string.h> | ||
|
||
struct evmc_uint256be balance(struct evmc_context* context, const struct evmc_address* address) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't need struct
prefix in C++.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a copy from examples/capi.c
. Should we keep it as C (with a .c
extension) or go full in on C++?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think C++ will be easier.
test/vmtester/tests.cpp
Outdated
struct evmc_message msg | ||
{ | ||
}; | ||
std::vector<uint8_t> code({0xfe, 0x00}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
std::array
would go here. Or even a raw array + std::begin
and std::size
.
Sounds good. Obviously that is a separate breaking change. |
80d55bc
to
5516456
Compare
@chfast updated |
I think mock_context.c should actually replace capi.c as a host implementation example. But this can be done later. |
Unfortunately need to adjust all the test VMs.