From e21a2d6f871d74fb2398ee71c87176fedea6b3de Mon Sep 17 00:00:00 2001 From: Ben Follington <5009316+bfollington@users.noreply.github.com> Date: Thu, 14 Sep 2023 06:12:45 +1000 Subject: [PATCH] Remove `testWritesThenCloseThenReopenWithVars` (#891) This test started failing while testing https://github.com/subconsciousnetwork/noosphere/pull/623, leading us to question why it ever passed in the first place. Due to Swift compiler trivia the deinit for `Noosphere` is not guaranteed to be called at the time we overwrite the variable, meaning two instances of `Noosphere` co-exist pointing at the same data. We should not ever be trying to open multiple instances of `Noosphere` pointing at the same database. After team discussion we decided to drop this test case and make this an explicit failure case on the Noosphere side. --- .../SubconsciousTests/Tests_Sphere.swift | 70 ------------------- 1 file changed, 70 deletions(-) diff --git a/xcode/Subconscious/SubconsciousTests/Tests_Sphere.swift b/xcode/Subconscious/SubconsciousTests/Tests_Sphere.swift index ac1039a9..3762e76d 100644 --- a/xcode/Subconscious/SubconsciousTests/Tests_Sphere.swift +++ b/xcode/Subconscious/SubconsciousTests/Tests_Sphere.swift @@ -448,76 +448,6 @@ final class Tests_Sphere: XCTestCase { } } - func testWritesThenCloseThenReopenWithVars() async throws { - let base = UUID() - - let globalStoragePath = try createTmpDir(path: "\(base)/noosphere") - .path() - - let sphereStoragePath = try createTmpDir(path: "\(base)/sphere") - .path() - - var noosphere = try Noosphere( - globalStoragePath: globalStoragePath, - sphereStoragePath: sphereStoragePath - ) - - let sphereReceipt = try await noosphere.createSphere( - ownerKeyName: "bob" - ) - - let sphereIdentity = sphereReceipt.identity - - var sphere = try Sphere( - noosphere: noosphere, - identity: sphereReceipt.identity - ) - - let versionA0 = try await sphere.version() - - let body = try "Test content".toData().unwrap() - let contentType = "text/subtext" - try await sphere.write( - slug: Slug("a")!, - contentType: contentType, - body: body - ) - - let versionA1 = try await sphere.save() - - try await sphere.write( - slug: Slug("b")!, - contentType: contentType, - body: body - ) - try await sphere.write( - slug: Slug("c")!, - contentType: contentType, - body: body - ) - let versionA2 = try await sphere.save() - - let versionAN = try await sphere.version() - - XCTAssertNotEqual(versionA0, versionAN) - XCTAssertNotEqual(versionA1, versionAN) - XCTAssertEqual(versionA2, versionAN) - - // Overwrite var with new instance - noosphere = try Noosphere( - globalStoragePath: globalStoragePath, - sphereStoragePath: sphereStoragePath - ) - // Overwrite sphere with new sphere - sphere = try Sphere( - noosphere: noosphere, - identity: sphereIdentity - ) - let versionB0 = try await sphere.version() - - XCTAssertEqual(versionB0, versionAN) - } - func testPetnameRoundtrip() async throws { let base = UUID()