Skip to content

Commit 8749af2

Browse files
committed
test: patch various rpc tests and remove unnecessary ones
1 parent 66e5761 commit 8749af2

File tree

8 files changed

+71
-136
lines changed

8 files changed

+71
-136
lines changed

cmd/crates/soroban-test/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,7 @@ impl AssertExt for Assert {
392392
.to_owned()
393393
}
394394
}
395+
395396
pub trait CommandExt {
396397
fn json_arg<A>(&mut self, j: A) -> &mut Self
397398
where

cmd/crates/soroban-test/tests/it/init.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ use predicates::prelude::predicate;
33
use soroban_test::TestEnv;
44

55
#[test]
6-
#[ignore = "We need to ignore these until soroban-sdk is 23.0.0 stable"]
76
fn init() {
87
let sandbox = TestEnv::default();
98
let cli_version = soroban_cli::commands::version::pkg();
@@ -21,11 +20,11 @@ fn init() {
2120
.assert(predicate::function(|c: &str| {
2221
let table = toml::from_str::<toml::Table>(c).unwrap();
2322
let sdk_version = table["workspace"]["dependencies"]["soroban-sdk"].as_str();
24-
println!("Check expected version {major}.0.0 matches template's {sdk_version:?}");
23+
println!("Check expected version {major} matches template's {sdk_version:?}");
2524
if is_rc {
26-
sdk_version.and_then(|x| x.split('-').next()) == Some(&format!("{major}.0.0"))
25+
sdk_version.and_then(|x| x.split('-').next()) == Some(major)
2726
} else {
28-
sdk_version == Some(&format!("{major}.0.0"))
27+
sdk_version == Some(major)
2928
}
3029
}));
3130
}

cmd/crates/soroban-test/tests/it/integration.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,3 @@ mod secure_store;
1313
mod snapshot;
1414
mod tx;
1515
mod util;
16-
mod wrap;

cmd/crates/soroban-test/tests/it/integration/custom_types.rs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ async fn parse() {
4444
contract_address(sandbox, id).await;
4545
contract_address_with_alias(sandbox, id).await;
4646
bytes(sandbox, id).await;
47+
bytes_n(sandbox, id).await;
48+
timepoint(sandbox, id).await;
49+
duration(sandbox, id).await;
4750
const_enum(sandbox, id).await;
4851
number_arg_return_ok(sandbox, id);
4952
void(sandbox, id);
@@ -275,6 +278,39 @@ async fn bytes(sandbox: &TestEnv, id: &str) {
275278
invoke_with_roundtrip(sandbox, id, "bytes", json!("7374656c6c6172")).await;
276279
}
277280

281+
async fn bytes_n(sandbox: &TestEnv, id: &str) {
282+
let bytes = "beeffacebeefface00";
283+
invoke_custom(sandbox, id, "bytes_n")
284+
.arg("--bytes_n")
285+
.arg(bytes)
286+
.assert()
287+
.success()
288+
.stdout(format!(
289+
r#""{bytes}"
290+
"#,
291+
));
292+
}
293+
294+
async fn timepoint(sandbox: &TestEnv, id: &str) {
295+
let tp = "1633046400";
296+
invoke_custom(sandbox, id, "timepoint")
297+
.arg("--timepoint")
298+
.arg(tp)
299+
.assert()
300+
.success()
301+
.stdout(format!("{tp}\n"));
302+
}
303+
304+
async fn duration(sandbox: &TestEnv, id: &str) {
305+
let dur = "3600";
306+
invoke_custom(sandbox, id, "duration")
307+
.arg("--duration")
308+
.arg(dur)
309+
.assert()
310+
.success()
311+
.stdout(format!("{dur}\n"));
312+
}
313+
278314
async fn const_enum(sandbox: &TestEnv, id: &str) {
279315
invoke_with_roundtrip(sandbox, id, "card", "11").await;
280316
}

cmd/crates/soroban-test/tests/it/integration/hello_world.rs

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use soroban_cli::{
77
};
88
use soroban_test::{AssertExt, TestEnv, LOCAL_NETWORK_PASSPHRASE};
99

10-
use super::util::{deploy_hello, extend, HELLO_WORLD};
10+
use super::util::{deploy_hello, extend};
1111
use crate::integration::util::extend_contract;
1212

1313
#[allow(clippy::too_many_lines)]
@@ -317,26 +317,6 @@ async fn contract_data_read() {
317317
.stdout(predicates::str::starts_with("COUNTER,2"));
318318
}
319319

320-
#[tokio::test]
321-
#[ignore]
322-
async fn half_max_instructions() {
323-
let sandbox = TestEnv::new();
324-
let wasm = HELLO_WORLD;
325-
sandbox
326-
.new_assert_cmd("contract")
327-
.arg("deploy")
328-
.arg("--fee")
329-
.arg("1000000")
330-
.arg("--instructions")
331-
.arg((u32::MAX / 2).to_string())
332-
.arg("--wasm")
333-
.arg(wasm.path())
334-
.arg("--ignore-checks")
335-
.assert()
336-
.stderr("")
337-
.stdout_as_str();
338-
}
339-
340320
async fn invoke_with_seed(sandbox: &TestEnv, id: &str, seed_phrase: &str) {
341321
invoke_with_source(sandbox, seed_phrase, id).await;
342322
}

cmd/crates/soroban-test/tests/it/integration/init.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
use soroban_test::{AssertExt, TestEnv};
22

33
#[test]
4-
#[ignore]
54
fn init_and_deploy() {
65
let name = "hello_world";
7-
let sandbox = TestEnv::default();
6+
let sandbox = &TestEnv::new();
87

98
sandbox
109
.new_assert_cmd("contract")

cmd/crates/soroban-test/tests/it/integration/ledger/entry.rs

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -221,8 +221,7 @@ async fn ledger_entry_contract_data() {
221221
.assert()
222222
.success()
223223
.stdout_as_str();
224-
let parsed_key_output: FullLedgerEntries =
225-
serde_json::from_str(&key_output).expect("Failed to parse JSON");
224+
let parsed_key_output: FullLedgerEntries = serde_json::from_str(&key_output).unwrap();
226225
assert!(!parsed_key_output.entries.is_empty());
227226

228227
// get entry by key xdr
@@ -240,9 +239,7 @@ async fn ledger_entry_contract_data() {
240239
.assert()
241240
.success()
242241
.stdout_as_str();
243-
244-
let parsed_key_xdr_output: FullLedgerEntries =
245-
serde_json::from_str(&key_xdr_output).expect("Failed to parse JSON");
242+
let parsed_key_xdr_output: FullLedgerEntries = serde_json::from_str(&key_xdr_output).unwrap();
246243
assert!(!parsed_key_xdr_output.entries.is_empty());
247244

248245
let expected_contract_data_key = expected_contract_ledger_key(&contract_id, storage_key).await;
@@ -264,6 +261,33 @@ async fn ledger_entry_contract_data() {
264261

265262
// the output should be the same regardless of key format
266263
assert_eq!(parsed_key_output.entries, parsed_key_xdr_output.entries);
264+
265+
// get instance data entry
266+
let instance_output = sandbox
267+
.new_assert_cmd("ledger")
268+
.arg("entry")
269+
.arg("fetch")
270+
.arg("contract-data")
271+
.arg("--contract")
272+
.arg(&contract_id)
273+
.arg("--network")
274+
.arg("testnet")
275+
.arg("--instance")
276+
.assert()
277+
.success()
278+
.stdout_as_str();
279+
let parsed_instance_output: FullLedgerEntries = serde_json::from_str(&instance_output).unwrap();
280+
let expected_instance_key = LedgerKey::ContractData(LedgerKeyContractData {
281+
contract: ScAddress::Contract(Hash(Contract::from_string(&contract_id).unwrap().0).into()),
282+
key: ScVal::LedgerKeyContractInstance,
283+
durability: ContractDataDurability::Persistent,
284+
});
285+
assert!(!parsed_instance_output.entries.is_empty());
286+
assert_eq!(parsed_instance_output.entries[0].key, expected_instance_key);
287+
assert!(matches!(
288+
parsed_instance_output.entries[0].val,
289+
LedgerEntryData::ContractData { .. }
290+
));
267291
}
268292

269293
// top level test

cmd/crates/soroban-test/tests/it/integration/wrap.rs

Lines changed: 0 additions & 103 deletions
This file was deleted.

0 commit comments

Comments
 (0)