use serde_json::json; use near_sdk::json_types::U128; use near_sdk::NearToken; #[tokio::test] async fn test_contract_is_operational() -> Result<(), Box> { let contract_wasm = near_workspaces::compile_project("./").await?; test_basics_on(&contract_wasm).await?; Ok(()) } async fn test_basics_on(contract_wasm: &[u8]) -> Result<(), Box> { let sandbox = near_workspaces::sandbox().await?; let contract = sandbox.dev_deploy(contract_wasm).await?; let user_account = sandbox.dev_create_account().await?; // Initialize the contract with owner and price let outcome = contract .call("new") .args_json(json!({ "owner_id": contract.id(), "initial_price": U128(NearToken::from_near(1).as_yoctonear()) })) .transact() .await?; assert!(outcome.is_success()); let outcome = user_account .call(contract.id(), "set_greeting") .args_json(json!({"greeting": "Hello World!"})) .transact() .await?; assert!(outcome.is_success()); let user_message_outcome = contract.view("get_greeting").args_json(json!({})).await?; assert_eq!(user_message_outcome.json::()?, "Hello World!"); Ok(()) }