-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(axelar-std)!: add pausable interface (#204)
- Loading branch information
1 parent
9c1fec1
commit 0d4af95
Showing
21 changed files
with
319 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 11 additions & 12 deletions
23
contracts/stellar-interchain-token-service/src/tests/pause.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,39 @@ | ||
use soroban_sdk::testutils::Address as _; | ||
use soroban_sdk::Address; | ||
use stellar_axelar_std::interfaces::{PausedEvent, UnpausedEvent}; | ||
use stellar_axelar_std::{assert_auth, assert_auth_err, events}; | ||
|
||
use super::utils::setup_env; | ||
use crate::event::PauseStatusSetEvent; | ||
|
||
#[test] | ||
fn pause_succeeds() { | ||
let (env, client, _, _, _) = setup_env(); | ||
|
||
assert!(!client.is_paused()); | ||
assert!(!client.paused()); | ||
|
||
assert_auth!(client.owner(), client.set_pause_status(&true)); | ||
goldie::assert!(events::fmt_last_emitted_event::<PauseStatusSetEvent>(&env)); | ||
assert_auth!(client.owner(), client.pause()); | ||
goldie::assert!(events::fmt_last_emitted_event::<PausedEvent>(&env)); | ||
|
||
assert!(client.is_paused()); | ||
assert!(client.paused()); | ||
} | ||
|
||
#[test] | ||
fn unpause_succeeds() { | ||
let (env, client, _, _, _) = setup_env(); | ||
|
||
assert_auth!(client.owner(), client.set_pause_status(&true)); | ||
assert_auth!(client.owner(), client.pause()); | ||
|
||
assert!(client.is_paused()); | ||
assert_auth!(client.owner(), client.set_pause_status(&false)); | ||
assert!(client.paused()); | ||
assert_auth!(client.owner(), client.unpause()); | ||
|
||
goldie::assert!(events::fmt_last_emitted_event::<PauseStatusSetEvent>(&env)); | ||
goldie::assert!(events::fmt_last_emitted_event::<UnpausedEvent>(&env)); | ||
|
||
assert!(!client.is_paused()); | ||
assert!(!client.paused()); | ||
} | ||
|
||
#[test] | ||
fn pause_fails_with_invalid_auth() { | ||
let (env, client, _, _, _) = setup_env(); | ||
|
||
let user = Address::generate(&env); | ||
assert_auth_err!(user, client.set_pause_status(&true)); | ||
assert_auth_err!(Address::generate(&env), client.pause()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 2 additions & 5 deletions
7
contracts/stellar-interchain-token-service/src/tests/testdata/pause_succeeds.golden
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,6 @@ | ||
PauseStatusSetEvent { | ||
paused: true, | ||
} | ||
PausedEvent | ||
|
||
Contract(CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAVAX5) | ||
|
||
pause_status_set { | ||
#[topic] paused: bool, | ||
paused { | ||
} |
7 changes: 2 additions & 5 deletions
7
contracts/stellar-interchain-token-service/src/tests/testdata/unpause_succeeds.golden
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,6 @@ | ||
PauseStatusSetEvent { | ||
paused: false, | ||
} | ||
UnpausedEvent | ||
|
||
Contract(CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAVAX5) | ||
|
||
pause_status_set { | ||
#[topic] paused: bool, | ||
unpaused { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.