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

feat: Remove composite codec #311

Merged
merged 1 commit into from
Apr 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 0 additions & 99 deletions Sources/XMTPiOS/Codecs/Composite.swift

This file was deleted.

22 changes: 0 additions & 22 deletions Sources/XMTPiOS/Codecs/DecodedComposite.swift

This file was deleted.

46 changes: 0 additions & 46 deletions Tests/XMTPTests/CodecTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -104,50 +104,4 @@ class CodecTests: XCTestCase {
XCTAssert(!message.senderHmac.isEmpty)

}


func testCompositeCodecOnePart() async throws {
let fixtures = await fixtures()

let aliceClient = fixtures.aliceClient!
aliceClient.register(codec: CompositeCodec())
let aliceConversation = try await aliceClient.conversations.newConversation(with: fixtures.bob.address)

let textContent = try TextCodec().encode(content: "hiya", client: aliceClient)
let source = DecodedComposite(encodedContent: textContent)
try await aliceConversation.send(content: source, options: .init(contentType: CompositeCodec().contentType))
let messages = try await aliceConversation.messages()

let decoded: DecodedComposite = try messages[0].content()
XCTAssertEqual("hiya", try decoded.content(with: aliceClient))
}

func testCompositeCodecCanHaveParts() async throws {
let fixtures = await fixtures()

let aliceClient = fixtures.aliceClient!
let aliceConversation = try await aliceClient.conversations.newConversation(with: fixtures.bob.address)

aliceClient.register(codec: CompositeCodec())
aliceClient.register(codec: NumberCodec())

let textContent = try TextCodec().encode(content: "sup", client: aliceClient)
let numberContent = try NumberCodec().encode(content: 3.14, client: aliceClient)

let source = DecodedComposite(parts: [
DecodedComposite(encodedContent: textContent),
DecodedComposite(parts: [
DecodedComposite(encodedContent: numberContent),
]),
])

try await aliceConversation.send(content: source, options: .init(contentType: CompositeCodec().contentType))
let messages = try await aliceConversation.messages()

let decoded: DecodedComposite = try messages[0].content()
let part1 = decoded.parts[0]
let part2 = decoded.parts[1].parts[0]
XCTAssertEqual("sup", try part1.content(with: aliceClient))
XCTAssertEqual(3.14, try part2.content(with: aliceClient))
}
}
Loading