Skip to content

Commit

Permalink
Merge pull request #241 from ethereum/vmtester
Browse files Browse the repository at this point in the history
vmtester: dereference if output_data is present
  • Loading branch information
axic authored Apr 24, 2019
2 parents 2375654 + cd993e1 commit 4f25bcb
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions test/vmtester/tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,24 @@
#include <array>
#include <cstring>

namespace
{
// NOTE: this is to avoid compiler optimisations when reading the buffer
uint8_t read_uint8(const volatile uint8_t* p)
{
return *p;
}

void read_buffer(const uint8_t* ptr, size_t size)
{
for (size_t i = 0; i < size; i++)
{
read_uint8(&ptr[i]);
}
}

} // namespace

TEST_F(evmc_vm_test, abi_version_match)
{
ASSERT_EQ(vm->abi_version, EVMC_ABI_VERSION);
Expand Down Expand Up @@ -46,6 +64,11 @@ TEST_F(evmc_vm_test, execute)
{
EXPECT_EQ(result.output_size, 0);
}
else
{
EXPECT_NE(result.output_size, 0);
read_buffer(result.output_data, result.output_size);
}

if (result.release)
result.release(&result);
Expand Down

0 comments on commit 4f25bcb

Please sign in to comment.