-
Notifications
You must be signed in to change notification settings - Fork 5
fix: prevent false on-chain send success #1384
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
ovitrif
wants to merge
13
commits into
master
Choose a base branch
from
codex/1211-explicit-broadcast-outcome
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+3,096
−420
Draft
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
83eb899
test: restore mnemonic test compilation
ovitrif eaccc22
fix: prevent false on-chain send success
ovitrif e96f046
Merge remote-tracking branch 'origin/master' into codex/1211-explicit…
ovitrif 00a2e52
fix: use verified broadcast outcome bindings
ovitrif b7740c7
test: make accepted send checks reproducible
ovitrif 5bafcf2
chore: link release notes to the pull request
ovitrif 904264c
docs: clarify on-chain max confirmation
ovitrif 6966111
fix: preserve original on-chain follow-up context
ovitrif ae0be37
fix: require observed hardware shop payments
ovitrif 9de645a
fix: protect unresolved hardware shop payments
ovitrif 0ef4613
fix: finish accepted funding and show unresolved transactions
ovitrif 6c75463
fix: preserve paid funding after local follow-up failure
ovitrif 62c32cc
fix: preserve payment authorization when syncing master
ovitrif File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
103 changes: 103 additions & 0 deletions
103
app/src/androidTest/java/to/bitkit/ui/screens/wallets/send/SendPendingScreenTest.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,103 @@ | ||
| package to.bitkit.ui.screens.wallets.send | ||
|
|
||
| import android.graphics.Bitmap | ||
| import androidx.compose.runtime.CompositionLocalProvider | ||
| import androidx.compose.runtime.getValue | ||
| import androidx.compose.runtime.mutableStateOf | ||
| import androidx.compose.runtime.setValue | ||
| import androidx.compose.ui.platform.LocalInspectionMode | ||
| import androidx.compose.ui.test.assertIsDisplayed | ||
| import androidx.compose.ui.test.assertIsNotEnabled | ||
| import androidx.compose.ui.test.junit4.v2.createComposeRule | ||
| import androidx.compose.ui.test.onNodeWithText | ||
| import androidx.compose.ui.test.performClick | ||
| import androidx.test.platform.app.InstrumentationRegistry | ||
| import org.junit.Rule | ||
| import org.junit.Test | ||
| import to.bitkit.test.annotations.ComposeUi | ||
| import to.bitkit.ui.theme.AppThemeSurface | ||
| import java.io.File | ||
| import kotlin.test.assertEquals | ||
|
|
||
| @ComposeUi | ||
| class SendPendingScreenTest { | ||
| companion object { | ||
| private const val SCREENSHOT_FRAME_WAIT_MS = 500L | ||
| } | ||
|
|
||
| @get:Rule | ||
| val composeTestRule = createComposeRule() | ||
|
|
||
| @Test | ||
| fun unresolvedOnchainContentStaysPendingWhenVisibilityIsToggled() { | ||
| // Component rendering only; this fixture does not reload the durable attempt or attempt another send. | ||
| var visible by mutableStateOf(true) | ||
| var closeCount = 0 | ||
| composeTestRule.setContent { | ||
| AppThemeSurface { | ||
| CompositionLocalProvider(LocalInspectionMode provides true) { | ||
| if (visible) { | ||
| SendPendingContent( | ||
| amount = 1_000L, | ||
| isOnchain = true, | ||
| activityId = null, | ||
| txid = "ab".repeat(32), | ||
| refusalReason = "Test backend refusal", | ||
| onClose = { closeCount++; visible = false }, | ||
| onViewDetails = { error("Unresolved send has no activity") }, | ||
| ) | ||
| } | ||
| } | ||
| } | ||
| } | ||
| assertUnresolved() | ||
| saveScreenshot("ln112-babysit-pending-refused-component.png") | ||
| composeTestRule.onNodeWithText("Close").performClick() | ||
| composeTestRule.runOnIdle { assertEquals(1, closeCount); visible = true } | ||
| assertUnresolved() | ||
| saveScreenshot("ln112-babysit-pending-refused-visible-component.png") | ||
| } | ||
|
|
||
| @Test | ||
| fun exactCandidateWithLocalActivityOffersDetailsWithoutClaimingAcceptance() { | ||
| var detailsId: String? = null | ||
| val txid = "cd".repeat(32) | ||
| composeTestRule.setContent { | ||
| AppThemeSurface { | ||
| CompositionLocalProvider(LocalInspectionMode provides true) { | ||
| SendPendingContent(amount = 1_000L, isOnchain = true, activityId = "queued-local-activity", | ||
| txid = txid, onClose = {}, onViewDetails = { detailsId = it }) | ||
| } | ||
| } | ||
| } | ||
| composeTestRule.onNodeWithText(txid, substring = true).assertIsDisplayed() | ||
| composeTestRule.onNodeWithText("Payment Pending").assertIsDisplayed() | ||
| composeTestRule.onNodeWithText("Payment Sent").assertDoesNotExist() | ||
| saveScreenshot("ln112-babysit-pending-details-component.png") | ||
| composeTestRule.onNodeWithText("Details").performClick() | ||
| composeTestRule.runOnIdle { assertEquals("queued-local-activity", detailsId) } | ||
| } | ||
|
|
||
| private fun assertUnresolved() { | ||
| composeTestRule.onNodeWithText("Test backend refusal", substring = true).assertIsDisplayed() | ||
| composeTestRule.onNodeWithText("ab".repeat(32), substring = true).assertIsDisplayed() | ||
| composeTestRule.onNodeWithText("Payment Pending").assertIsDisplayed() | ||
| composeTestRule.onNodeWithText("Bitkit will block another send", substring = true).assertIsDisplayed() | ||
| composeTestRule.onNodeWithText("Details").assertIsNotEnabled() | ||
| composeTestRule.onNodeWithText("Retry").assertDoesNotExist() | ||
| composeTestRule.onNodeWithText("Payment Sent").assertDoesNotExist() | ||
| } | ||
|
|
||
| private fun saveScreenshot(name: String) { | ||
| val instrumentation = InstrumentationRegistry.getInstrumentation() | ||
| composeTestRule.waitForIdle() | ||
| instrumentation.waitForIdleSync() | ||
| // Semantics may be committed before the emulator compositor presents that frame. | ||
| android.os.SystemClock.sleep(SCREENSHOT_FRAME_WAIT_MS) | ||
| val image = requireNotNull(instrumentation.uiAutomation.takeScreenshot()) | ||
| File(instrumentation.targetContext.getExternalFilesDir(null), name).outputStream().use { | ||
| check(image.compress(Bitmap.CompressFormat.PNG, 100, it)) | ||
| } | ||
| image.recycle() | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.