mirror of https://github.com/status-im/evmc.git
cpp: Add default constructor for HostContext
This commit is contained in:
parent
5d9e6ba90b
commit
95737d2721
|
@ -501,7 +501,10 @@ class HostContext : public HostInterface
|
||||||
evmc_tx_context tx_context = {};
|
evmc_tx_context tx_context = {};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/// Implicit converting constructor from evmc_host_context.
|
/// Default constructor for null Host context.
|
||||||
|
HostContext() = default;
|
||||||
|
|
||||||
|
/// Constructor from the EVMC Host primitives.
|
||||||
HostContext(const evmc_host_interface* interface, evmc_host_context* ctx) noexcept
|
HostContext(const evmc_host_interface* interface, evmc_host_context* ctx) noexcept
|
||||||
: host{interface}, context{ctx}
|
: host{interface}, context{ctx}
|
||||||
{}
|
{}
|
||||||
|
|
|
@ -404,9 +404,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_interface = example_host_get_interface();
|
auto* host_interface = example_host_get_interface();
|
||||||
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};
|
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