From f219749a7268b175c8f4861c8a5a1a259564205e Mon Sep 17 00:00:00 2001 From: Cameron Voell <1103838+cameronvoell@users.noreply.github.com> Date: Tue, 11 Jun 2024 07:33:15 -0700 Subject: [PATCH] Update libxmtp - Fix pending commit clearing after invalid permissions (#347) * added test for catching pending commit error * Updated to latests libxmtp binary, updated tests --------- Co-authored-by: cameronvoell --- Package.resolved | 4 +-- Package.swift | 2 +- Tests/XMTPTests/GroupPermissionsTests.swift | 33 ++++++++++++++++++--- Tests/XMTPTests/GroupTests.swift | 4 +-- XMTP.podspec | 4 +-- 5 files changed, 36 insertions(+), 11 deletions(-) diff --git a/Package.resolved b/Package.resolved index c0bb9cb6..ada20c98 100644 --- a/Package.resolved +++ b/Package.resolved @@ -41,8 +41,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/xmtp/libxmtp-swift", "state" : { - "revision" : "bfee6cde5cadf0e1842b77daf80e6e4a88830194", - "version" : "0.5.0-beta1" + "revision" : "c5e9ed9d3ee9de55beec4d7a8f76861c9d43230d", + "version" : "0.5.1-beta1" } }, { diff --git a/Package.swift b/Package.swift index 567f7ac6..d2492281 100644 --- a/Package.swift +++ b/Package.swift @@ -25,7 +25,7 @@ let package = Package( .package(url: "https://github.com/1024jp/GzipSwift", from: "5.2.0"), .package(url: "https://github.com/bufbuild/connect-swift", exact: "0.12.0"), .package(url: "https://github.com/apple/swift-docc-plugin.git", from: "1.0.0"), - .package(url: "https://github.com/xmtp/libxmtp-swift", exact: "0.5.1-beta0"), + .package(url: "https://github.com/xmtp/libxmtp-swift", exact: "0.5.1-beta1"), ], targets: [ // Targets are the basic building blocks of a package. A target can define a module or a test suite. diff --git a/Tests/XMTPTests/GroupPermissionsTests.swift b/Tests/XMTPTests/GroupPermissionsTests.swift index d0dcd467..02d893bc 100644 --- a/Tests/XMTPTests/GroupPermissionsTests.swift +++ b/Tests/XMTPTests/GroupPermissionsTests.swift @@ -107,15 +107,15 @@ class GroupPermissionTests: XCTestCase { XCTAssertTrue(superAdminList.contains(fixtures.bobClient.inboxID)) // Verify that alice can NOT update group name - XCTAssertEqual(try bobGroup.groupName(), "New Group") + XCTAssertEqual(try bobGroup.groupName(), "") await assertThrowsAsyncError( try await aliceGroup.updateGroupName(groupName: "Alice group name") ) try await aliceGroup.sync() try await bobGroup.sync() - XCTAssertEqual(try bobGroup.groupName(), "New Group") - XCTAssertEqual(try aliceGroup.groupName(), "New Group") + XCTAssertEqual(try bobGroup.groupName(), "") + XCTAssertEqual(try aliceGroup.groupName(), "") try await bobGroup.addAdmin(inboxId: fixtures.aliceClient.inboxID) try await bobGroup.sync() @@ -228,5 +228,30 @@ class GroupPermissionTests: XCTestCase { XCTAssertEqual(superAdmins.count, 2) XCTAssertTrue(regularMembers.isEmpty) } - + + func testCanCommitAfterInvalidPermissionsCommit() async throws { + let fixtures = try await localFixtures() + let bobGroup = try await fixtures.bobClient.conversations.newGroup(with: [fixtures.alice.walletAddress, fixtures.caro.walletAddress], permissions: .allMembers) + try await fixtures.aliceClient.conversations.sync() + let aliceGroup = try await fixtures.aliceClient.conversations.groups().first! + + // Verify that alice can NOT add an admin + XCTAssertEqual(try bobGroup.groupName(), "") + await assertThrowsAsyncError( + try await aliceGroup.addAdmin(inboxId: fixtures.aliceClient.inboxID) + ) + + try await aliceGroup.sync() + try await bobGroup.sync() + + // Verify that alice can update group name + try await bobGroup.sync() + try await aliceGroup.sync() + try await aliceGroup.updateGroupName(groupName: "Alice group name") + try await aliceGroup.sync() + try await bobGroup.sync() + + XCTAssertEqual(try bobGroup.groupName(), "Alice group name") + XCTAssertEqual(try aliceGroup.groupName(), "Alice group name") + } } diff --git a/Tests/XMTPTests/GroupTests.swift b/Tests/XMTPTests/GroupTests.swift index 9e54f599..52d23d48 100644 --- a/Tests/XMTPTests/GroupTests.swift +++ b/Tests/XMTPTests/GroupTests.swift @@ -645,7 +645,7 @@ class GroupTests: XCTestCase { var groupName = try group.groupName() - XCTAssertEqual(groupName, "New Group") + XCTAssertEqual(groupName, "") try await group.updateGroupName(groupName: "Test Group Name 1") @@ -666,7 +666,7 @@ class GroupTests: XCTestCase { bobGroup = group } groupName = try bobGroup.groupName() - XCTAssertEqual(groupName, "New Group") + XCTAssertEqual(groupName, "") try await bobGroup.sync() groupName = try bobGroup.groupName() diff --git a/XMTP.podspec b/XMTP.podspec index 6b8ed6cc..b6918162 100644 --- a/XMTP.podspec +++ b/XMTP.podspec @@ -16,7 +16,7 @@ Pod::Spec.new do |spec| # spec.name = "XMTP" - spec.version = "0.11.4" + spec.version = "0.11.5" spec.summary = "XMTP SDK Cocoapod" # This description is used to generate tags and improve search results. @@ -44,5 +44,5 @@ Pod::Spec.new do |spec| spec.dependency "web3.swift" spec.dependency "GzipSwift" spec.dependency "Connect-Swift", "= 0.12.0" - spec.dependency 'LibXMTP', '= 0.5.1-beta0' + spec.dependency 'LibXMTP', '= 0.5.1-beta1' end