Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

assert_expected_events! gives false positives on inner enum values #2460

Open
2 tasks done
Tracked by #50
0xmovses opened this issue Nov 22, 2023 · 3 comments
Open
2 tasks done
Tracked by #50

assert_expected_events! gives false positives on inner enum values #2460

0xmovses opened this issue Nov 22, 2023 · 3 comments
Labels
I2-bug The node fails to follow expected behavior. I10-unconfirmed Issue might be valid, but it's not yet known.

Comments

@0xmovses
Copy link
Contributor

0xmovses commented Nov 22, 2023

Is there an existing issue?

  • I have searched the existing issues

Experiencing problems? Have you tried our Stack Exchange first?

  • This is not a support question.

Description of bug

In XCM emulator tests, when asserting on inner Event enum values, the macro will always pass even if the assertion should fail. For example:

assert_expected_events!(
	PeopleRococo,
	vec![
		RuntimeEvent::Balances(pallet_balances::Event::Endowed { account, free_balance }) => {
		    account: *account == PeopleRococoSender::get(),
		    free_balance: *free_balance == 42,
		    },
		]
);

No matter what number you assert free_balance, it will always pass (if the event is emitted).

*free_balance == 42,
*free_balance == 10000,
*free_balance == 234598,

These will all pass. We don't want false positives on XCM emulator tests for obvious reasons.

Steps to reproduce

  1. On master, navigate to cumulus/parachains/integration-tests/emulated/tests/assets/asset-hub-rococo/src/tests/send.rs

  2. On line 90 you'll see an assertion :

assert_expected_events!(
			AssetHubRococo,
			vec![
				RuntimeEvent::Assets(pallet_assets::Event::Burned { asset_id, owner, balance }) => {
					asset_id: *asset_id == ASSET_ID,
					owner: *owner == para_sovereign_account,
					balance: *balance == fee_amount,
				},
  1. Change the value of ASSET_ID to some other number, re-run the test. The test still passes
@0xmovses 0xmovses added I2-bug The node fails to follow expected behavior. I10-unconfirmed Issue might be valid, but it's not yet known. labels Nov 22, 2023
@0xmovses 0xmovses changed the title assert_expected_events! gives false positive on inner values assert_expected_events! gives false positive on Event enum inner values Nov 22, 2023
@0xmovses 0xmovses changed the title assert_expected_events! gives false positive on Event enum inner values assert_expected_events! gives false positives on inner enum values Nov 22, 2023
@joepetrowski
Copy link
Contributor

Steps to reproduce

Can you add a reproducible example on its own that's not dependent on a branch? E.g.

#[test]
fn inner_event_assertions_should_work() {
	RococoRelay::execute_with(|| {
		type RuntimeEvent = <RococoRelay as Chain>::RuntimeEvent;

		assert_ok!(/* balance transfer */);
		assert_expected_events!(
			RococoRelay,
			vec![
				RuntimeEvent::Balances(pallet_balances::Event::Transfer { from, to, amount }) => {
					/* assert things */
				},
			]
		);
	});
}

@bkontur
Copy link
Contributor

bkontur commented Nov 23, 2023

could this be related to this: #1127 ?

@0xmovses
Copy link
Contributor Author

@joepetrowski I've updated the issue with an example that can be ran on main.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
I2-bug The node fails to follow expected behavior. I10-unconfirmed Issue might be valid, but it's not yet known.
Projects
None yet
Development

No branches or pull requests

3 participants