From b2c566f79c168f2761855a321c5ac36b4144ec7a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Bylica?= Date: Tue, 17 Apr 2018 11:05:54 +0200 Subject: [PATCH] Move static asserts from EVMJIT --- test/vmtester/tests.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/test/vmtester/tests.cpp b/test/vmtester/tests.cpp index 0fa5141..6c8267d 100644 --- a/test/vmtester/tests.cpp +++ b/test/vmtester/tests.cpp @@ -6,6 +6,25 @@ #include +// Compile time checks: + +static_assert(sizeof(evmc_uint256be) == 32, "evmc_uint256be is too big"); +static_assert(sizeof(evmc_address) == 20, "evmc_address is too big"); +static_assert(sizeof(evmc_result) == 64, "evmc_result does not fit cache line"); +static_assert(sizeof(evmc_instance) <= 64, "evmc_instance does not fit cache line"); +static_assert(sizeof(evmc_message) <= 18 * 8, "evmc_message not optimally packed"); +static_assert(offsetof(evmc_message, code_hash) % 8 == 0, "evmc_message.code_hash not aligned"); + +// Check enums match int size. +// On GCC/clang the underlying type should be unsigned int, on MSVC int +static_assert( + sizeof(evmc_call_kind) == sizeof(int), "Enum `evmc_call_kind` is not the size of int"); +static_assert(sizeof(evmc_revision) == sizeof(int), "Enum `evmc_revision` is not the size of int"); + +static constexpr size_t optionalDataSize = + sizeof(evmc_result) - offsetof(evmc_result, create_address); +static_assert(optionalDataSize == sizeof(evmc_result_optional_data), ""); + TEST_F(evmc_vm_test, abi_version_match) { ASSERT_EQ(vm->abi_version, EVMC_ABI_VERSION);