-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Split out soroban-rpc test contract and remove rlib to reduce size un…
…der 1KB
- Loading branch information
Showing
5 changed files
with
63 additions
and
34 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
cmd/crates/soroban-test/tests/fixtures/test-wasms/soroban_rpc/Cargo.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
[package] | ||
name = "test_soroban_rpc" | ||
version = "0.9.4" | ||
authors = ["Stellar Development Foundation <info@stellar.org>"] | ||
license = "Apache-2.0" | ||
edition = "2021" | ||
publish = false | ||
rust-version = "1.70" | ||
|
||
[lib] | ||
crate-type = ["cdylib"] | ||
doctest = false | ||
|
||
[dependencies] | ||
soroban-sdk = { workspace = true } | ||
|
||
[dev-dependencies] | ||
soroban-sdk = { workspace = true, features = ["testutils"]} |
27 changes: 27 additions & 0 deletions
27
cmd/crates/soroban-test/tests/fixtures/test-wasms/soroban_rpc/src/lib.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#![no_std] | ||
use soroban_sdk::{contract, contractimpl, symbol_short, Address, Env, Symbol}; | ||
|
||
const COUNTER: Symbol = symbol_short!("COUNTER"); | ||
|
||
#[contract] | ||
pub struct Contract; | ||
|
||
#[contractimpl] | ||
impl Contract { | ||
pub fn auth(env: Env, addr: Address, world: Symbol) -> Address { | ||
addr.require_auth(); | ||
// Emit test event | ||
env.events().publish(("auth",), world); | ||
|
||
addr | ||
} | ||
|
||
pub fn inc(env: Env) { | ||
let mut count: u32 = env.storage().persistent().get(&COUNTER).unwrap_or(0); // Panic if the value of COUNTER is not u32. | ||
|
||
// Increment the count. | ||
count += 1; | ||
// Save the count. | ||
env.storage().persistent().set(&COUNTER, &count); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters