Skip to content

Commit

Permalink
short circuit test-only code by mockable feature
Browse files Browse the repository at this point in the history
  • Loading branch information
h4x3rotab committed Jun 24, 2022
1 parent 5a8ac92 commit 69c2f5e
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ pausable = ["openbrush_contracts/pausable"]
timelock_controller = ["openbrush_contracts/timelock_controller"]
proxy = ["openbrush_contracts/proxy"]
diamond = ["openbrush_contracts/diamond"]
mockable = ["openbrush_lang/mockable"]

[profile.release]
panic = "abort"
Expand Down
3 changes: 2 additions & 1 deletion lang/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,5 @@ std = [
"ink_metadata/std",
"scale/std",
"scale-info/std",
]
]
mockable = []
3 changes: 0 additions & 3 deletions lang/codegen/src/trait_definition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ pub fn generate(_attrs: TokenStream, _input: TokenStream) -> TokenStream {
}
let attrs: proc_macro2::TokenStream = _attrs.into();
let (mock_type, attrs) = extract_mock_config(attrs);
println!("mock_type: {:?}", mock_type);
println!("extracted_attrs: {:?}", attrs);
let mut trait_item: ItemTrait = parse2(_input).unwrap();
let trait_without_ink_attrs;
let ink_code;
Expand Down Expand Up @@ -139,7 +137,6 @@ pub fn generate(_attrs: TokenStream, _input: TokenStream) -> TokenStream {

#maybe_use_mock_env
};
// println!("Final output: {}", code);
code.into()
}

Expand Down
1 change: 1 addition & 0 deletions lang/src/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ pub trait Flush: ::ink_storage::traits::SpreadLayout + InkStorage {
impl<T: ::ink_storage::traits::SpreadLayout + InkStorage> Flush for T {}

/// Types for managing mock cross-contract calls in unit tests
#[cfg(feature = "mockable")]
pub mod mock {
use super::AccountId;

Expand Down

0 comments on commit 69c2f5e

Please sign in to comment.