             XCTAssertEqual(deleted, 4)
         }
     }
-     */
 }
+
+extension NSManagedObjectContext {
+    public func objectIDs(inEntityNamed entityName: String, withAttributesNamed attributeName: String) -> [AnyHashable: Any] {
+        var result = [AnyHashable: Any]()
+
+        self.performAndWait {
+            let expression = NSExpressionDescription()
+            expression.name = "objectID"
+            expression.expression = NSExpression.expressionForEvaluatedObject()
+            expression.expressionResultType = .objectIDAttributeType
+
+            let request = NSFetchRequest<NSDictionary>(entityName: entityName)
+            request.resultType = .dictionaryResultType
+            request.propertiesToFetch = [expression, attributeName]
+
+            do {
+                let objects = try self.fetch(request)
+                for object in objects {
+                    let fetchedID = object[attributeName] as! NSObject
+                    let objectID = object["objectID"] as! NSManagedObjectID
+
+                    if let _ = result[fetchedID] {
+                        self.delete(self.object(with: objectID))
+                    } else {
+                        result[fetchedID] = objectID
+                    }
+                }
+            } catch let error as NSError {
+                print("error: \(error)")
+            }
+        }
+        
+        return result
+    }
+}

        dataStack.performInNewBackgroundContext { backgroundContext in
            self.createUsers(context: backgroundContext)

            let before = DataObjectIDs.objectIDs(inEntityNamed: "User", withAttributesNamed: "remoteID", context: backgroundContext)
            let JSONObjects = try! JSON.from("users2.json", bundle: Bundle(for: DataFilterTests.self)) as! [[String: Any]]
            var inserted = 0
            var updated = 0

import XCTest
import CoreData
@testable import Sync

class DataFilterTests: XCTestCase {
    @discardableResult func user(remoteID: Int, firstName: String, lastName: String, age: Int, context: NSManagedObjectContext) -> NSManagedObject {
