Skip to content

adds the ability to run example app tests against d14n testnet staging#774

Draft
cameronvoell wants to merge 3 commits intomainfrom
cv/03-13-adds_the_ability_to_run_example_app_tests_against_d14n_testnet_staging
Draft

adds the ability to run example app tests against d14n testnet staging#774
cameronvoell wants to merge 3 commits intomainfrom
cv/03-13-adds_the_ability_to_run_example_app_tests_against_d14n_testnet_staging

Conversation

@cameronvoell
Copy link
Contributor

@cameronvoell cameronvoell commented Mar 13, 2026

Add d14n testnet staging environment support to example app tests

  • Adds a TestEnvOption type and getTestEnv/setTestEnv utilities in testEnv.ts to track a global test environment selection (local, dev, or d14n).
  • Adds a test environment picker to LaunchScreen.tsx so users can switch environments at runtime.
  • Updates createClients in test-utils.ts to default to the globally selected environment; when d14n is selected, it routes to dev with a required GATEWAY_HOST env variable and throws if absent.
  • Adds an Expo config plugin withReactNativeConfigEnv.js that injects react-native-config's dotenv.gradle into app/build.gradle during Android prebuild, enabling .env variables (including GATEWAY_HOST) in BuildConfig.
  • Risk: createClients now throws at runtime if d14n is selected but GATEWAY_HOST is not set in the environment.
📊 Macroscope summarized dc9a8dd. 7 files reviewed, 2 issues evaluated, 0 issues filtered, 1 comment posted (Automatic summaries will resume when PR exits draft mode or review begins).

🗂️ Filtered Issues

@changeset-bot
Copy link

changeset-bot bot commented Mar 13, 2026

⚠️ No Changeset found

Latest commit: dc9a8dd

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Contributor Author

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

Comment on lines +21 to +25
const afterPlugins = contents.indexOf('apply plugin: "com.facebook.react"')
if (afterPlugins === -1) {
return config
}
const insertAt = contents.indexOf('\n', afterPlugins) + 1
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Low plugins/withReactNativeConfigEnv.js:21

If apply plugin: "com.facebook.react" is the last line without a trailing newline, indexOf('\n', afterPlugins) returns -1, so insertAt becomes 0. This prepends the comment and dotenv.gradle to the start of the file instead of after the plugin line, corrupting the gradle structure. Consider handling the -1 case to append at the end of the file when no newline is found.

-    const insertAt = contents.indexOf('\n', afterPlugins) + 1
+    const nextNewline = contents.indexOf('\n', afterPlugins)
+    const insertAt = nextNewline === -1 ? contents.length : nextNewline + 1
🚀 Reply "fix it for me" or copy this AI Prompt for your agent:
In file example/plugins/withReactNativeConfigEnv.js around lines 21-25:

If `apply plugin: "com.facebook.react"` is the last line without a trailing newline, `indexOf('\n', afterPlugins)` returns `-1`, so `insertAt` becomes `0`. This prepends the comment and `dotenv.gradle` to the start of the file instead of after the plugin line, corrupting the gradle structure. Consider handling the `-1` case to append at the end of the file when no newline is found.

Evidence trail:
example/plugins/withReactNativeConfigEnv.js lines 21-29 at REVIEWED_COMMIT. Line 25 shows `const insertAt = contents.indexOf('\n', afterPlugins) + 1` which returns 0 when indexOf returns -1 (no newline found). Lines 26-29 show the slicing logic that would prepend content to the start of the file when insertAt is 0.

@cameronvoell cameronvoell force-pushed the cv/03-13-adds_the_ability_to_run_example_app_tests_against_d14n_testnet_staging branch from b2cec4d to ce540e7 Compare March 13, 2026 22:50
@cameronvoell cameronvoell force-pushed the cv/03-11-add_new_device_sync_functions_and_tests_for_libxmtp_release_1.10.0 branch 2 times, most recently from e0d9d66 to 3d8c892 Compare March 13, 2026 23:17
@cameronvoell cameronvoell force-pushed the cv/03-11-add_new_device_sync_functions_and_tests_for_libxmtp_release_1.10.0 branch from 3d8c892 to 1725e55 Compare March 13, 2026 23:45
@cameronvoell cameronvoell force-pushed the cv/03-13-adds_the_ability_to_run_example_app_tests_against_d14n_testnet_staging branch from ce540e7 to dc9a8dd Compare March 13, 2026 23:45
Base automatically changed from cv/03-11-add_new_device_sync_functions_and_tests_for_libxmtp_release_1.10.0 to main March 14, 2026 00:17
`Expected 1 preference update, got ${types.length}`
)

alix.preferences.cancelStreamConsent()
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Medium tests/historySyncTests.ts:247

alix.preferences.cancelStreamConsent() cancels the wrong stream — the test started streamPreferenceUpdates at line 225, not streamConsent. This leaves the preference updates stream uncancelled, causing resource leaks and potential interference with subsequent tests.

Suggested change
alix.preferences.cancelStreamConsent()
alix.preferences.cancelStreamPreferenceUpdates()
🚀 Reply "fix it for me" or copy this AI Prompt for your agent:
In file example/src/tests/historySyncTests.ts around line 247:

`alix.preferences.cancelStreamConsent()` cancels the wrong stream — the test started `streamPreferenceUpdates` at line 225, not `streamConsent`. This leaves the preference updates stream uncancelled, causing resource leaks and potential interference with subsequent tests.

Evidence trail:
example/src/tests/historySyncTests.ts lines 220-250 (REVIEWED_COMMIT): Line 225 calls `await alix.preferences.streamPreferenceUpdates(...)`, Line 247 calls `alix.preferences.cancelStreamConsent()`

src/lib/PrivatePreferences.ts lines 145-180 (REVIEWED_COMMIT): Shows `cancelStreamConsent()` at line 154 cancels consent-related subscriptions (EventTypes.Consent) and `cancelStreamPreferenceUpdates()` at line 169 cancels preference update subscriptions (EventTypes.PreferenceUpdates) - these are separate methods for separate streams

// Create a default metadata object when null
mapOf(
"archiveVersion" to 0u,
"elements" to listOf("messages", "consent"),
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Medium wrappers/ArchiveMetadataWrapper.kt:42

encodeToMap returns "messages" (plural) for the null-metadata default, but getArchiveElementString returns "message" (singular) for ArchiveElement.MESSAGES and the catch block fallback also uses "message". Downstream consumers expecting consistent element names receive "messages" when metadata is null but "message" when encoding succeeds or fails.

🚀 Reply "fix it for me" or copy this AI Prompt for your agent:
In file android/src/main/java/expo/modules/xmtpreactnativesdk/wrappers/ArchiveMetadataWrapper.kt around line 42:

`encodeToMap` returns `"messages"` (plural) for the null-metadata default, but `getArchiveElementString` returns `"message"` (singular) for `ArchiveElement.MESSAGES` and the catch block fallback also uses `"message"`. Downstream consumers expecting consistent element names receive `"messages"` when metadata is null but `"message"` when encoding succeeds or fails.

Evidence trail:
android/src/main/java/expo/modules/xmtpreactnativesdk/wrappers/ArchiveMetadataWrapper.kt at REVIEWED_COMMIT:
- Line 42: `"elements" to listOf("messages", "consent")` (plural "messages")
- Line 28: `ArchiveElement.MESSAGES -> "message"` (singular "message")
- Lines 18-20: catch block returns `listOf("message", "consent")` (singular "message")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant