Skip to content

Commit 65f9268

Browse files
committed
.
1 parent a289bad commit 65f9268

37 files changed

Lines changed: 480 additions & 52 deletions

soroban-env-host/src/test/invocation.rs

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use crate::{
1010
budget::AsBudget, events::HostEvent, test::observe::ObservedHost, xdr::ScErrorType,
1111
ContractFunctionSet, Error, Host, HostError, Symbol, Tag,
1212
};
13-
use soroban_test_wasms::{ADD_I32, ALLOC, ERR, INVOKE_CONTRACT, VEC};
13+
use soroban_test_wasms::{ADD_I32, ALLOC, ERR, INVOKE_CONTRACT, STORAGE_LIST, VEC};
1414

1515
#[test]
1616
fn invoke_single_contract_function() -> Result<(), HostError> {
@@ -44,6 +44,38 @@ fn invoke_single_contract_function() -> Result<(), HostError> {
4444
Ok(())
4545
}
4646

47+
#[test]
48+
fn invoke_storage_list() -> Result<(), HostError> {
49+
let host = observe_host!(Host::test_host_with_recording_footprint());
50+
let contract_id_obj = host.register_test_contract_wasm(STORAGE_LIST);
51+
let a = 4i32;
52+
let b = 7i32;
53+
let c = 0x7fffffff_i32;
54+
55+
let res = host.call(
56+
contract_id_obj,
57+
Symbol::try_from_small_str("add")?,
58+
host.test_vec_obj(&[a, b])?,
59+
)?;
60+
assert_eq!(i32::try_from_val(&*host, &res)?, a + b);
61+
// overflow
62+
let res = host.call(
63+
contract_id_obj,
64+
Symbol::try_from_small_str("add")?,
65+
host.test_vec_obj(&[a, c])?,
66+
);
67+
let code = (ScErrorType::WasmVm, ScErrorCode::InvalidAction);
68+
69+
eprintln!(
70+
"time ellapsed in nano-seconds for VmInstantiation: {}",
71+
host.as_budget()
72+
.get_time(ContractCostType::VmInstantiation)?
73+
);
74+
75+
assert!(HostError::result_matches_err(res, code));
76+
Ok(())
77+
}
78+
4779
#[test]
4880
fn invoke_alloc() -> Result<(), HostError> {
4981
let host = observe_host!(Host::test_host_with_recording_footprint());

soroban-test-wasms/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,4 +101,6 @@ mod curr {
101101

102102
pub const INCREMENT: &[u8] =
103103
include_bytes!("../wasm-workspace/opt/curr/increment.wasm").as_slice();
104+
pub const STORAGE_LIST: &[u8] =
105+
include_bytes!("../wasm-workspace/opt/curr/storage_list.wasm").as_slice();
104106
}

0 commit comments

Comments
 (0)