From dbe1c3e73b546756d0bcbf1b8f243c3933013bac Mon Sep 17 00:00:00 2001 From: Alex Beregszaszi Date: Fri, 22 Nov 2019 19:58:54 +0000 Subject: [PATCH 1/2] mocked_host: add nonce to account --- include/evmc/mocked_host.hpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/evmc/mocked_host.hpp b/include/evmc/mocked_host.hpp index 181de73..3edd62b 100644 --- a/include/evmc/mocked_host.hpp +++ b/include/evmc/mocked_host.hpp @@ -35,6 +35,9 @@ struct MockedAccount {} }; + /// The account nonce. + int nonce = 0; + /// The account code. bytes code; From d4e61aa84ab2c15dfe9d40121d42493fb1379da4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Bylica?= Date: Thu, 28 Nov 2019 15:21:00 +0100 Subject: [PATCH 2/2] test: Add a unit test for MockedAccount --- test/unittests/test_cpp.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/test/unittests/test_cpp.cpp b/test/unittests/test_cpp.cpp index 5f1cd26..7cd30a2 100644 --- a/test/unittests/test_cpp.cpp +++ b/test/unittests/test_cpp.cpp @@ -633,4 +633,18 @@ TEST(cpp, result_create) ASSERT_TRUE(c.release); EXPECT_TRUE(std::memcmp(c.output_data, r.output_data, c.output_size) == 0); c.release(&c); -} \ No newline at end of file +} + +TEST(cpp, mocked_account) +{ + using namespace evmc::literals; + + evmc::MockedAccount account; + EXPECT_EQ(account.nonce, 0); + --account.nonce; + account.set_balance(0x0102030405060708); + + EXPECT_EQ(account.balance, + 0x0000000000000000000000000000000000000000000000000102030405060708_bytes32); + EXPECT_EQ(account.nonce, -1); +}