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

Update state_history_tests.cpp #10319

Merged
merged 1 commit into from
May 3, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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