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

add an example for kv test #979

Merged
merged 12 commits into from
Oct 23, 2020
Merged

add an example for kv test #979

merged 12 commits into from
Oct 23, 2020

Conversation

vzqzhang
Copy link
Contributor

@vzqzhang vzqzhang commented Oct 16, 2020

Change Description

  • Add the kv test created for Dogfooding

API Changes

  • API Changes

Documentation Additions

  • Documentation Additions

require_auth(_self);
kvtest_table table{"kvtest"_n};

uint64_t id = 1;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please check tab character here and below.

auto itr = table.id.find(id);
if (itr != table.id.end()) {
std::string val = itr.value().data;
eosio::check(val.compare(data + std::to_string(id)), "The value for the key " + std::to_string(id) + " is " + val);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

val can be 8MB string too big to print.

@@ -0,0 +1,16 @@
--- kv_addr_book Project ---
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrong project name?

@@ -0,0 +1,60 @@
#include <eosio/eosio.hpp>
#include <eosio/asset.hpp>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you have to include this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. I used eosio::check in the code.

@iamveritas
Copy link
Contributor

A couple of observations:

  1. since we already have in examples folder the kv_addr_book which is demonstrating the kv api, I think this could be merged into that one
  2. however, if you think it makes more sense to be a stand alone example please give it a more suggestive name and comments in the code to be clear what is this example is trying to demonstrate.

@vzqzhang vzqzhang merged commit d2ab320 into develop Oct 23, 2020
@vzqzhang vzqzhang deleted the dogfooding_kv_tests branch October 23, 2020 18:50
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants