Skip to content

Commit

Permalink
Contract call tests
Browse files Browse the repository at this point in the history
  • Loading branch information
virgil-serbanuta committed Sep 13, 2024
1 parent c7f58e5 commit ceb17cf
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 0 deletions.
Empty file.
34 changes: 34 additions & 0 deletions tests/mx-rust-contracts/call-endpoint-args.1.run
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
setCallee("Owner");

push mxListValue();
push mxStringValue("getMyStorage");
push mxIntValue(0);
push mxTransfersValue();
push mxIntValue(0);
push mxStringValue("TestContract");
call 6 MX#managedExecuteOnDestContext;
check_eq mxIntValue(0);

push_return_value;
check_eq mxIntValue(0);

push mxListValue(mxIntValue(8));
push mxStringValue("setMyStorage");
push mxIntValue(0);
push mxTransfersValue();
push mxIntValue(0);
push mxStringValue("TestContract");
call 6 MX#managedExecuteOnDestContext;
check_eq mxIntValue(0);

push mxListValue();
push mxStringValue("getMyStorage");
push mxIntValue(0);
push mxTransfersValue();
push mxIntValue(0);
push mxStringValue("TestContract");
call 6 MX#managedExecuteOnDestContext;
check_eq mxIntValue(0);

push_return_value;
check_eq mxIntValue(8)
27 changes: 27 additions & 0 deletions tests/mx-rust-contracts/call-endpoint-args.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#![no_std]

#[allow(unused_imports)]
use multiversx_sc::imports::*;

#[multiversx_sc::contract]
pub trait Contract {
#[view(noArg)]
#[storage_mapper("my_value")]
fn my_storage(&self) -> SingleValueMapper<BigUint>;

#[init]
fn init(&self) {}

#[upgrade]
fn upgrade(&self) {}

#[endpoint(setMyStorage)]
fn set_my_storage(&self, value: &BigUint) {
self.my_storage().set(value)
}

#[endpoint(getMyStorage)]
fn get_my_storage(&self) -> BigUint {
self.my_storage().get()
}
}

0 comments on commit ceb17cf

Please sign in to comment.