Skip to content

Commit

Permalink
fix(pausable): rename unit test and fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
brozorec committed Jan 7, 2025
1 parent 8e4ba91 commit c5635bb
Show file tree
Hide file tree
Showing 11 changed files with 21 additions and 23 deletions.
1 change: 0 additions & 1 deletion contracts/utils/pausable/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,3 @@ pub enum PausableError {
/// The operation failed because the contract is not paused.
ExpectedPause = 2,
}

2 changes: 1 addition & 1 deletion contracts/utils/pausable/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ mod storage;

pub use crate::{
clients::{Pausable, PausableClient},
storage::{paused, pause, unpause, when_not_paused, when_paused},
storage::{pause, paused, unpause, when_not_paused, when_paused},
};

mod test;
38 changes: 19 additions & 19 deletions contracts/utils/pausable/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use crate::storage::{pause, paused, unpause, when_not_paused, when_paused, PAUSE
struct MockContract;

#[test]
fn test_initial_state() {
fn initial_state() {
let e = Env::default();
let address = e.register(MockContract, ());

Expand All @@ -23,7 +23,7 @@ fn test_initial_state() {
}

#[test]
fn test_pause() {
fn pause_works() {
let e = Env::default();
e.mock_all_auths();
let address = e.register(MockContract, ());
Expand All @@ -35,18 +35,18 @@ fn test_pause() {
assert_eq!(paused(&e), true);

//assert_eq!(
//e.auths(),
//[(
//caller.clone(),
//AuthorizedInvocation {
//function: AuthorizedFunction::Contract((
//address.clone(),
//symbol_short!("pause"),
//vec![&e, caller.clone().into_val(&e)]
//)),
//sub_invocations: [].to_vec()
//}
//)]
//e.auths(),
//[(
//caller.clone(),
//AuthorizedInvocation {
//function: AuthorizedFunction::Contract((
//address.clone(),
//symbol_short!("pause"),
//vec![&e, caller.clone().into_val(&e)]
//)),
//sub_invocations: [].to_vec()
//}
//)]
//);

let events = e.events().all();
Expand All @@ -66,7 +66,7 @@ fn test_pause() {
}

#[test]
fn test_unpause() {
fn unpause_works() {
let e = Env::default();
e.mock_all_auths();
let address = e.register(MockContract, ());
Expand Down Expand Up @@ -97,7 +97,7 @@ fn test_unpause() {

#[test]
#[should_panic(expected = "Error(Contract, #1)")]
fn test_pause_when_paused() {
fn errors_pause_when_paused() {
let e = Env::default();
e.mock_all_auths();
let address = e.register(MockContract, ());
Expand All @@ -113,7 +113,7 @@ fn test_pause_when_paused() {

#[test]
#[should_panic(expected = "Error(Contract, #2)")]
fn test_unpause_when_not_paused() {
fn errors_unpause_when_not_paused() {
let e = Env::default();
e.mock_all_auths();
let address = e.register(MockContract, ());
Expand All @@ -126,7 +126,7 @@ fn test_unpause_when_not_paused() {
}

#[test]
fn test_when_not_paused() {
fn when_not_paused_works() {
let e = Env::default();
let address = e.register(MockContract, ());

Expand All @@ -137,7 +137,7 @@ fn test_when_not_paused() {
}

#[test]
fn test_when_paused() {
fn when_paused_works() {
let e = Env::default();
e.mock_all_auths();
let address = e.register(MockContract, ());
Expand Down
3 changes: 1 addition & 2 deletions examples/pausable/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@
//!
//! Counter can be incremented only when `unpaused` and reset only when `paused`.
use openzeppelin_pausable::{self as pausable, Pausable};
use soroban_sdk::{
contract, contracterror, contractimpl, contracttype, panic_with_error, Address, Env,
};

use openzeppelin_pausable::{self as pausable, Pausable};

#[contracttype]
pub enum DataKey {
Owner,
Expand Down

0 comments on commit c5635bb

Please sign in to comment.