Skip to content

Commit

Permalink
rename assert_single_event to assert_event
Browse files Browse the repository at this point in the history
  • Loading branch information
Foivos committed Nov 20, 2024
1 parent d65578f commit 76733ca
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 18 deletions.
4 changes: 2 additions & 2 deletions move/axelar_gateway/sources/channel.move
Original file line number Diff line number Diff line change
Expand Up @@ -199,9 +199,9 @@ public(package) fun approved_message_payload(
fun test_new_and_destroy() {
let ctx = &mut sui::tx_context::dummy();
let channel: Channel = new(ctx);
utils::assert_single_event<events::ChannelCreated>();
utils::assert_event<events::ChannelCreated>();
channel.destroy();
utils::assert_single_event<events::ChannelDestroyed>();
utils::assert_event<events::ChannelDestroyed>();
}

#[test]
Expand Down
8 changes: 4 additions & 4 deletions move/axelar_gateway/sources/gateway.move
Original file line number Diff line number Diff line change
Expand Up @@ -603,7 +603,7 @@ fun test_take_approved_message() {
payload,
);

utils::assert_single_event<events::MessageExecuted>();
utils::assert_event<events::MessageExecuted>();

let expected_approved_message = axelar_gateway::channel::create_approved_message(
source_chain,
Expand Down Expand Up @@ -666,7 +666,7 @@ fun test_approve_messages() {

self.approve_messages(bcs::to_bytes(&messages), bcs::to_bytes(&proof));

utils::assert_single_event<events::MessageApproved>();
utils::assert_event<events::MessageApproved>();

clock.destroy_for_testing();
sui::test_utils::destroy(self)
Expand Down Expand Up @@ -768,7 +768,7 @@ fun test_rotate_signers() {
ctx,
);

utils::assert_single_event<events::SignersRotated>();
utils::assert_event<events::SignersRotated>();

let data_hash = gateway_v0::rotate_signers_data_hash(next_weighted_signers);
let proof = generate_proof(
Expand Down Expand Up @@ -1053,7 +1053,7 @@ fun test_send_message() {
let gateway = dummy(ctx);
gateway.send_message(message_ticket);

utils::assert_single_event<events::ContractCall>();
utils::assert_event<events::ContractCall>();

sui::test_utils::destroy(gateway);
channel.destroy();
Expand Down
4 changes: 2 additions & 2 deletions move/its/sources/events.move
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ fun test_interchain_transfer_empty_data() {
amount,
&data,
);
let event = utils::assert_single_event<InterchainTransfer<COIN>>();
let event = utils::assert_event<InterchainTransfer<COIN>>();

assert!(event.data_hash == data_hash);
assert!(event.source_address == source_address);
Expand Down Expand Up @@ -230,7 +230,7 @@ fun test_interchain_transfer_nonempty_data() {
amount,
&data,
);
let event = utils::assert_single_event<InterchainTransfer<COIN>>();
let event = utils::assert_event<InterchainTransfer<COIN>>();

assert!(event.data_hash == data_hash);
assert!(event.source_address == source_address);
Expand Down
14 changes: 7 additions & 7 deletions move/its/sources/its.move
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ fun test_register_coin() {
let coin_management = its::coin_management::new_locked();

register_coin(&mut its, coin_info, coin_management);
utils::assert_single_event<its::events::CoinRegistered<COIN>>();
utils::assert_event<its::events::CoinRegistered<COIN>>();

sui::test_utils::destroy(its);
}
Expand Down Expand Up @@ -463,7 +463,7 @@ fun test_deploy_remote_interchain_token() {
destination_chain,
);

utils::assert_single_event<its::events::InterchainTokenDeploymentStarted<COIN>>();
utils::assert_event<its::events::InterchainTokenDeploymentStarted<COIN>>();

let mut writer = abi::new_writer(6);

Expand Down Expand Up @@ -503,7 +503,7 @@ fun test_deploy_interchain_token() {

let token_id = register_coin(&mut its, coin_info, coin_management);

utils::assert_single_event<its::events::CoinRegistered<COIN>>();
utils::assert_event<its::events::CoinRegistered<COIN>>();

let amount = 1234;
let coin = sui::coin::mint_for_testing<COIN>(amount, ctx);
Expand All @@ -527,7 +527,7 @@ fun test_deploy_interchain_token() {
&clock,
);

utils::assert_single_event<its::events::InterchainTransfer<COIN>>();
utils::assert_event<its::events::InterchainTransfer<COIN>>();

let mut writer = abi::new_writer(6);

Expand Down Expand Up @@ -599,7 +599,7 @@ fun test_receive_interchain_transfer() {

receive_interchain_transfer<COIN>(&mut its, approved_message, &clock, ctx);

utils::assert_single_event<its::events::InterchainTransferReceived<COIN>>();
utils::assert_event<its::events::InterchainTransferReceived<COIN>>();

clock.destroy_for_testing();
sui::test_utils::destroy(its);
Expand Down Expand Up @@ -661,7 +661,7 @@ fun test_receive_interchain_transfer_with_data() {
ctx,
);

utils::assert_single_event<its::events::InterchainTransferReceived<COIN>>();
utils::assert_event<its::events::InterchainTransferReceived<COIN>>();

assert!(received_source_chain == source_chain);
assert!(received_source_address == its_source_address);
Expand Down Expand Up @@ -710,7 +710,7 @@ fun test_receive_deploy_interchain_token() {

receive_deploy_interchain_token<COIN>(&mut its, approved_message);

utils::assert_single_event<its::events::CoinRegistered<COIN>>();
utils::assert_event<its::events::CoinRegistered<COIN>>();

clock.destroy_for_testing();
sui::test_utils::destroy(its);
Expand Down
6 changes: 3 additions & 3 deletions move/utils/sources/utils/utils.move
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ public macro fun peel<$T>($data: vector<u8>, $peel_fn: |&mut BCS| -> $T): $T {
use sui::event;

#[test_only]
public fun assert_events<T: copy + drop>(n: u64): vector<T> {
public fun assert_events<T: copy + drop>(event_count: u64): vector<T> {
let events = event::events_by_type<T>();
assert!(events.length() == n);
assert!(events.length() == event_count);
events
}

#[test_only]
public fun assert_single_event<T: copy + drop>(): T {
public fun assert_event<T: copy + drop>(): T {
let events = assert_events<T>(1);
events[0]
}
Expand Down

0 comments on commit 76733ca

Please sign in to comment.