Skip to content
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

1.1.0 #64

Merged
merged 18 commits into from
Dec 6, 2024
6 changes: 5 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,11 @@ jobs:
- name: Run Relay integration tests
if: matrix.type == 'relay-tests'
shell: bash
run: make relay_tests RELAY_HOST=relay.walletconnect.com PROJECT_ID=${{ secrets.PROJECT_ID }}
run: make relay_tests \
RELAY_HOST=relay.walletconnect.com \
PROJECT_ID=${{ secrets.PROJECT_ID }} \
BUNDLE_ID_PRESENT_PROJECT_ID=${{ secrets.BUNDLE_ID_PRESENT_PROJECT_ID }} \
BUNDLE_ID_NOT_PRESENT_PROJECT_ID=${{ secrets.BUNDLE_ID_NOT_PRESENT_PROJECT_ID }}

- name: Publish Test Report
uses: mikepenz/action-junit-report@v3
Expand Down
4 changes: 4 additions & 0 deletions Configuration.xcconfig
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,9 @@ EXPLORER_HOST = explorer-api.walletconnect.com
// pimloco bundler url including api key
// PIMLICO_BUNDLER_URL = PIMLICO_BUNDLER_URL

// BUNDLE_ID_PRESENT_PROJECT_ID = BUNDLE_ID_PRESENT_PROJECT_ID

// BUNDLE_ID_NOT_PRESENT_PROJECT_ID = BUNDLE_ID_NOT_PRESENT_PROJECT_ID

