mirror of
https://github.com/logos-blockchain/lez-programs.git
synced 2026-07-22 14:59:38 +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(
|
m_newPosition->contextAsync(
|
||||||
request, m_network.snapshot(), isWalletOpen(), refreshWalletAccounts,
|
request, m_network.snapshot(), isWalletOpen(), refreshWalletAccounts,
|
||||||
[this, generation](QVariantMap result) {
|
[this, generation](QVariantMap result) {
|
||||||
if (generation == m_contextGeneration)
|
if (generation == m_contextGeneration) {
|
||||||
|
result.insert(QStringLiteral("requestId"), generation);
|
||||||
setNewPositionContext(std::move(result));
|
setNewPositionContext(std::move(result));
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -35,6 +35,7 @@ TestCase {
|
|||||||
"feeTiers": []
|
"feeTiers": []
|
||||||
})
|
})
|
||||||
property int contextRefreshCalls: 0
|
property int contextRefreshCalls: 0
|
||||||
|
property int contextRequestId: 0
|
||||||
property int submitCalls: 0
|
property int submitCalls: 0
|
||||||
property var lastContextRefreshRequest: ({})
|
property var lastContextRefreshRequest: ({})
|
||||||
|
|
||||||
@ -54,6 +55,9 @@ TestCase {
|
|||||||
function refreshNewPositionContext(request) {
|
function refreshNewPositionContext(request) {
|
||||||
++contextRefreshCalls
|
++contextRefreshCalls
|
||||||
lastContextRefreshRequest = request
|
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)
|
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() {
|
function test_submitFailureKeepsReturnedFreshQuoteWithoutRequery() {
|
||||||
var backend = createTemporaryObject(backendComponent, testCase)
|
var backend = createTemporaryObject(backendComponent, testCase)
|
||||||
var page = createTemporaryObject(pageComponent, testCase, { "backend": backend })
|
var page = createTemporaryObject(pageComponent, testCase, { "backend": backend })
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user