Skip to content

Commit

Permalink
Merge branch 'main' into feat/muxed_keys
Browse files Browse the repository at this point in the history
  • Loading branch information
willemneal authored Nov 6, 2024
2 parents 3802fd1 + 1fc9c34 commit eced1d2
Show file tree
Hide file tree
Showing 30 changed files with 674 additions and 113 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/binaries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ jobs:
- os: ubuntu-20.04 # Use 20.04 to get an older version of glibc for increased compat
target: aarch64-unknown-linux-gnu
- os: macos-14
target: x86_64-apple-darwin
- os: macos-12
target: aarch64-apple-darwin
- os: macos-12
target: x86_64-apple-darwin
- os: windows-latest
target: x86_64-pc-windows-msvc
ext: .exe
Expand Down
35 changes: 17 additions & 18 deletions .github/workflows/rpc-tests.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

name: RPC Tests
on:
push:
Expand All @@ -15,32 +14,32 @@ jobs:
runs-on: ubuntu-22.04
services:
rpc:
image: stellar/quickstart:v438-testing
image: stellar/quickstart:testing
ports:
- 8000:8000
env:
ENABLE_LOGS: true
ENABLE_SOROBAN_DIAGNOSTIC_EVENTS: true
NETWORK: local
PROTOCOL_VERSION: 22
options: >-
--health-cmd "curl --no-progress-meter --fail-with-body -X POST \"http://localhost:8000/soroban/rpc\" -H 'Content-Type: application/json' -d '{\"jsonrpc\":\"2.0\",\"id\":8675309,\"method\":\"getNetwork\"}' && curl --no-progress-meter \"http://localhost:8000/friendbot\" | grep '\"invalid_field\": \"addr\"'"
--health-interval 10s
--health-timeout 5s
--health-retries 50
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- run: rustup update
- run: cargo build
- run: rustup target add wasm32-unknown-unknown
- run: make build-test-wasms
- run: SOROBAN_PORT=8000 cargo test --features it --package soroban-test --test it -- integration

