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

assertion failure with message: read , help #11031

Open
915-nistor-robert opened this issue Jan 14, 2022 · 2 comments
Open

assertion failure with message: read , help #11031

915-nistor-robert opened this issue Jan 14, 2022 · 2 comments

Comments

@915-nistor-robert
Copy link

My contract gives assertion failure with message: read

My action code is:
ACTION waxrng::getrandom(name nm/, uint64_t customer_id, uint64_t signing_value/){
auto itrCustomer = rngcustomers.find(nm.value);

if (itrCustomer == rngcustomers.end()){
rngcustomers.emplace(_self, [&](auto &rec){
//rec.customer_id = customer_id;
rec.nm = nm;
});
} else {
rngcustomers.modify(itrCustomer, _self, [&](auto &rec){
rec.nm = nm;
});
}

action(
{get_self(), "active"_n},
"orng.wax"_n,
"requestrand"_n,
std::tuple{nm.value,/customer_id, signing_value,/ get_self()}
).send();
}

ACTION waxrng::receiverand(/*uint64_t customer_id,*/name nm  , checksum256& random_value){
  uint64_t max_value = 1000;
  auto byte_array = random_value.extract_as_byte_array();
  uint64_t random_int = 0;
  for (int i = 0; i<8; i++){
    random_int <<= 8;
    random_int |= (uint64_t)byte_array[i];
  }

  uint64_t num1 = random_int % max_value;

  auto itrCustomer = rngcustomers.find(nm.value);

  check(itrCustomer != rngcustomers.end(), "customer table not set");
  rngcustomers.modify(itrCustomer, _self, [&](auto& rec){
    rec.random_value = random_value;
    rec.finalnumber = num1;
  });
}
@crazybits
Copy link

you probably update your table struct without data cleanup before change.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants
@crazybits @915-nistor-robert and others