cpp: Add default constructor for HostContext

This commit is contained in:
Paweł Bylica 2019-11-06 13:06:58 +01:00
parent 5d9e6ba90b
commit 95737d2721
No known key found for this signature in database
GPG Key ID: 7A0C037434FE77EF
2 changed files with 6 additions and 2 deletions

View File

@ -501,7 +501,10 @@ class HostContext : public HostInterface
evmc_tx_context tx_context = {};
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
: host{interface}, context{ctx}
{}

View File

@ -404,9 +404,10 @@ TEST(cpp, host_call)
{
// Use example host to test Host::call() method.
auto host = evmc::HostContext{}; // Use default constructor.
auto* host_interface = example_host_get_interface();
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);