- uses: actions/checkout@v4
- uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- run: rustup update
- run: cargo build
- run: rustup target add wasm32-unknown-unknown
- run: make build-test-wasms
- run: SOROBAN_PORT=8000 cargo test --features it --package soroban-test --test it -- integration
14 changes: 5 additions & 9 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
sys:
- os: ubuntu-latest-16-cores
target: x86_64-unknown-linux-gnu
- os: ubuntu-latest-16-cores
- os: ubuntu-jammy-16-cores-arm64
target: aarch64-unknown-linux-gnu
- os: macos-latest
target: x86_64-apple-darwin
Expand Down Expand Up @@ -79,14 +79,10 @@ jobs:
- if: runner.os == 'Linux'
run: sudo apt-get update && sudo apt-get -y install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu libudev-dev
- run: cargo clippy --all-targets --target ${{ matrix.sys.target }}
- run: make build-test
# TODO: enable ARM linux
- if: startsWith(matrix.sys.target, 'x86_64') || runner.os == 'macOS'
# specify directories explicitly (otherwise it will fail with missing symbols)
run: |
for I in cmd/soroban-cli cmd/crates/* cmd/crates/soroban-test/tests/fixtures/test-wasms/hello_world ; do
cargo test --target ${{ matrix.sys.target }} --manifest-path $I/Cargo.toml
done
- run: make test
env:
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc
CARGO_BUILD_TARGET: ${{ matrix.sys.target }}

publish-dry-run:
if: github.event_name == 'push' || startsWith(github.head_ref, 'release/')
Expand Down
12 changes: 12 additions & 0 deletions Cargo.lock

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

11 changes: 9 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,15 @@ members = [
"cmd/crates/soroban-test/tests/fixtures/hello",
"cmd/crates/soroban-test/tests/fixtures/bye",
]
default-members = ["cmd/soroban-cli", "cmd/crates/soroban-spec-tools", "cmd/crates/soroban-test"]
exclude = ["cmd/crates/soroban-test/tests/fixtures/hello", "cmd/crates/soroban-test/tests/fixtures/bye"]
default-members = [
"cmd/soroban-cli",
"cmd/crates/soroban-spec-tools",
"cmd/crates/soroban-test",
]
exclude = [
"cmd/crates/soroban-test/tests/fixtures/hello",
"cmd/crates/soroban-test/tests/fixtures/bye",
]

[workspace.package]
version = "21.5.0"
Expand Down
56 changes: 55 additions & 1 deletion FULL_HELP_DOCS.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ Anything after the `--` double dash (the "slop") is parsed as arguments to the c

* `contract` — Tools for smart contract developers
* `events` — Watch the network for contract events
* `env` — Prints the current environment variables or defaults to the stdout, in a format that can be used as .env file. Environment variables have precedency over defaults
* `keys` — Create and manage identities including keys and addresses
* `network` — Start and configure networks
* `snapshot` — Download a snapshot of a ledger from an archive
Expand Down Expand Up @@ -387,7 +388,11 @@ If no keys are specified the contract itself is extended.

Deploy a wasm contract

**Usage:** `stellar contract deploy [OPTIONS] --source-account <SOURCE_ACCOUNT> <--wasm <WASM>|--wasm-hash <WASM_HASH>>`
**Usage:** `stellar contract deploy [OPTIONS] --source-account <SOURCE_ACCOUNT> <--wasm <WASM>|--wasm-hash <WASM_HASH>> [-- <CONTRACT_CONSTRUCTOR_ARGS>...]`

###### **Arguments:**

* `<CONTRACT_CONSTRUCTOR_ARGS>` — If provided, will be passed to the contract's `__constructor` function with provided arguments for that function as `--arg-name value`

###### **Options:**

Expand Down Expand Up @@ -897,6 +902,19 @@ Watch the network for contract events



## `stellar env`

Prints the current environment variables or defaults to the stdout, in a format that can be used as .env file. Environment variables have precedency over defaults

**Usage:** `stellar env [OPTIONS]`

###### **Options:**

* `--global` — Use global config
* `--config-dir <CONFIG_DIR>` — Location of config directory, default is "."



## `stellar keys`

Create and manage identities including keys and addresses
Expand All @@ -912,6 +930,7 @@ Create and manage identities including keys and addresses
* `ls` — List identities
* `rm` — Remove an identity
* `show` — Given an identity return its private key
* `use` — Set the default identity that will be used on all commands. This allows you to skip `--source-account` or setting a environment variable, while reusing this value in all commands that require it



Expand Down Expand Up @@ -1052,6 +1071,23 @@ Given an identity return its private key



## `stellar keys use`

Set the default identity that will be used on all commands. This allows you to skip `--source-account` or setting a environment variable, while reusing this value in all commands that require it

**Usage:** `stellar keys use [OPTIONS] <NAME>`

###### **Arguments:**

* `<NAME>` — Set the default network name

###### **Options:**

* `--global` — Use global config
* `--config-dir <CONFIG_DIR>` — Location of config directory, default is "."



## `stellar network`

Start and configure networks
Expand All @@ -1065,6 +1101,7 @@ Start and configure networks
* `ls` — List networks
* `start` — ⚠️ Deprecated: use `stellar container start` instead
* `stop` — ⚠️ Deprecated: use `stellar container stop` instead
* `use` — Set the default network that will be used on all commands. This allows you to skip `--network` or setting a environment variable, while reusing this value in all commands that require it
* `container` — Commands to start, stop and get logs for a quickstart container


Expand Down Expand Up @@ -1174,6 +1211,23 @@ Stop a network started with `network start`. For example, if you ran `stellar ne



## `stellar network use`

Set the default network that will be used on all commands. This allows you to skip `--network` or setting a environment variable, while reusing this value in all commands that require it

**Usage:** `stellar network use [OPTIONS] <NAME>`

###### **Arguments:**

* `<NAME>` — Set the default network name

###### **Options:**

* `--global` — Use global config
* `--config-dir <CONFIG_DIR>` — Location of config directory, default is "."



## `stellar network container`

Commands to start, stop and get logs for a quickstart container
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ generate-full-help-doc:
cargo run --bin doc-gen --features clap-markdown

test: build-test
cargo test
cargo test --workspace

e2e-test:
cargo test --features it --test it -- integration
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[package]
name = "test_constructor"
version = "21.5.0"
authors = ["Stellar Development Foundation <[email protected]>"]
license = "Apache-2.0"
edition = "2021"
publish = false
rust-version.workspace = true

[lib]
crate-type = ["cdylib"]
doctest = false

[dependencies]
soroban-sdk = { workspace = true }

[dev-dependencies]
soroban-sdk = { workspace = true, features = ["testutils"]}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#![no_std]
use soroban_sdk::{contract, contractimpl, symbol_short, Env, Symbol};

#[contract]
pub struct Contract;
const COUNTER: Symbol = symbol_short!("COUNTER");

#[contractimpl]
impl Contract {
/// Example constructor
pub fn __constructor(env: Env, counter: u32) {
env.storage().persistent().set(&COUNTER, &counter);
}
/// Counter value
pub fn counter(env: Env) -> u32 {
env.storage().persistent().get(&COUNTER).unwrap()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ use token::Client as TokenClient;
use token::StellarAssetClient as TokenAdminClient;

fn create_token_contract<'a>(e: &Env, admin: &Address) -> (TokenClient<'a>, TokenAdminClient<'a>) {
let contract_address = e.register_stellar_asset_contract(admin.clone());
let contract_address = e
.register_stellar_asset_contract_v2(admin.clone())
.address();
(
TokenClient::new(e, &contract_address),
TokenAdminClient::new(e, &contract_address),
Expand Down
53 changes: 53 additions & 0 deletions cmd/crates/soroban-test/tests/it/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -340,3 +340,56 @@ fn config_dirs_precedence() {
))
.stdout("SAQMV6P3OWM2SKCK3OEWNXSRYWK5RNNUL5CPHQGIJF2WVT4EI2BZ63GG\n");
}

#[test]
fn set_default_identity() {
let sandbox = TestEnv::default();

sandbox
.new_assert_cmd("keys")
.env(
"SOROBAN_SECRET_KEY",
"SC4ZPYELVR7S7EE7KZDZN3ETFTNQHHLTUL34NUAAWZG5OK2RGJ4V2U3Z",
)
.arg("add")
.arg("alice")
.assert()
.success();

sandbox
.new_assert_cmd("keys")
.arg("use")
.arg("alice")
.assert()
.stderr(predicate::str::contains(
"The default source account is set to `alice`",
))
.success();

sandbox
.new_assert_cmd("env")
.assert()
.stdout(predicate::str::contains("STELLAR_ACCOUNT=alice"))
.success();
}

#[test]
fn set_default_network() {
let sandbox = TestEnv::default();

sandbox
.new_assert_cmd("network")
.arg("use")
.arg("testnet")
.assert()
.stderr(predicate::str::contains(
"The default network is set to `testnet`",
))
.success();

sandbox
.new_assert_cmd("env")
.assert()
.stdout(predicate::str::contains("STELLAR_NETWORK=testnet"))
.success();
}
1 change: 1 addition & 0 deletions cmd/crates/soroban-test/tests/it/integration.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
mod bindings;
mod constructor;
mod cookbook;
mod custom_types;
mod dotenv;
Expand Down
Loading

0 comments on commit eced1d2

Please sign in to comment.