smart-contractslisted
Install: claude install-skill rylsherdamz-rgb/stellar-agentic-framework
# Smart Contracts (Soroban)
## Source Files
| File | Contents |
|------|----------|
| `contracts/hello-world/src/lib.rs` | Minimal contract scaffold |
| `contracts/hello-world/src/test.rs` | Unit + auth + event tests |
| `contracts/token/src/lib.rs` | Full SEP-41 token |
| `contracts/token/src/test.rs` | Token unit + integration tests |
---
## Testing Guide
### Setup
```rust
#![cfg(test)]
extern crate std;
use soroban_sdk::{
testutils::{Address as _, Events},
Address, Env, String, Symbol,
};
```
### Pattern 1: Unit Test with Setup Helper
Extract shared setup into a helper function:
```rust
fn setup() -> (Env, Address, Address, MyContractClient<'static>) {
let env = Env::default();
env.mock_all_auths();
let admin = Address::generate(&env);
let user = Address::generate(&env);
let contract_id = env.register(MyContract, (&admin, 1000u32));
let client = MyContractClient::new(&env, &contract_id);
(env, admin, user, client)
}
#[test]
fn test_initial_state() {
let (_, _, _, client) = setup();
assert_eq!(client.get_count(), 0);
}
```
### Pattern 2: Auth Testing (without mock_all_auths)
Test that only authorized callers can invoke privileged functions:
```rust
#[test]
fn test_auth_required() {
let env = Env::default();
// Do NOT call mock_all_auths() — test auth failures
let admin = Address::generate(&env);
let attacker = Address::generate(&env);
let contract_id = env.register(MyContract, (&admin,));
let c