- (void) testReachableNetwork { NSError* error; CBLMutableDocument* doc1 = [[CBLMutableDocument alloc] init]; NSData* data = [self dataFromResource: @"image" ofType: @"jpg"]; CBLBlob* blob = [[CBLBlob alloc] initWithContentType: @"image/jpeg" data: data]; [doc1 setBlob: blob forKey: @"blob"]; Assert([self.db saveDocument: doc1 error: &error]); AssertEqual(self.db.count, 1u); CBLDatabase.log.console.level = kCBLLogLevelDebug; id target = [[CBLURLEndpoint alloc] initWithURL: [NSURL URLWithString: @"ws://:4984/scratch"]]; CBLReplicatorConfiguration* config = [self configWithTarget: target type : kCBLReplicatorTypePushAndPull continuous: NO]; config.networkInterface = @"en0"; // comment and uncomment for enabling and disabling timeout = 15; [self run: config errorCode: 0 errorDomain: nil]; } - (void) testWrongNetworkInterface { // Create a doc with a blob: NSError* error; CBLMutableDocument* doc1 = [[CBLMutableDocument alloc] initWithID: @"doc1"]; NSData* data = [self dataFromResource: @"image" ofType: @"jpg"]; CBLBlob* blob = [[CBLBlob alloc] initWithContentType: @"image/jpeg" data: data]; [doc1 setBlob: blob forKey: @"blob"]; Assert([self.db saveDocument: doc1 error: &error]); AssertEqual(self.db.count, 1u); CBLDatabase.log.console.level = kCBLLogLevelDebug; id target = [[CBLURLEndpoint alloc] initWithURL: [NSURL URLWithString: @"ws://127.0.0.1:4984/scratch"]]; CBLReplicatorConfiguration* config = [self configWithTarget: target type : kCBLReplicatorTypePush continuous: NO]; config.networkInterface = @"en0"; [self run: config errorCode: 0 errorDomain: nil]; } - (void) testInvalidNetworkInterface { // Create a doc with a blob: NSError* error; CBLMutableDocument* doc1 = [[CBLMutableDocument alloc] initWithID: @"doc1"]; NSData* data = [self dataFromResource: @"image" ofType: @"jpg"]; CBLBlob* blob = [[CBLBlob alloc] initWithContentType: @"image/jpeg" data: data]; [doc1 setBlob: blob forKey: @"blob"]; Assert([self.db saveDocument: doc1 error: &error]); AssertEqual(self.db.count, 1u); CBLDatabase.log.console.level = kCBLLogLevelDebug; id target = [[CBLURLEndpoint alloc] initWithURL: [NSURL URLWithString: @"ws://:4984/scratch"]]; CBLReplicatorConfiguration* config = [self configWithTarget: target type : kCBLReplicatorTypePush continuous: NO]; config.networkInterface = @"ex0"; [self run: config errorCode: 0 errorDomain: nil]; } - (void) testUnknownHost { timeout = 20; // Create a doc with a blob: NSError* error; CBLMutableDocument* doc1 = [[CBLMutableDocument alloc] initWithID: @"doc1"]; NSData* data = [self dataFromResource: @"image" ofType: @"jpg"]; CBLBlob* blob = [[CBLBlob alloc] initWithContentType: @"image/jpeg" data: data]; [doc1 setBlob: blob forKey: @"blob"]; Assert([self.db saveDocument: doc1 error: &error]); AssertEqual(self.db.count, 1u); CBLDatabase.log.console.level = kCBLLogLevelDebug; id target = [[CBLURLEndpoint alloc] initWithURL: [NSURL URLWithString: @"ws://foo.couchbase.com:4984/scratch"]]; CBLReplicatorConfiguration* config = [self configWithTarget: target type : kCBLReplicatorTypePush continuous: NO]; config.networkInterface = @"en0"; [self run: config errorCode: 0 errorDomain: nil]; } - (void) testConnectionTimeout { // Create a doc with a blob: NSError* error; CBLMutableDocument* doc1 = [[CBLMutableDocument alloc] initWithID: @"doc1"]; NSData* data = [self dataFromResource: @"image" ofType: @"jpg"]; CBLBlob* blob = [[CBLBlob alloc] initWithContentType: @"image/jpeg" data: data]; [doc1 setBlob: blob forKey: @"blob"]; Assert([self.db saveDocument: doc1 error: &error]); AssertEqual(self.db.count, 1u); timeout = 50; CBLDatabase.log.console.level = kCBLLogLevelDebug; id target = [[CBLURLEndpoint alloc] initWithURL: [NSURL URLWithString: @"ws://example.com:81/db/"]]; CBLReplicatorConfiguration* config = [self configWithTarget: target type : kCBLReplicatorTypePush continuous: NO]; config.maxAttempts = 2; config.networkInterface = @"en0"; [self run: config errorCode: 0 errorDomain: nil]; } /* Run for SG ``` sync couchbase-lite-ios/vendor/couchbase-lite-core/Replicator/tests/data/config.json ``` */