Skip to content

Commit 882fbbd

Browse files
committed
Fixes conversion queries for integration tests
1 parent 70bc3df commit 882fbbd

File tree

2 files changed

+27
-5
lines changed

2 files changed

+27
-5
lines changed

crates/apps_lib/src/client/masp.rs

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,14 +117,37 @@ pub async fn syncing<
117117

118118
#[cfg(feature = "testing")]
119119
{
120+
use std::collections::BTreeMap;
121+
122+
use futures::StreamExt;
123+
use namada_core::masp::MaspEpoch;
124+
120125
// Load the confirmed context (if present) and update the conversions
121126
// for the shielded history. This is needed for integration
122127
// tests only as the cli wallet is not supposed to compile the
123128
// history of shielded transactions
124129
shielded.load_confirmed().await;
125-
let masp_epoch = namada_sdk::rpc::query_masp_epoch(&client).await?;
126-
for (asset_type, (token, denom, position, epoch, _conv)) in
127-
namada_sdk::rpc::query_conversions(&client, &masp_epoch).await?
130+
let current_masp_epoch =
131+
namada_sdk::rpc::query_masp_epoch(&client).await?;
132+
let epochs: Vec<_> = MaspEpoch::iter_bounds_inclusive(
133+
MaspEpoch::zero(),
134+
current_masp_epoch,
135+
)
136+
.collect();
137+
let conversion_tasks = epochs
138+
.iter()
139+
.map(|epoch| namada_sdk::rpc::query_conversions(&client, epoch));
140+
let conversions = futures::stream::iter(conversion_tasks)
141+
.buffer_unordered(100)
142+
.fold(BTreeMap::default(), async |mut acc, conversion| {
143+
acc.append(
144+
&mut conversion.expect("Conversion should be defined"),
145+
);
146+
acc
147+
})
148+
.await;
149+
150+
for (asset_type, (token, denom, position, epoch, _conv)) in conversions
128151
{
129152
let pre_asset_type = AssetData {
130153
token,

crates/apps_lib/src/client/rpc.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2154,8 +2154,7 @@ pub async fn query_conversions(
21542154
let conversion_tasks = epochs
21552155
.iter()
21562156
.map(|epoch| rpc::query_conversions(context.client(), epoch));
2157-
let task_stream = futures::stream::iter(conversion_tasks);
2158-
let conversions = task_stream
2157+
let conversions = futures::stream::iter(conversion_tasks)
21592158
.buffer_unordered(100)
21602159
.fold(BTreeMap::default(), async |mut acc, conversion| {
21612160
acc.append(&mut conversion.expect("Conversion should be defined"));

0 commit comments

Comments
 (0)