Skip to content

Commit

Permalink
Update libxmtp - Fix pending commit clearing after invalid permissions (
Browse files Browse the repository at this point in the history
#347)

* added test for catching pending commit error

* Updated to latests libxmtp binary, updated tests

---------

Co-authored-by: cameronvoell <cameronvoell@users.noreply.github.com>
  • Loading branch information
cameronvoell and cameronvoell authored Jun 11, 2024
1 parent 1280ab8 commit f219749
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 11 deletions.
4 changes: 2 additions & 2 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
},
{
Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
33 changes: 29 additions & 4 deletions Tests/XMTPTests/GroupPermissionsTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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")
}
}
4 changes: 2 additions & 2 deletions Tests/XMTPTests/GroupTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand All @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions XMTP.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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

0 comments on commit f219749

Please sign in to comment.