mirror of https://github.com/status-im/evmc.git
Merge pull request #451 from ethereum/cpp
cpp: Require the host interface for HostContext be passed by reference
This commit is contained in:
commit
af16e9d7ef
|
@ -53,6 +53,11 @@ and this project adheres to [Semantic Versioning].
|
||||||
[[#442](https://github.com/ethereum/evmc/pull/442)]
|
[[#442](https://github.com/ethereum/evmc/pull/442)]
|
||||||
- In the Rust bindings make `ExecutionContext` optional within `execute`.
|
- In the Rust bindings make `ExecutionContext` optional within `execute`.
|
||||||
[[#350](https://github.com/ethereum/evmc/pull/350)]
|
[[#350](https://github.com/ethereum/evmc/pull/350)]
|
||||||
|
- A set of small improvements to C++ API
|
||||||
|
[[#445](https://github.com/ethereum/evmc/pull/445),
|
||||||
|
[#449](https://github.com/ethereum/evmc/pull/449),
|
||||||
|
[#451](https://github.com/ethereum/evmc/pull/451)]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## [6.3.1] - 2019-08-19
|
## [6.3.1] - 2019-08-19
|
||||||
|
|
|
@ -402,8 +402,10 @@ public:
|
||||||
HostContext() = default;
|
HostContext() = default;
|
||||||
|
|
||||||
/// Constructor from the EVMC Host primitives.
|
/// Constructor from the EVMC Host primitives.
|
||||||
HostContext(const evmc_host_interface* interface, evmc_host_context* ctx) noexcept
|
/// @param interface The reference to the Host interface.
|
||||||
: host{interface}, context{ctx}
|
/// @param ctx The pointer to the Host context object. This parameter MAY be null.
|
||||||
|
HostContext(const evmc_host_interface& interface, evmc_host_context* ctx) noexcept
|
||||||
|
: host{&interface}, context{ctx}
|
||||||
{}
|
{}
|
||||||
|
|
||||||
bool account_exists(const address& address) noexcept final
|
bool account_exists(const address& address) noexcept final
|
||||||
|
|
|
@ -440,9 +440,10 @@ TEST(cpp, host)
|
||||||
{
|
{
|
||||||
// Use example host to execute all methods from the C++ host wrapper.
|
// Use example host to execute all methods from the C++ host wrapper.
|
||||||
|
|
||||||
auto* host_interface = example_host_get_interface();
|
const auto* host_interface = example_host_get_interface();
|
||||||
|
ASSERT_NE(host_interface, nullptr);
|
||||||
auto* host_context = example_host_create_context(evmc_tx_context{});
|
auto* host_context = example_host_create_context(evmc_tx_context{});
|
||||||
auto host = evmc::HostContext{host_interface, host_context};
|
auto host = evmc::HostContext{*host_interface, host_context};
|
||||||
|
|
||||||
const auto a = evmc::address{{{1}}};
|
const auto a = evmc::address{{{1}}};
|
||||||
const auto v = evmc::bytes32{{{7, 7, 7}}};
|
const auto v = evmc::bytes32{{{7, 7, 7}}};
|
||||||
|
@ -476,9 +477,10 @@ TEST(cpp, host_call)
|
||||||
// Use example host to test Host::call() method.
|
// Use example host to test Host::call() method.
|
||||||
|
|
||||||
auto host = evmc::HostContext{}; // Use default constructor.
|
auto host = evmc::HostContext{}; // Use default constructor.
|
||||||
auto* host_interface = example_host_get_interface();
|
const auto* host_interface = example_host_get_interface();
|
||||||
|
ASSERT_NE(host_interface, nullptr);
|
||||||
auto* host_context = example_host_create_context(evmc_tx_context{});
|
auto* host_context = example_host_create_context(evmc_tx_context{});
|
||||||
host = evmc::HostContext{host_interface, host_context};
|
host = evmc::HostContext{*host_interface, host_context};
|
||||||
|
|
||||||
EXPECT_EQ(host.call({}).gas_left, 0);
|
EXPECT_EQ(host.call({}).gas_left, 0);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue