Skip to content

Commit df673ea

Browse files
authored
fix owns_coins to properly paginate (#1449)
There was an issue with the e2e tests causing them to fail once wallet_b had more than 100 coins due to improper pagination over coins. This also updates the e2e tests targeting beta4 by using a docker image sha generated from this branch: #1448
1 parent 47c6ff4 commit df673ea

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

.github/workflows/e2e-test-beta4-dev.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ jobs:
1717
envsubst < ${{ github.workspace }}/.github/workflows/e2e_config/beta-4.toml.template > ${{ github.workspace }}/.github/workflows/e2e_config/beta-4.toml
1818
1919
- name: Run e2e tests with docker
20-
run: docker run -v ${{ github.workspace }}/.github/workflows/e2e_config:/etc/e2e_config -e FUEL_CORE_E2E_CONFIG='/etc/e2e_config/beta-4.toml' ghcr.io/fuellabs/fuel-core-e2e-client:v0.20.7 ./fuel-core-e2e-client -- alice
20+
run: docker run -v ${{ github.workspace }}/.github/workflows/e2e_config:/etc/e2e_config -e FUEL_CORE_E2E_CONFIG='/etc/e2e_config/beta-4.toml' ghcr.io/fuellabs/fuel-core-e2e-client:sha-ccba276 ./fuel-core-e2e-client -- alice

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
99
Description of the upcoming release here.
1010

1111
### Added
12-
12+
- [#1449](https://github.com/FuelLabs/fuel-core/pull/1449): fix coin pagination in e2e test client
1313
- [#1447](https://github.com/FuelLabs/fuel-core/pull/1447): Add timeout for continuous e2e tests
1414
- [#1444](https://github.com/FuelLabs/fuel-core/pull/1444): Add "sanity" benchmarks for memory opcodes.
1515
- [#1437](https://github.com/FuelLabs/fuel-core/pull/1437): Add some transaction throughput tests for basic transfers.

bin/e2e-test-client/src/test_context.rs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -107,26 +107,33 @@ impl Wallet {
107107
pub async fn owns_coin(&self, utxo_id: UtxoId) -> anyhow::Result<bool> {
108108
let mut first_page = true;
109109
let mut results = vec![];
110+
let mut cursor = None;
110111

111112
while first_page || !results.is_empty() {
112113
first_page = false;
113-
results = self
114+
let response = self
114115
.client
115116
.coins(
116117
&self.address,
117118
None,
118119
PaginationRequest {
119-
cursor: None,
120+
cursor,
120121
results: 100,
121122
direction: PageDirection::Forward,
122123
},
123124
)
124-
.await?
125-
.results;
125+
.await?;
126+
results = response.results;
126127
// check if page has the utxos we're looking for
127128
if results.iter().any(|coin| coin.utxo_id == utxo_id) {
128129
return Ok(true)
129130
}
131+
// otherwise update the cursor to check the next page
132+
if response.has_next_page {
133+
cursor = response.cursor;
134+
} else {
135+
break
136+
}
130137
}
131138

132139
Ok(false)

0 commit comments

Comments
 (0)