From 52fff84f831634fd2cbd4d5825651a6d3a139e56 Mon Sep 17 00:00:00 2001 From: haiyizxx Date: Wed, 11 Sep 2024 10:57:46 -0400 Subject: [PATCH] fix(interchain-token-service): non deterministic test (#620) --- interchain-token-service/tests/instantiate.rs | 12 +++++++++++- .../testdata/instantiate_with_args_succeeds.golden | 8 ++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/interchain-token-service/tests/instantiate.rs b/interchain-token-service/tests/instantiate.rs index de04b96aa..a29bd37ee 100644 --- a/interchain-token-service/tests/instantiate.rs +++ b/interchain-token-service/tests/instantiate.rs @@ -29,7 +29,7 @@ fn instantiate_with_args_succeeds() { .into_iter() .collect::>(); - let response = assert_ok!(contract::instantiate( + let mut response = assert_ok!(contract::instantiate( deps.as_mut(), mock_env(), mock_info("sender", &[]), @@ -40,6 +40,16 @@ fn instantiate_with_args_succeeds() { its_contracts: its_contracts.clone(), }, )); + + response.events.sort_by_key(|event| { + event + .attributes + .iter() + .find(|attr| attr.key == "chain") + .map(|attr| attr.value.clone()) + .unwrap_or_default() + }); + assert_eq!(0, response.messages.len()); goldie::assert_json!(response); diff --git a/interchain-token-service/tests/testdata/instantiate_with_args_succeeds.golden b/interchain-token-service/tests/testdata/instantiate_with_args_succeeds.golden index bd7a2a6f1..50b1e2056 100644 --- a/interchain-token-service/tests/testdata/instantiate_with_args_succeeds.golden +++ b/interchain-token-service/tests/testdata/instantiate_with_args_succeeds.golden @@ -7,11 +7,11 @@ "attributes": [ { "key": "chain", - "value": "optimism" + "value": "ethereum" }, { "key": "address", - "value": "op-address" + "value": "eth-address" } ] }, @@ -20,11 +20,11 @@ "attributes": [ { "key": "chain", - "value": "ethereum" + "value": "optimism" }, { "key": "address", - "value": "eth-address" + "value": "op-address" } ] }