Skip to content

Commit

Permalink
write a test for it
Browse files Browse the repository at this point in the history
  • Loading branch information
nplasterer committed Nov 1, 2023
1 parent 0fe9b32 commit 8c13c4c
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions Tests/XMTPTests/ConversationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -641,4 +641,26 @@ class ConversationTests: XCTestCase {

XCTAssertTrue(isBobAllowed2)
}

func testCanHaveImplicitConsentOnMessageSend() async throws {
let bobConversation = try await bobClient.conversations.newConversation(with: alice.address, context: InvitationV1.Context(conversationID: "hi"))
let isAllowed = (await bobConversation.consentState()) == .allowed

// Conversations you start should start as allowed
XCTAssertTrue(isAllowed)


let aliceConversation = (try await aliceClient.conversations.list())[0]
let isUnknown = (await aliceConversation.consentState()) == .unknown

// Conversations started with you should start as unknown
XCTAssertTrue(isUnknown)

try await aliceConversation.send(content: "hey bob")
try await aliceClient.contacts.refreshConsentList()
let isNowAllowed = (await aliceConversation.consentState()) == .allowed

// Conversations you send a message to get marked as allowed
XCTAssertTrue(isNowAllowed)
}
}

0 comments on commit 8c13c4c

Please sign in to comment.