stellar / soroban-examples

Example Soroban Contracts
Apache License 2.0
65 stars 68 forks source link

Remove self-circular testutils deps #59

Closed leighmcculloch closed 2 years ago

leighmcculloch commented 2 years ago

What

Remove self-circular testutils dev dependencies.

Why

It causes errors in rust-analyzer which doesn't expect the circular reference. It is also reasonably confusing to others because (e.g. @graydon had questions about it) and requires a decent amount of discussion to knowledge share why it exists.

The circular reference was added to activate things that are gated behind testutils feature, so that those things are always activated during tests. However, Rust provides a built-in way for us to do this today, without needing the circular reference. All we need to do is use the #[cfg(test)] attribute. If we have items that need to be testutils for externals and we want them to always be activated within the crates own tests, then we can use #[cfg(any(test, feature = "testutils"))]. We already use this pattern in the SDK macros for any testutils.

See https://github.com/stellar/rs-soroban-sdk/pull/401