Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add update_object native function in TestScenario #820

Merged
merged 1 commit into from
Mar 15, 2022
Merged

Conversation

lxfind
Copy link
Contributor

@lxfind lxfind commented Mar 14, 2022

Right now we use transfer to mimic returning an object back to the inventory.
This is not ideal because it will mix up with real transfers. I will also not allow us properly detect issues such as transferring a shared object.
This PR adds a native function that emits a new test-only event for updating the object.
It does the following, specifically:

  1. When returning an object, call the update_object native function. This function checks that we are not mutating an immutable object. And also emit a UPDATE_OBJECT_EVENT.
  2. When processing transfers, now that we know these transfers are all real, we can detect cases where a shared object is being transferred.
  3. Added error codes for the above two cases and return them. Added tests.

Some potential TODOs:

  1. We can only detect transferring shared object at a late time when we process the inventory. Ideally we want to detect it when an object is being transferred. One idea to do this is to emit a special event when calling TestScenario::begin, and then when processing a transfer, we look at the first event to see if we are in the test mode. If we are in the test mode, we could then process the inventory at that time.
  2. When any of the errors happen, we only return an abort_code, which is not very meaningful to developers (the fact that the error may be delayed makes it even worse). We need to think about how we may be able to make this more debuggable.

@lxfind lxfind requested review from awelc, sblackshear and damirka March 14, 2022 04:33
@lxfind lxfind changed the title Add update_object native function Add update_object native function in TestScenario Mar 14, 2022
@lxfind lxfind added the move label Mar 14, 2022
@lxfind lxfind merged commit 8b57a34 into main Mar 15, 2022
@lxfind lxfind deleted the test-return-object branch March 15, 2022 00:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants