mirror of
https://github.com/logos-blockchain/lez-programs.git
synced 2026-08-25 06:01:11 +00:00
fix(amm): complete repeated context refreshes
This commit is contained in:
@@ -253,8 +253,10 @@ void AmmUiBackend::refreshNewPositionContext(QVariantMap request)
|
||||
m_newPosition->contextAsync(
|
||||
request, m_network.snapshot(), isWalletOpen(), refreshWalletAccounts,
|
||||
[this, generation](QVariantMap result) {
|
||||
if (generation == m_contextGeneration)
|
||||
if (generation == m_contextGeneration) {
|
||||
result.insert(QStringLiteral("requestId"), generation);
|
||||
setNewPositionContext(std::move(result));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -35,6 +35,7 @@ TestCase {
|
||||
"feeTiers": []
|
||||
})
|
||||
property int contextRefreshCalls: 0
|
||||
property int contextRequestId: 0
|
||||
property int submitCalls: 0
|
||||
property var lastContextRefreshRequest: ({})
|
||||
|
||||
@@ -54,6 +55,9 @@ TestCase {
|
||||
function refreshNewPositionContext(request) {
|
||||
++contextRefreshCalls
|
||||
lastContextRefreshRequest = request
|
||||
var result = JSON.parse(JSON.stringify(newPositionContext))
|
||||
result.requestId = ++contextRequestId
|
||||
newPositionContext = result
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -112,6 +116,21 @@ TestCase {
|
||||
compare(page.flow.contextHints(true).refreshWalletAccounts, true)
|
||||
}
|
||||
|
||||
function test_repeatedIdenticalContextCompletesRefresh() {
|
||||
var backend = createTemporaryObject(backendComponent, testCase)
|
||||
var page = createTemporaryObject(pageComponent, testCase, { "backend": backend })
|
||||
verify(page)
|
||||
|
||||
page.flow.refreshContext(false)
|
||||
tryCompare(page.flow, "contextLoading", false)
|
||||
compare(backend.contextRequestId, 1)
|
||||
|
||||
page.flow.refreshContext(false)
|
||||
tryCompare(page.flow, "contextLoading", false)
|
||||
compare(backend.contextRequestId, 2)
|
||||
compare(page.flow.newPositionContext.status, "ready")
|
||||
}
|
||||
|
||||
function test_submitFailureKeepsReturnedFreshQuoteWithoutRequery() {
|
||||
var backend = createTemporaryObject(backendComponent, testCase)
|
||||
var page = createTemporaryObject(pageComponent, testCase, { "backend": backend })
|
||||
|
||||
Reference in New Issue
Block a user