From 9537bd07bdeb9cd6a3cb261dc8cc2e35a09a9b5c Mon Sep 17 00:00:00 2001 From: Alexander Gonzalez Date: Tue, 9 Apr 2024 20:17:18 +0200 Subject: [PATCH] ref: rename tests feature to std --- contracts/Cargo.toml | 7 ++++++- contracts/src/erc20/extensions/metadata.rs | 2 +- contracts/src/erc20/mod.rs | 2 +- contracts/src/erc721/mod.rs | 2 +- contracts/src/lib.rs | 8 ++++---- 5 files changed, 13 insertions(+), 8 deletions(-) diff --git a/contracts/Cargo.toml b/contracts/Cargo.toml index 7f4019411..be78a7909 100644 --- a/contracts/Cargo.toml +++ b/contracts/Cargo.toml @@ -25,10 +25,15 @@ once_cell = "1.19.0" [features] default = [] -tests = [] + erc20 = [] erc20_metadata = ["erc20"] erc721 = [] +# Enables using the standard library. This is not included in the default +# features, because this crate is meant to be used in a `no_std` environment. +# Currently, the std feature is only used for testing purposes. +std = [] + [lib] crate-type = ["lib", "cdylib"] diff --git a/contracts/src/erc20/extensions/metadata.rs b/contracts/src/erc20/extensions/metadata.rs index 6237a5e61..baa995316 100644 --- a/contracts/src/erc20/extensions/metadata.rs +++ b/contracts/src/erc20/extensions/metadata.rs @@ -87,7 +87,7 @@ impl Metadata { } } -#[cfg(all(test, feature = "tests"))] +#[cfg(all(test, feature = "std"))] mod tests { use alloy_primitives::U256; use stylus_sdk::storage::{StorageBool, StorageString, StorageType}; diff --git a/contracts/src/erc20/mod.rs b/contracts/src/erc20/mod.rs index 461338252..fec28e2ae 100644 --- a/contracts/src/erc20/mod.rs +++ b/contracts/src/erc20/mod.rs @@ -343,7 +343,7 @@ impl ERC20 { } } -#[cfg(all(test, feature = "tests"))] +#[cfg(all(test, feature = "std"))] mod tests { use alloy_primitives::{address, Address, U256}; use stylus_sdk::{ diff --git a/contracts/src/erc721/mod.rs b/contracts/src/erc721/mod.rs index 464b76139..dafdebf2b 100644 --- a/contracts/src/erc721/mod.rs +++ b/contracts/src/erc721/mod.rs @@ -1035,7 +1035,7 @@ impl ERC721 { } } -#[cfg(all(test, feature = "tests"))] +#[cfg(all(test, feature = "std"))] mod tests { use alloy_primitives::address; use once_cell::sync::Lazy; diff --git a/contracts/src/lib.rs b/contracts/src/lib.rs index b38e9a2cd..b96cf6495 100644 --- a/contracts/src/lib.rs +++ b/contracts/src/lib.rs @@ -1,19 +1,19 @@ #![doc = include_str!("../../README.md")] #![warn(missing_docs, unreachable_pub, rust_2021_compatibility)] #![warn(clippy::all, clippy::pedantic)] -#![cfg_attr(not(feature = "tests"), no_std, no_main)] +#![cfg_attr(not(feature = "std"), no_std, no_main)] extern crate alloc; #[global_allocator] static ALLOC: mini_alloc::MiniAlloc = mini_alloc::MiniAlloc::INIT; mod arithmetic; -#[cfg(any(feature = "tests", feature = "erc20"))] +#[cfg(any(feature = "std", feature = "erc20"))] pub mod erc20; -#[cfg(any(feature = "tests", feature = "erc721"))] +#[cfg(any(feature = "std", feature = "erc721"))] pub mod erc721; -#[cfg(not(any(feature = "tests", target_arch = "wasm32-unknown-unknown")))] +#[cfg(not(any(feature = "std", target_arch = "wasm32-unknown-unknown")))] #[panic_handler] fn panic(_info: &core::panic::PanicInfo) -> ! { loop {}