1
0
mirror of git://jb55.com/damus synced 2024-10-01 09:20:47 +00:00

test: fix crashing in AUTH test

This commit is contained in:
William Casarin 2024-01-10 15:37:52 -08:00
parent ed30b123db
commit 091a8ae090

View File

@ -51,7 +51,13 @@ final class AuthIntegrationTests: XCTestCase {
XCTAssertEqual(pool.num_connected, 1)
// Assert that AUTH message has been received
XCTAssertTrue(received_messages.count >= 1, "expected recieved_messages to be >= 1")
let json_received = try! JSONSerialization.jsonObject(with: received_messages[0].data(using: .utf8)!, options: []) as! [Any]
guard let msg = received_messages[safe: 0],
let dat = msg.data(using: .utf8),
let json_received = try? JSONSerialization.jsonObject(with: dat, options: []) as? [Any]
else {
XCTAssert(false)
return
}
XCTAssertEqual(json_received[0] as! String, "AUTH")
// Assert that we've replied with the AUTH response
XCTAssertEqual(sent_messages.count, 1)