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

svm-runtime-ffi tests restoration #324

merged 8 commits into from Jul 29, 2021


Copy link

@YaronWittenstein YaronWittenstein commented Jul 29, 2021

This #269 PR made the svm_runtime_success made svm_runtime_failure obsolete.

This PR re-implements both tests under the new design.


  • Since there is no option to inject imports using the FFI layer anymore, the Rust examples using the SVM SDK have been updated as well.

  • Both svm_envelope_alloc and svm_context_alloc have been modified not to accept any input.
    The binary size of Envelope and Context is fixed.

  • When encoding an Error Message as part of a Receipt, the message is truncated to be of length 255 bytes at most.
    (the classic example, is having an error message containing a deep call-stack).

@YaronWittenstein YaronWittenstein self-assigned this Jul 29, 2021
@YaronWittenstein YaronWittenstein added this to the July 19 Sprint milestone Jul 29, 2021
@YaronWittenstein YaronWittenstein marked this pull request as ready for review July 29, 2021 14:05
@YaronWittenstein YaronWittenstein marked this pull request as draft July 29, 2021 14:21
@YaronWittenstein YaronWittenstein marked this pull request as ready for review July 29, 2021 15:03
Copy link

@neysofu neysofu left a comment

Choose a reason for hiding this comment

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

Some changes I'd like to see:

  • Remove unsafe from svm_envelope_alloc, svm_message_alloc, svm_context_alloc. They're not needed (not introduced with this PR but since we're at it we might as well do it).
  • Remove svm_byte_array::bytes. It's equivalent to x.as_slice().as_ptr(), which is a safe alternative.
  • Replace svm_byte_array::bytes_mut with a safe fn as_slice_mut(&mut self) -> &mut [u8] { ... }. Note the added safety and how it requires &mut.
  • Safer byte_array_copy:
fn byte_array_copy(byte_array: &mut svm_byte_array, bytes: &[u8]) {

This reflects in tests under e.g.:

let mut byte_array = api::svm_message_alloc(msg.len() as u32);
byte_array_copy(&mut byte_array, &msg);

@YaronWittenstein YaronWittenstein merged commit 615b5f3 into master Jul 29, 2021
@YaronWittenstein YaronWittenstein deleted the runtime-ffi-tests-restoration branch July 29, 2021 16:46
@YaronWittenstein YaronWittenstein linked an issue Jul 29, 2021 that may be closed by this pull request
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
None yet

Successfully merging this pull request may close these issues.

runtime-ffi - Rewrite the commented tests
2 participants