mirror of
https://github.com/logos-blockchain/lez-programs.git
synced 2026-07-21 22:40:00 +00:00
fix(amm): complete repeated context refreshes
This commit is contained in:
parent
1d1db9ba4e
commit
a66ffddfe4
@ -165,8 +165,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 })
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user