Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions app/contract/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 4 additions & 5 deletions app/contract/contracts/Folder/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::process::Command;
use std::time::{SystemTime, UNIX_EPOCH};

fn main() {
let out_dir = env::var("OUT_DIR").unwrap();
let out_dir = env::var("OUT_DIR").expect("OUT_DIR environment variable must be set by cargo");
let dest_path = Path::new(&out_dir).join("build_manifest.rs");

let git_hash = get_git_hash();
Expand Down Expand Up @@ -45,7 +45,8 @@ pub const BUILD_MANIFEST_SCHEMA_VERSION: u32 = {};
schema_version
);

fs::write(&dest_path, manifest_content).unwrap();
fs::write(&dest_path, manifest_content)
.expect("Failed to write build manifest to OUT_DIR");

println!("cargo:rerun-if-changed=build.rs");
println!("cargo:rerun-if-changed=src/");
Expand All @@ -56,9 +57,7 @@ fn get_git_hash() -> String {
let output = Command::new("git")
.args(&["rev-parse", "HEAD"])
.output()
.unwrap_or_else(|_| {
panic!("Failed to get git hash");
});
.expect("Failed to execute `git rev-parse HEAD` — is git installed and is this a git repository?");

if output.status.success() {
String::from_utf8_lossy(&output.stdout).trim().to_string()
Expand Down
6 changes: 5 additions & 1 deletion app/contract/contracts/Folder/src/role_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,11 @@ fn test_insufficient_role_error() {

match res {
Err(Ok(RustAcademyError::InsufficientRole)) => (),
_ => panic!("Expected InsufficientRole error"),
other => assert!(
false,
"Expected InsufficientRole error but got: {:?}",
other
),
}
}

Expand Down
47 changes: 38 additions & 9 deletions app/contract/contracts/Folder/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,18 @@ fn test_emergency_mode_blocks_risky_entry_points_and_allows_safe_paths() {

let refund_res = client.try_refund(&commitment, &user);

match refund_res {
Ok(Ok(_)) => (),
Ok(Err(e)) => panic!("Contract Logic Error (Check Status/Expiry): {:?}", e),
Err(e) => panic!("Host Auth Error 10 (Check Auth/Account existence): {:?}", e),
match &refund_res {
Ok(Ok(_)) => {}
Ok(Err(e)) => assert!(
false,
"Expected refund to succeed but got contract logic error: {:?}",
e
),
Err(e) => assert!(
false,
"Expected refund to succeed but got host error: {:?}",
e
),
}

assert!(client.try_cleanup_escrow(&commitment).is_ok());
Expand Down Expand Up @@ -368,8 +376,26 @@ fn assert_contract_error<T>(
expected: RustAcademyError,
) {
match result {
Err(Ok(actual)) => assert_eq!(actual, expected),
_ => panic!("expected contract error"),
Err(Ok(actual)) => assert_eq!(
actual, expected,
"Expected contract error {:?} but got {:?}",
expected, actual
),
Err(Err(host_err)) => assert!(
false,
"Expected contract error {:?} but got host error: {:?}",
expected, host_err
),
Ok(Ok(_)) => assert!(
false,
"Expected contract error {:?} but call succeeded",
expected
),
Ok(Err(conversion_err)) => assert!(
false,
"Expected contract error {:?} but got conversion error: {:?}",
expected, conversion_err
),
}
}

Expand All @@ -378,17 +404,20 @@ fn latest_contract_event(env: &Env, contract_id: &Address) -> (soroban_sdk::Vec<
let len = all.len();

for i in (0..len).rev() {
let event = all.get(i).unwrap();
let event = all.get(i).expect("Event index out of bounds while scanning events");
if event.0 == *contract_id {
return (event.1, event.2);
}
}

panic!("no contract event found for contract id")
panic!(
"No contract event found for contract id — expected at least one event to have been emitted"
)
}

fn event_data_map(env: &Env, data: Val) -> Map<Symbol, Val> {
data.try_into_val(env).unwrap()
data.try_into_val(env)
.expect("Failed to convert event data to Map<Symbol, Val>")
}

#[test]
Expand Down
Loading