Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Commit

Permalink
Merge pull request #10319 from EOSIO/fix_to_EPE_492_KV_delta_unit_test
Browse files Browse the repository at this point in the history
Update state_history_tests.cpp
  • Loading branch information
Farhad Shahabi authored May 3, 2021
2 parents 8e07d4f + fdd6a36 commit 2439d2c
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions unittests/state_history_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -931,18 +931,31 @@ BOOST_AUTO_TEST_CASE(test_deltas_kv) {
BOOST_REQUIRE_EQUAL(key_values[0].contract.to_string(), "kvtable");
BOOST_REQUIRE_EQUAL(key_values[0].payer.to_string(), "kvtable");

std::string key = string(key_values[0].key.pos, key_values[0].key.remaining());
std::string val = string(key_values[0].value.pos, key_values[0].value.remaining());
BOOST_REQUIRE_EQUAL(fc::to_hex(key.data(), key.size()), "00");
BOOST_REQUIRE_EQUAL(fc::to_hex(val.data(), val.size()), "7897");

chain.produce_block();

result = chain.find_table_delta("key_value");
BOOST_REQUIRE(!result.first);

result = chain.find_table_delta("key_value", true);
BOOST_REQUIRE(result.first);

key_values = chain.deserialize_data<eosio::ship_protocol::key_value_v0, eosio::ship_protocol::key_value>(result.second);
BOOST_REQUIRE_EQUAL(key_values.size(), 1);
BOOST_REQUIRE_EQUAL(result.second->rows.obj[0].first, 2);

BOOST_REQUIRE_EQUAL(key_values[0].contract.to_string(), "kvtable");
BOOST_REQUIRE_EQUAL(key_values[0].payer.to_string(), "kvtable");

key = string(key_values[0].key.pos, key_values[0].key.remaining());
val = string(key_values[0].value.pos, key_values[0].value.remaining());
BOOST_REQUIRE_EQUAL(fc::to_hex(key.data(), key.size()), "00");
BOOST_REQUIRE_EQUAL(fc::to_hex(val.data(), val.size()), "7897");

chain.produce_block();

trace = chain.push_action("kvtable"_n, "erase"_n, "kvtable"_n, mutable_variant_object()("contract", "kvtable"_n)("k", "00"));
Expand Down

0 comments on commit 2439d2c

Please sign in to comment.