Skip to content
Merged
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
37 changes: 14 additions & 23 deletions crates/contracts/core/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,42 +1,33 @@
#![no_std]
use soroban_sdk::{contract, contractimpl, Env, Symbol};
use soroban_sdk::{contract, contractimpl, Address, Env};

#[contract]
pub struct StellarAidContract;
pub struct CoreContract;

#[contractimpl]
impl StellarAidContract {
pub fn hello(_env: Env, _to: Symbol) -> Symbol {
soroban_sdk::symbol_short!("Hello")
}
impl CoreContract {
pub fn init(_env: Env, _admin: Address) {}

pub fn get_greeting(_env: Env) -> Symbol {
soroban_sdk::symbol_short!("Hi")
pub fn ping(_env: Env) -> u32 {
1
}
}

#[cfg(test)]
mod tests {
use super::*;
use soroban_sdk::{symbol_short, Env};
use soroban_sdk::Env;

#[test]
fn test_hello() {
fn test_init_and_ping() {
let env = Env::default();
let contract_id = env.register_contract(None, StellarAidContract);
let client = StellarAidContractClient::new(&env, &contract_id);

let result = client.hello(&symbol_short!("World"));
assert_eq!(result, symbol_short!("Hello"));
}
let contract_id = env.register_contract(None, CoreContract);
let client = CoreContractClient::new(&env, &contract_id);

#[test]
fn test_get_greeting() {
let env = Env::default();
let contract_id = env.register_contract(None, StellarAidContract);
let client = StellarAidContractClient::new(&env, &contract_id);
let admin = env.current_contract_address();
client.init(&admin);

let result = client.get_greeting();
assert_eq!(result, symbol_short!("Hi"));
let result = client.ping();
assert_eq!(result, 1);
}
}
Loading