Skip to content

Commit

Permalink
chore: add test for checking pause control (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
aleksuss authored Mar 17, 2023
1 parent 61ae8e2 commit aee2fe9
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
37 changes: 37 additions & 0 deletions eth-connector/src/admin_controlled.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,40 @@ pub mod error {
}
}
}

#[test]
fn test_pause_control() {
use crate::connector_impl::EthConnector;

let mut connector = EthConnector {
prover_account: "prover".parse().unwrap(),
eth_custodian_address: Default::default(),
paused_mask: UNPAUSE_ALL,
account_with_access_right: "aurora".parse().unwrap(),
owner_id: "aurora".parse().unwrap(),
};

assert!(connector.assert_not_paused(PAUSE_DEPOSIT).is_ok());
assert!(connector.assert_not_paused(PAUSE_WITHDRAW).is_ok());

connector.set_paused_flags(PAUSE_DEPOSIT);

assert!(connector.assert_not_paused(PAUSE_DEPOSIT).is_err());
assert!(connector.assert_not_paused(PAUSE_WITHDRAW).is_ok());

connector.set_paused_flags(UNPAUSE_ALL);
connector.set_paused_flags(PAUSE_WITHDRAW);

assert!(connector.assert_not_paused(PAUSE_DEPOSIT).is_ok());
assert!(connector.assert_not_paused(PAUSE_WITHDRAW).is_err());

connector.set_paused_flags(PAUSE_WITHDRAW | PAUSE_DEPOSIT);

assert!(connector.assert_not_paused(PAUSE_DEPOSIT).is_err());
assert!(connector.assert_not_paused(PAUSE_WITHDRAW).is_err());

connector.set_paused_flags(UNPAUSE_ALL);

assert!(connector.assert_not_paused(PAUSE_DEPOSIT).is_ok());
assert!(connector.assert_not_paused(PAUSE_WITHDRAW).is_ok());
}
2 changes: 1 addition & 1 deletion eth-connector/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ impl ConnectorWithdraw for EthConnectorContract {
self.assert_access_right().sdk_unwrap();
assert_one_yocto();

// Check is current flow paused. If it's owner just skip asserrion.
// Check is current flow paused. If it's owner just skip assertion.
self.assert_not_paused(PAUSE_WITHDRAW)
.map_err(|_| "WithdrawErrorPaused")
.sdk_unwrap();
Expand Down

0 comments on commit aee2fe9

Please sign in to comment.