Skip to content

Commit

Permalink
Make tests faster (#694)
Browse files Browse the repository at this point in the history
  • Loading branch information
leighmcculloch authored Sep 30, 2022
1 parent db5bb28 commit f3f32bd
Show file tree
Hide file tree
Showing 70 changed files with 238 additions and 842 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
- run: cargo install --target-dir ~/.cargo/target --locked --version 0.5.16 cargo-hack
- run: cargo hack build --target wasm32-unknown-unknown --profile release
- run: cargo hack --feature-powerset --exclude-features docs build --target ${{ matrix.sys.target }}
- run: cargo hack --feature-powerset --exclude-features docs test --target ${{ matrix.sys.target }}
- run: cargo hack --feature-powerset --ignore-unknown-features --features testutils --exclude-features docs test --target ${{ matrix.sys.target }}

docs:
runs-on: ubuntu-latest
Expand Down
236 changes: 66 additions & 170 deletions Cargo.lock

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

8 changes: 0 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,16 @@ members = [
"soroban-sdk-macros",
"soroban-spec",
"tests/empty",
"tests/hello",
"tests/add_i32",
"tests/add_i64",
"tests/add_u64",
"tests/add_bigint",
"tests/vec",
"tests/import_contract",
"tests/invoke_contract",
"tests/call_stack",
"tests/udt",
"tests/contract_data",
"tests/create_contract",
"tests/events",
"tests/logging",
"tests/errors",
"tests/account",
]

[patch.crates-io]
soroban-sdk = { path = "soroban-sdk" }
soroban-auth = { path = "soroban-auth" }
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ doc: fmt
cargo +nightly doc -p soroban-sdk -p soroban-auth --no-deps --features docs,testutils $(CARGO_DOC_ARGS)

test: fmt build
cargo hack --feature-powerset --exclude-features docs $(CARGO_TEST_SUBCOMMAND)
cargo hack --feature-powerset --ignore-unknown-features --features testutils --exclude-features docs $(CARGO_TEST_SUBCOMMAND)

build: fmt
cargo hack build --target wasm32-unknown-unknown --release
Expand Down
26 changes: 13 additions & 13 deletions soroban-sdk-macros/src/derive_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,16 +83,16 @@ impl<'a> ClientFn<'a> {
}
pub fn try_output(&self) -> Type {
let (t, e) = match self.output {
ReturnType::Default => (quote!(()), quote!(::soroban_sdk::Status)),
ReturnType::Default => (quote!(()), quote!(soroban_sdk::Status)),
ReturnType::Type(_, typ) => match unpack_result(typ) {
Some((t, e)) => (quote!(#t), quote!(#e)),
None => (quote!(#typ), quote!(::soroban_sdk::Status)),
None => (quote!(#typ), quote!(soroban_sdk::Status)),
},
};
Type::Verbatim(quote! {
Result<
Result<#t, <#t as ::soroban_sdk::TryFromVal<::soroban_sdk::Env, ::soroban_sdk::RawVal>>::Error>,
Result<#e, <#e as TryFrom<::soroban_sdk::Status>>::Error>
Result<#t, <#t as soroban_sdk::TryFromVal<soroban_sdk::Env, soroban_sdk::RawVal>>::Error>,
Result<#e, <#e as TryFrom<soroban_sdk::Status>>::Error>
>
})
}
Expand Down Expand Up @@ -151,21 +151,21 @@ pub fn derive_client(name: &str, fns: &[ClientFn]) -> TokenStream {
quote! {
#(#fn_attrs)*
pub fn #fn_ident(&self, #(#fn_input_types),*) -> #fn_output {
use ::soroban_sdk::IntoVal;
use soroban_sdk::IntoVal;
self.env.invoke_contract(
&self.contract_id,
&::soroban_sdk::symbol!(#fn_name),
::soroban_sdk::vec![&self.env, #(#fn_input_names.into_val(&self.env)),*],
&soroban_sdk::symbol!(#fn_name),
soroban_sdk::vec![&self.env, #(#fn_input_names.into_val(&self.env)),*],
)
}

#(#fn_attrs)*
pub fn #fn_try_ident(&self, #(#fn_input_types),*) -> #fn_try_output {
use ::soroban_sdk::IntoVal;
use soroban_sdk::IntoVal;
self.env.try_invoke_contract(
&self.contract_id,
&::soroban_sdk::symbol!(#fn_name),
::soroban_sdk::vec![&self.env, #(#fn_input_names.into_val(&self.env)),*],
&soroban_sdk::symbol!(#fn_name),
soroban_sdk::vec![&self.env, #(#fn_input_names.into_val(&self.env)),*],
)
}
}
Expand All @@ -182,11 +182,11 @@ pub fn derive_client(name: &str, fns: &[ClientFn]) -> TokenStream {
let client_ident = format_ident!("{}", name);
quote! {
pub struct #client_ident {
env: ::soroban_sdk::Env,
contract_id: ::soroban_sdk::BytesN<32>,
env: soroban_sdk::Env,
contract_id: soroban_sdk::BytesN<32>,
}
impl #client_ident {
pub fn new(env: &::soroban_sdk::Env, contract_id: impl ::soroban_sdk::IntoVal<::soroban_sdk::Env, ::soroban_sdk::BytesN<32>>) -> Self {
pub fn new(env: &soroban_sdk::Env, contract_id: impl soroban_sdk::IntoVal<soroban_sdk::Env, soroban_sdk::BytesN<32>>) -> Self {
Self {
env: env.clone(),
contract_id: contract_id.into_val(env),
Expand Down
Loading

0 comments on commit f3f32bd

Please sign in to comment.