// rpc url
// RPC_URL = RPC_URL
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
"repositoryURL": "https://github.com/attaswift/BigInt.git",
"state": {
"branch": null,
"revision": "793a7fac0bfc318e85994bf6900652e827aef33e",
"version": "5.4.1"
"revision": "114343a705df4725dfe7ab8a2a326b8883cfd79c",
"version": "5.5.1"
}
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,10 @@
</BuildActionEntry>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
buildForRunning = "NO"
buildForProfiling = "NO"
buildForArchiving = "NO"
buildForAnalyzing = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "8445118E2C8B689D00A6A86C"
Expand Down Expand Up @@ -119,15 +119,6 @@
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "8445118E2C8B689D00A6A86C"
BuildableName = "AppKitLab.app"
BlueprintName = "AppKitLab"
ReferencedContainer = "container:ExampleApp.xcodeproj">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,16 @@
value = "$(PROJECT_ID)"
isEnabled = "YES">
</EnvironmentVariable>
<EnvironmentVariable
key = "BUNDLE_ID_NOT_PRESENT_PROJECT_ID"
value = "$(BUNDLE_ID_NOT_PRESENT_PROJECT_ID)"
isEnabled = "YES">
</EnvironmentVariable>
<EnvironmentVariable
key = "BUNDLE_ID_PRESENT_PROJECT_ID"
value = "$(BUNDLE_ID_PRESENT_PROJECT_ID)"
isEnabled = "YES">
</EnvironmentVariable>
</EnvironmentVariables>
<Testables>
<TestableReference
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,6 @@
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "Web3Inbox"
BuildableName = "Web3Inbox"
BlueprintName = "Web3Inbox"
ReferencedContainer = "container:..">
</BuildableReference>
</BuildActionEntry>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
Expand Down Expand Up @@ -62,62 +48,6 @@
ReferencedContainer = "container:..">
</BuildableReference>
</BuildActionEntry>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "WalletConnectAuth"
BuildableName = "WalletConnectAuth"
BlueprintName = "WalletConnectAuth"
ReferencedContainer = "container:..">
</BuildableReference>
</BuildActionEntry>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "Web3Wallet"
BuildableName = "Web3Wallet"
BlueprintName = "Web3Wallet"
ReferencedContainer = "container:..">
</BuildableReference>
</BuildActionEntry>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "WalletConnectRouter"
BuildableName = "WalletConnectRouter"
BlueprintName = "WalletConnectRouter"
ReferencedContainer = "container:..">
</BuildableReference>
</BuildActionEntry>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "WalletConnectEcho"
BuildableName = "WalletConnectEcho"
BlueprintName = "WalletConnectEcho"
ReferencedContainer = "container:..">
</BuildableReference>
</BuildActionEntry>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
Expand All @@ -132,34 +62,6 @@
ReferencedContainer = "container:..">
</BuildableReference>
</BuildActionEntry>
<BuildActionEntry
buildForTesting = "NO"
buildForRunning = "NO"
buildForProfiling = "NO"
buildForArchiving = "NO"
buildForAnalyzing = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "WalletConnectChat"
BuildableName = "WalletConnectChat"
BlueprintName = "WalletConnectChat"
ReferencedContainer = "container:..">
</BuildableReference>
</BuildActionEntry>
<BuildActionEntry
buildForTesting = "NO"
buildForRunning = "NO"
buildForProfiling = "NO"
buildForArchiving = "NO"
buildForAnalyzing = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "ChatTests"
BuildableName = "ChatTests"
BlueprintName = "ChatTests"
ReferencedContainer = "container:..">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
Expand Down Expand Up @@ -268,16 +170,6 @@
ReferencedContainer = "container:..">
</BuildableReference>
</TestableReference>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "ReownAppKitTests"
BuildableName = "ReownAppKitTests"
BlueprintName = "ReownAppKitTests"
ReferencedContainer = "container:..">
</BuildableReference>
</TestableReference>
</Testables>
</TestAction>
<LaunchAction
Expand All @@ -300,9 +192,9 @@
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "Web3Inbox"
BuildableName = "Web3Inbox"
BlueprintName = "Web3Inbox"
BlueprintIdentifier = "WalletConnectPush"
BuildableName = "WalletConnectPush"
BlueprintName = "WalletConnectPush"
ReferencedContainer = "container:..">
</BuildableReference>
</MacroExpansion>
Expand Down
27 changes: 26 additions & 1 deletion Example/RelayIntegrationTests.xctestplan
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,38 @@
"id" : "3D7BF967-0C62-49DD-ABA1-BDDEE678ED85",
"name" : "Configuration 1",
"options" : {

"environmentVariableEntries" : [
{
"key" : "RELAY_HOST",
"value" : "$(RELAY_HOST)"
},
{
"key" : "PROJECT_ID",
"value" : "$(PROJECT_ID)"
},
{
"key" : "BUNDLE_ID_NOT_PRESENT_PROJECT_ID",
"value" : "$(BUNDLE_ID_NOT_PRESENT_PROJECT_ID)"
},
{
"key" : "BUNDLE_ID_PRESENT_PROJECT_ID",
"value" : "$(BUNDLE_ID_PRESENT_PROJECT_ID)"
}
]
}
}
],
"defaultOptions" : {
"codeCoverage" : false,
"environmentVariableEntries" : [
{
"key" : "BUNDLE_ID_NOT_PRESENT_PROJECT_ID",
"value" : "$(BUNDLE_ID_NOT_PRESENT_PROJECT_ID)"
},
{
"key" : "BUNDLE_ID_PRESENT_PROJECT_ID",
"value" : "$(BUNDLE_ID_PRESENT_PROJECT_ID)"
},
{
"key" : "RELAY_HOST",
"value" : "$(RELAY_HOST)"
Expand Down
86 changes: 25 additions & 61 deletions Example/RelayIntegrationTests/RelayClientEndToEndTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -32,24 +32,11 @@ final class RelayClientEndToEndTests: XCTestCase {
private var relayA: RelayClient!
private var relayB: RelayClient!

func makeRelayClient(prefix: String) -> RelayClient {
func makeRelayClient(prefix: String, projectId: String = InputConfig.projectId) -> RelayClient {
let keyValueStorage = RuntimeKeyValueStorage()
let logger = ConsoleLogger(prefix: prefix, loggingLevel: .debug)
let clientIdStorage = ClientIdStorage(defaults: keyValueStorage, keychain: KeychainStorageMock(), logger: logger)
let socketAuthenticator = ClientIdAuthenticator(
clientIdStorage: clientIdStorage,
logger: ConsoleLoggerMock()
)
let urlFactory = RelayUrlFactory(
relayHost: InputConfig.relayHost,
projectId: InputConfig.projectId
)
let socket = WebSocket(url: urlFactory.create())
let webSocketFactory = WebSocketFactoryMock(webSocket: socket)
let networkMonitor = NetworkMonitor()

let socketStatusProvider = SocketStatusProvider(socket: socket, logger: logger)
let socketConnectionHandler = AutomaticSocketConnectionHandler(socket: socket, subscriptionsTracker: SubscriptionsTracker(logger: logger), logger: logger, socketStatusProvider: socketStatusProvider, clientIdAuthenticator: socketAuthenticator)

let keychain = KeychainStorageMock()
let relayClient = RelayClientFactory.create(
Expand All @@ -58,7 +45,7 @@ final class RelayClientEndToEndTests: XCTestCase {
keyValueStorage: keyValueStorage,
keychainStorage: keychain,
socketFactory: DefaultSocketFactory(),
socketConnectionType: .manual,
socketConnectionType: .automatic,
networkMonitor: networkMonitor,
logger: logger
)
Expand All @@ -74,38 +61,27 @@ final class RelayClientEndToEndTests: XCTestCase {
super.tearDown()
}

// func testSubscribe() {
// relayA = makeRelayClient(prefix: "")
//
// do {
// try relayA.connect()
// } catch {
// XCTFail("Failed to connect: \(error)")
// }
//
// let subscribeExpectation = expectation(description: "subscribe call succeeds")
// subscribeExpectation.assertForOverFulfill = true
// relayA.socketConnectionStatusPublisher.sink { [weak self] status in
// guard let self = self else {return}
// if status == .connected {
// Task(priority: .high) { try await self.relayA.subscribe(topic: "ecb78f2df880c43d3418ddbf871092b847801932e21765b250cc50b9e96a9131") }
// subscribeExpectation.fulfill()
// }
// }.store(in: &publishers)
//
// wait(for: [subscribeExpectation], timeout: InputConfig.defaultTimeout)
// }

func testEndToEndPayload() {
// test_bundleId_present - configured in the cloud to include bundleId for whitelisted apps
func testConnectProjectBundleIdPresent() async throws {
let randomTopic = String.randomTopic()
relayA = makeRelayClient(prefix: "⚽️ X ", projectId: InputConfig.bundleIdPresentProjectId)
try await self.relayA.publish(topic: randomTopic, payload: "", tag: 0, prompt: false, ttl: 60)
sleep(1)
}

// test_bundleId_not_present - configured in the cloud to not include bundleId for whitelisted apps
func testConnectProjectBundleIdNotPresent() async throws{
let randomTopic = String.randomTopic()
relayA = makeRelayClient(prefix: "⚽️ X ", projectId: InputConfig.bundleIdNotPresentProjectId)

try await self.relayA.publish(topic: randomTopic, payload: "", tag: 0, prompt: false, ttl: 60)
sleep(1)
}

func testEndToEndPayload() async throws {
relayA = makeRelayClient(prefix: "⚽️ A ")
relayB = makeRelayClient(prefix: "🏀 B ")

do {
try relayA.connect()
try relayB.connect()
} catch {
XCTFail("Failed to connect: \(error)")
}
let randomTopic = String.randomTopic()
let payloadA = "A"
let payloadB = "B"
Expand All @@ -120,8 +96,7 @@ final class RelayClientEndToEndTests: XCTestCase {
expectationA.assertForOverFulfill = false
expectationB.assertForOverFulfill = false

relayA.messagePublisher.sink { [weak self] topic, payload, _, _ in
guard let self = self else { return }
relayA.messagePublisher.sink { topic, payload, _, _ in
(subscriptionATopic, subscriptionAPayload) = (topic, payload)
expectationA.fulfill()
}.store(in: &publishers)
Expand All @@ -136,22 +111,11 @@ final class RelayClientEndToEndTests: XCTestCase {
expectationB.fulfill()
}.store(in: &publishers)

relayA.socketConnectionStatusPublisher.sink { [weak self] status in
guard let self = self else { return }
guard status == .connected else { return }
Task(priority: .high) {
try await self.relayA.subscribe(topic: randomTopic)
try await self.relayA.publish(topic: randomTopic, payload: payloadA, tag: 0, prompt: false, ttl: 60)
}
}.store(in: &publishers)
try await self.relayA.subscribe(topic: randomTopic)
try await self.relayA.publish(topic: randomTopic, payload: payloadA, tag: 0, prompt: false, ttl: 60)

try await self.relayB.subscribe(topic: randomTopic)

relayB.socketConnectionStatusPublisher.sink { [weak self] status in
guard let self = self else { return }
guard status == .connected else { return }
Task(priority: .high) {
try await self.relayB.subscribe(topic: randomTopic)
}
}.store(in: &publishers)

wait(for: [expectationA, expectationB], timeout: InputConfig.defaultTimeout)

Expand Down
Loading
Loading