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

Remove retry loop from make_application. #2144

Merged
merged 1 commit into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 5 additions & 10 deletions linera-service/src/cli_wrappers/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -854,16 +854,11 @@ impl NodeService {
application_id: &ApplicationId<A>,
) -> Result<ApplicationWrapper<A>> {
let application_id = application_id.forget_abi().to_string();
let n_try = 15;
for i in 0..n_try {
tokio::time::sleep(Duration::from_secs(i)).await;
let values = self.try_get_applications_uri(chain_id).await?;
if let Some(link) = values.get(&application_id) {
return Ok(ApplicationWrapper::from(link.to_string()));
}
warn!("Waiting for application {application_id:?} to be visible on chain {chain_id:?}");
}
bail!("Could not find application URI: {application_id} after {n_try} tries");
let values = self.try_get_applications_uri(chain_id).await?;
let Some(link) = values.get(&application_id) else {
bail!("Could not find application URI: {application_id}");
};
Ok(ApplicationWrapper::from(link.to_string()))
}

pub async fn try_get_applications_uri(
Expand Down
46 changes: 38 additions & 8 deletions linera-service/tests/end_to_end_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -614,13 +614,14 @@ async fn test_wasm_end_to_end_social_user_pub_sub(config: impl LineraNetConfig)
let mut node_service1 = client1.run_node_service(8080).await?;
let mut node_service2 = client2.run_node_service(8081).await?;

node_service1.process_inbox(&chain1).await?;

// Request the application so chain 2 has it, too.
node_service2
.request_application(&chain2, &application_id)
.await?;

node_service1.process_inbox(&chain1).await?;
node_service2.process_inbox(&chain2).await?;

let app2 = node_service2
.make_application(&chain2, &application_id)
.await?;
Expand Down Expand Up @@ -768,6 +769,8 @@ async fn test_wasm_end_to_end_fungible(
app1.assert_entries(expected_balances).await;
app1.assert_keys([account_owner1, account_owner2]).await;

node_service2.process_inbox(&chain2).await?;

// Fungible didn't exist on chain2 initially but now it does and we can talk to it.
let app2 = FungibleApp(
node_service2
Expand Down Expand Up @@ -924,6 +927,8 @@ async fn test_wasm_end_to_end_same_wallet_fungible(
)
.await;

node_service.process_inbox(&chain2).await?;

// Checking the final values on chain1 and chain2.
let expected_balances = [
(account_owner1, Amount::from_tokens(4)),
Expand Down Expand Up @@ -1038,6 +1043,8 @@ async fn test_wasm_end_to_end_non_fungible(config: impl LineraNetConfig) -> Resu
)
.await;

node_service2.process_inbox(&chain2).await?;

// Checking the NFT is removed from chain1
assert!(app1.get_nft(&nft1_id).await.is_err());
assert!(!app1
Expand Down Expand Up @@ -1315,6 +1322,9 @@ async fn test_wasm_end_to_end_crowd_funding(config: impl LineraNetConfig) -> Res
.request_application(&chain2, &application_id_crowd)
.await?;

node_service1.process_inbox(&chain1).await?;
node_service2.process_inbox(&chain2).await?;

let app_crowd2 = node_service2
.make_application(&chain2, &application_id_crowd)
.await?;
Expand Down Expand Up @@ -1437,6 +1447,11 @@ async fn test_wasm_end_to_end_matching_engine(config: impl LineraNetConfig) -> R
.request_application(&chain_admin, &token1)
.await?;

node_service_a.process_inbox(&chain_a).await?;
node_service_b.process_inbox(&chain_b).await?;
node_service_a.process_inbox(&chain_a).await?;
node_service_admin.process_inbox(&chain_admin).await?;

let app_fungible0_a = FungibleApp(node_service_a.make_application(&chain_a, &token0).await?);
let app_fungible1_a = FungibleApp(node_service_a.make_application(&chain_a, &token1).await?);
let app_fungible0_b = FungibleApp(node_service_b.make_application(&chain_b, &token0).await?);
Expand Down Expand Up @@ -1508,14 +1523,19 @@ async fn test_wasm_end_to_end_matching_engine(config: impl LineraNetConfig) -> R
node_service_a
.request_application(&chain_a, &application_id_matching)
.await?;
node_service_b
.request_application(&chain_b, &application_id_matching)
.await?;

node_service_admin.process_inbox(&chain_admin).await?;
node_service_a.process_inbox(&chain_a).await?;
node_service_b.process_inbox(&chain_b).await?;

let app_matching_a = MatchingEngineApp(
node_service_a
.make_application(&chain_a, &application_id_matching)
.await?,
);
node_service_b
.request_application(&chain_b, &application_id_matching)
.await?;
let app_matching_b = MatchingEngineApp(
node_service_b
.make_application(&chain_b, &application_id_matching)
Expand Down Expand Up @@ -1775,6 +1795,9 @@ async fn test_wasm_end_to_end_amm(config: impl LineraNetConfig) -> Result<()> {
)
.await;

node_service0.process_inbox(&chain0).await?;
node_service1.process_inbox(&chain1).await?;

let app_fungible0_0 = FungibleApp(node_service0.make_application(&chain0, &token0).await?);
let app_fungible1_0 = FungibleApp(node_service0.make_application(&chain0, &token1).await?);

Expand Down Expand Up @@ -1856,14 +1879,19 @@ async fn test_wasm_end_to_end_amm(config: impl LineraNetConfig) -> Result<()> {
node_service0
.request_application(&chain0, &application_id_amm)
.await?;
node_service1
.request_application(&chain1, &application_id_amm)
.await?;

node_service_amm.process_inbox(&chain_amm).await?;
node_service0.process_inbox(&chain0).await?;
node_service1.process_inbox(&chain1).await?;

let app_amm0 = AmmApp(
node_service0
.make_application(&chain0, &application_id_amm)
.await?,
);
node_service1
.request_application(&chain1, &application_id_amm)
.await?;
let app_amm1 = AmmApp(
node_service1
.make_application(&chain1, &application_id_amm)
Expand Down Expand Up @@ -2575,6 +2603,8 @@ async fn test_open_chain_node_service(config: impl LineraNetConfig) -> Result<()
)
.await;

node_service.process_inbox(&chain2).await?;

// Send 4 tokens back.
let app2 = FungibleApp(
node_service
Expand Down
Loading