diff --git a/lib/evmone/execution_state.hpp b/lib/evmone/execution_state.hpp index 3734539171..1ab0528867 100644 --- a/lib/evmone/execution_state.hpp +++ b/lib/evmone/execution_state.hpp @@ -183,6 +183,7 @@ class ExecutionState bytes_view _code) noexcept { gas_left = message.gas; + gas_refund = 0; memory.clear(); msg = &message; host = {host_interface, host_ctx}; diff --git a/test/unittests/execution_state_test.cpp b/test/unittests/execution_state_test.cpp index 4c37ba9930..832021e488 100644 --- a/test/unittests/execution_state_test.cpp +++ b/test/unittests/execution_state_test.cpp @@ -84,6 +84,7 @@ TEST(execution_state, reset_advanced) evmone::advanced::AdvancedExecutionState st; st.gas_left = 1; + st.gas_refund = 2; st.stack.push({}); st.memory.grow(64); st.msg = &msg; @@ -97,6 +98,7 @@ TEST(execution_state, reset_advanced) st.analysis.advanced = &analysis; EXPECT_EQ(st.gas_left, 1); + EXPECT_EQ(st.gas_refund, 2); EXPECT_EQ(st.stack.size(), 1); EXPECT_EQ(st.memory.size(), 64); EXPECT_EQ(st.msg, &msg); @@ -121,6 +123,7 @@ TEST(execution_state, reset_advanced) // TODO: We are not able to test HostContext with current API. It may require an execution // test. EXPECT_EQ(st.gas_left, 13); + EXPECT_EQ(st.gas_refund, 0); EXPECT_EQ(st.stack.size(), 0); EXPECT_EQ(st.memory.size(), 0); EXPECT_EQ(st.msg, &msg2);