author
int64
658
755k
date
stringlengths
19
19
timezone
int64
-46,800
43.2k
hash
stringlengths
40
40
message
stringlengths
5
490
mods
list
language
stringclasses
20 values
license
stringclasses
3 values
repo
stringlengths
5
68
original_message
stringlengths
12
491
675,381
14.03.2017 20:15:19
-10,800
78a034d27e0c59948b18a31966fe1eb18b82bba4
Update advertising hostaname when network changes
[ { "change_type": "MODIFY", "old_path": "thali/NextGeneration/thaliWifiInfrastructure.js", "new_path": "thali/NextGeneration/thaliWifiInfrastructure.js", "diff": "@@ -748,6 +748,13 @@ function (newStatus) {\n}\n}\n+ if (connectedToAP || changedAP) {\n+ // TODO: advertiser should provide API to update its advertising hostname or\n+ // it should handle network changes itself\n+ this.advertiser.routerServerAddress = ip.address();\n+ this.advertiser._updateLocation();\n+ }\n+\nPromise.all(actionResults).then(function (results) {\nresults.forEach(function (result) {\nif (result) {\n" } ]
JavaScript
MIT License
thaliproject/thali_cordovaplugin
Update advertising hostaname when network changes
675,378
15.03.2017 17:08:19
-10,800
b824c55b85a2ef0cfdef294fc68f9ea01d949cb3
Update '#stop should change peers' test for Wifi, update peerIdentifier format.
[ { "change_type": "MODIFY", "old_path": "test/www/jxcore/bv_tests/testThaliMobile.js", "new_path": "test/www/jxcore/bv_tests/testThaliMobile.js", "diff": "@@ -2040,30 +2040,25 @@ test('does not fire duplicate events after peer listener recreation',\n);\ntest('#stop should change peers', function (t) {\n- var somePeerIdentifier = 'urn:uuid:' + uuid.v4();\n-\n- var connectionType = platform.isAndroid ?\n- connectionTypes.BLUETOOTH :\n- connectionTypes.MULTI_PEER_CONNECTIVITY_FRAMEWORK;\n+ var spy = sinon.spy();\nThaliMobile.start(express.Router(), new Buffer('foo'),\n- ThaliMobile.networkTypes.NATIVE)\n+ ThaliMobile.networkTypes.BOTH)\n.then(function () {\nreturn ThaliMobile.startListeningForAdvertisements();\n})\n.then(function () {\n- return ThaliMobileNativeWrapper._handlePeerAvailabilityChanged({\n- peerIdentifier: somePeerIdentifier,\n- peerAvailable: true\n- });\n- })\n- .then(function () {\n+ var nativePeer = generateLowerLevelPeers().nativePeer;\n+ var wifiPeer = generateLowerLevelPeers().wifiPeer;\n+\n+ var availabilityHandler = function(peer) {\n+ spy();\n+ if(spy.callCount === 2) {\nt.equal(Object.getOwnPropertyNames(\n- ThaliMobile._peerAvailabilities[connectionType]).length, 1,\n+ ThaliMobile._peerAvailabilities[peer.connectionType]).length, 1,\n'Peer availabilities has one entry for our connection type');\n- return ThaliMobile.stop();\n- })\n- .then(function () {\n+\n+ ThaliMobile.stop().then(function(){\nObject.getOwnPropertyNames(connectionTypes)\n.forEach(function (connectionKey) {\nvar connectionType = connectionTypes[connectionKey];\n@@ -2072,6 +2067,14 @@ test('#stop should change peers', function (t) {\n0, 'No peers');\n});\nt.end();\n+ });\n+ }\n+ };\n+\n+ ThaliMobile.emitter.on('peerAvailabilityChanged', availabilityHandler);\n+\n+ emitNativePeerAvailability(nativePeer);\n+ emitWifiPeerAvailability(wifiPeer);\n})\n.catch(function (err) {\nt.fail('Failed out with ' + err);\n" }, { "change_type": "MODIFY", "old_path": "test/www/jxcore/bv_tests/testThaliWifiInfrastructure.js", "new_path": "test/www/jxcore/bv_tests/testThaliWifiInfrastructure.js", "diff": "@@ -723,7 +723,7 @@ test(\nreturn !platform.isAndroid\n},\nfunction (t) {\n- var peerIdentifier = 'urn:uuid:' + uuid.v4();\n+ var peerIdentifier = uuid.v4();\nvar portNumber = 8080;\nvar generation = 50;\n@@ -783,7 +783,7 @@ test(\n);\ntest('#stop should clear watchers', function (t) {\n- var somePeerIdentifier = 'urn:uuid:' + uuid.v4();\n+ var somePeerIdentifier = uuid.v4();\nwifiInfrastructure.startListeningForAdvertisements()\n.then(function () {\n" } ]
JavaScript
MIT License
thaliproject/thali_cordovaplugin
Update '#stop should change peers' test for Wifi, update peerIdentifier format.
675,379
15.03.2017 18:15:50
-10,800
76f9e054444bdb1b700bbe303c00a8cfe333fae1
Update project build configuration to Debug, when building ThaliCoreCITests scheme.
[ { "change_type": "MODIFY", "old_path": "thali/install/ios/nativeInstaller.js", "new_path": "thali/install/ios/nativeInstaller.js", "diff": "@@ -289,7 +289,7 @@ function buildFramework(projectDir, outputDir, buildWithTests) {\nprojectScheme = 'ThaliCoreCITests';\n}\n- var projectConfiguration = 'Release';\n+ var projectConfiguration = 'Debug';\nvar sdk = 'iphoneos';\nvar projectPath = path.join(projectDir, projectName + '.xcodeproj');\nvar buildDir = path.join(projectDir, 'build');\n" } ]
JavaScript
MIT License
thaliproject/thali_cordovaplugin
Update project build configuration to Debug, when building ThaliCoreCITests scheme.
675,378
16.03.2017 12:00:04
-10,800
04701a26016641fbf33f65b661f642788abd15eb
Update Discovered peer should be removed if no availability updates ' + 'were received during availability timeout' and wifi peer is marked unavailable if announcements stop tests.
[ { "change_type": "MODIFY", "old_path": "test/www/jxcore/bv_tests/testThaliWifiInfrastructure.js", "new_path": "test/www/jxcore/bv_tests/testThaliWifiInfrastructure.js", "diff": "@@ -719,9 +719,6 @@ test('functions are run from a queue in the right order', function (t) {\ntest(\n'Discovered peer should be removed if no availability updates ' +\n'were received during availability timeout',\n- function () {\n- return !platform.isAndroid\n- },\nfunction (t) {\nvar peerIdentifier = uuid.v4();\nvar portNumber = 8080;\n@@ -750,8 +747,9 @@ test(\nif (peer.peerIdentifier !== peerIdentifier) {\nreturn;\n}\n-\n- t.notOk((peer.portNumber === null && peer.hostAddress === null), 'Peer should not be available');\n+ //peer should not be available\n+ t.equal(peer.portNumber, null, 'port is null');\n+ t.equal(peer.hostAddress, null, 'host is null');\nwifiInfrastructure.removeListener('wifiPeerAvailabilityChanged',\nunavailabilityHandler);\n@@ -769,10 +767,10 @@ test(\n'wifiPeerAvailabilityChanged',\n{\npeerIdentifier: peerIdentifier,\n- peerAvailable: true,\ngeneration: generation,\nportNumber: portNumber,\n- hostAddress: '127.0.0.1'\n+ hostAddress: '127.0.0.1',\n+ availableSince: Date.now()\n}\n);\n})\n@@ -856,7 +854,6 @@ test('wifi peer is marked unavailable if announcements stop',\npeerAvailable = false;\nif (spy.calledOnce) {\nt.equal(peerAvailable, true, 'peer should be available');\n- testServer.stop();\n} else if (spy.calledTwice) {\nt.equal(peerAvailable, false, 'peer should become unavailable');\n" }, { "change_type": "MODIFY", "old_path": "thali/NextGeneration/thaliWifiInfrastructure.js", "new_path": "thali/NextGeneration/thaliWifiInfrastructure.js", "diff": "@@ -760,7 +760,7 @@ function (networkStatus) {\nThaliWifiInfrastructure.prototype._hadlePeerAvailabilityWatchers =\nfunction (peer) {\n- if (peer.peerAvailable) {\n+ if (Boolean(peer.hostAddress && peer.portNumber)) {\nthis._addAvailabilityWatcherToPeerIfNotExist(peer);\n} else {\nthis._removeAvailabilityWatcherFromPeerIfExists(peer);\n@@ -817,7 +817,6 @@ function (peer) {\nif (!this._isAvailabilityWatcherForPeerExist(peer)) {\nreturn;\n}\n-\nvar peerIdentifier = peer.peerIdentifier;\nvar interval = this.peerAvailabilityWatchers[peerIdentifier];\n" } ]
JavaScript
MIT License
thaliproject/thali_cordovaplugin
Update Discovered peer should be removed if no availability updates ' + 'were received during availability timeout' and wifi peer is marked unavailable if announcements stop tests.
675,378
16.03.2017 13:08:22
-10,800
0d6a44516fd152aab0c4704b76f86bbaab6c1f50
Update tests, update _terminateListener and _disconnect for thaliMobileNativeWrapper
[ { "change_type": "MODIFY", "old_path": "test/www/jxcore/bv_tests/testThaliMobile.js", "new_path": "test/www/jxcore/bv_tests/testThaliMobile.js", "diff": "@@ -2213,12 +2213,13 @@ test('does not fire duplicate events after peer listener recreation',\n}\n);\n-test('If there are more then PERS_LIMIT peers presented ' +\n+test('If there are more then PEERS_LIMIT peers presented ' +\n'then `discoveryDOS` event should be emitted', function (t) {\nvar PEERS_LIMIT = 1;\nvar CURRENT_MULTI_PEER_CONNECTIVITY_FRAMEWORK_PEERS_LIMIT =\n- ThaliMobile.connectionTypePeersLimits[connectionTypes.MULTI_PEER_CONNECTIVITY_FRAMEWORK];\n+ ThaliMobile.connectionTypePeersLimits\n+ [connectionTypes.MULTI_PEER_CONNECTIVITY_FRAMEWORK];\nvar CURRENT_BLUETOOTH_PEERS_LIMIT =\nThaliMobile.connectionTypePeersLimits[connectionTypes.BLUETOOTH];\n@@ -2226,18 +2227,16 @@ test('If there are more then PERS_LIMIT peers presented ' +\nvar CURRENT_TCP_NATIVE_PEERS_LIMIT =\nThaliMobile.connectionTypePeersLimits[connectionTypes.TCP_NATIVE];\n- ThaliMobile.connectionTypePeersLimits[connectionTypes.MULTI_PEER_CONNECTIVITY_FRAMEWORK] =\n- PEERS_LIMIT;\n+ ThaliMobile.connectionTypePeersLimits\n+ [connectionTypes.MULTI_PEER_CONNECTIVITY_FRAMEWORK] = PEERS_LIMIT;\nThaliMobile.connectionTypePeersLimits[connectionTypes.BLUETOOTH] =\nPEERS_LIMIT;\nThaliMobile.connectionTypePeersLimits[connectionTypes.TCP_NATIVE] =\nPEERS_LIMIT;\n- var peerIdentifier = 'urn:uuid:' + uuid.v4();\n- var anotherPeerIdentifier = 'urn:uuid:' + uuid.v4();\n-\nfunction finishTest (connectionType) {\n- ThaliMobile.connectionTypePeersLimits[connectionTypes.MULTI_PEER_CONNECTIVITY_FRAMEWORK] =\n+ ThaliMobile.connectionTypePeersLimits\n+ [connectionTypes.MULTI_PEER_CONNECTIVITY_FRAMEWORK] =\nCURRENT_MULTI_PEER_CONNECTIVITY_FRAMEWORK_PEERS_LIMIT;\nThaliMobile.connectionTypePeersLimits[connectionTypes.BLUETOOTH] =\nCURRENT_BLUETOOTH_PEERS_LIMIT;\n@@ -2250,29 +2249,15 @@ test('If there are more then PERS_LIMIT peers presented ' +\n.then(function () {\nThaliMobile.emitter.on('discoveryDOS', function (info) {\nt.ok(info.limit, PEERS_LIMIT, 'DOS limit should be presented');\n- t.ok(info.count, 2, 'Actual number off peers should be presented');\n+ t.ok(info.count, 2, 'Actual number of peers should be presented');\nfinishTest();\n});\n- ThaliMobileNativeWrapper.emitter.emit(\n- 'nonTCPPeerAvailabilityChangedEvent',\n- {\n- peerIdentifier: peerIdentifier,\n- peerAvailable: true,\n- generation: 0,\n- portNumber: 8080\n- }\n- );\n+ var nativePeer = generateLowerLevelPeers().nativePeer;\n+ var additionalNativePeer = generateLowerLevelPeers().nativePeer;\n- ThaliMobileNativeWrapper.emitter.emit(\n- 'nonTCPPeerAvailabilityChangedEvent',\n- {\n- peerIdentifier: anotherPeerIdentifier,\n- peerAvailable: true,\n- generation: 1,\n- portNumber: 8081\n- }\n- );\n+ emitNativePeerAvailability(nativePeer);\n+ emitNativePeerAvailability(additionalNativePeer);\n});\n});\n" }, { "change_type": "MODIFY", "old_path": "thali/NextGeneration/thaliMobileNativeWrapper.js", "new_path": "thali/NextGeneration/thaliMobileNativeWrapper.js", "diff": "@@ -754,10 +754,6 @@ module.exports._terminateConnection = function (incomingConnectionId) {\nmodule.exports._disconnect = function (peerIdentifier) {\nreturn gPromiseQueue\n.enqueue(function (resolve, reject) {\n- if (platform.isAndroid) {\n- return reject(new Error('Not multiConnect platform'));\n- }\n- if (platform.isIOS) {\nMobile('disconnect')\n.callNative(function (errorMsg) {\nif (errorMsg) {\n@@ -765,7 +761,6 @@ module.exports._disconnect = function (peerIdentifier) {\n}\nresolve();\n});\n- }\n});\n};\n@@ -813,9 +808,6 @@ module.exports.disconnect = function (peerIdentifier, portNumber) {\n* @returns {Promise<?error>}\n*/\nmodule.exports._terminateListener = function (peerIdentifier, port) {\n- if (platform.isIOS) {\n- return Promise.reject(new Error('Not connect platform'));\n- }\nreturn gPromiseQueue.enqueue(function (resolve, reject) {\ngServersManager.terminateOutgoingConnection(peerIdentifier, port)\n.then(function () {\n" } ]
JavaScript
MIT License
thaliproject/thali_cordovaplugin
Update tests, update _terminateListener and _disconnect for thaliMobileNativeWrapper
675,379
16.03.2017 13:47:39
-10,800
71d54659d53bd0bc0054b96d3b507aec7261654d
Move TestRunnerProtocol.swift to src/ios/Testing.
[ { "change_type": "RENAME", "old_path": "src/ios/TestRunnerProtocol.swift", "new_path": "src/ios/Testing/TestRunnerProtocol.swift", "diff": "//\n-// AppTestRunnerProtocol.swift\n+// TestRunnerProtocol.swift\n// Thali\n//\n// Copyright (C) Microsoft. All rights reserved.\n" } ]
JavaScript
MIT License
thaliproject/thali_cordovaplugin
Move TestRunnerProtocol.swift to src/ios/Testing.
675,379
16.03.2017 13:49:44
-10,800
43674931213e682be3a80a1ef30d4dd0767d1c44
Update AppContext.swift.
[ { "change_type": "MODIFY", "old_path": "src/ios/AppContext.swift", "new_path": "src/ios/AppContext.swift", "diff": "@@ -197,11 +197,11 @@ extension PeerAvailability {\nwifiState = wifiEnabled ? .on : .off\nlet bssid = ((wifiState == .on) && wifiConnected)\n- ? networkReachability.BSSID()\n- : NSNull()\n+ ? networkReachability.bssid()\n+ : nil\nlet ssid = ((wifiState == .on) && wifiConnected)\n- ? networkReachability.SSID()\n- : NSNull()\n+ ? networkReachability.ssid()\n+ : nil\nlet networkStatus = [\nNetworkStatusParameters.wifi.rawValue : wifiState.rawValue,\n@@ -212,7 +212,7 @@ extension PeerAvailability {\nNetworkStatusParameters.ssid.rawValue : ssid\n]\n- delegate?.context(self, didChangeNetworkStatus: jsonValue(networkStatus))\n+ delegate?.context(self, didChangeNetworkStatus: jsonValue(networkStatus as AnyObject))\n}\nfileprivate func handleWillEnterBackground() {\n@@ -248,11 +248,11 @@ extension PeerAvailability {\nfileprivate func handleMultiConnectResolved(withSyncValue value: String, port: UInt16?,\nerror: Error?) {\n- let errorValue = error != nil ? errorDescription(error!) : NSNull()\n- let listeningPort = port != nil ? NSNumber(value: port! as UInt16) : NSNull()\n+ let errorValue = error != nil ? errorDescription(error!) : nil\n+ let listeningPort = port != nil ? NSNumber(value: port! as UInt16) : nil\ndelegate?.context(self,\ndidResolveMultiConnectWithSyncValue: value,\n- error: errorValue,\n+ error: errorValue as NSObject?,\nlisteningPort: listeningPort)\n}\n@@ -260,9 +260,9 @@ extension PeerAvailability {\nerror: Error?) {\nlet parameters = [\n\"peerIdentifier\" : identifier,\n- \"error\" : error != nil ? errorDescription(error!) : NSNull()\n+ \"error\" : error != nil ? errorDescription(error!) : nil\n]\n- delegate?.context(self, didFailMultiConnectConnectionWith: jsonValue(parameters))\n+ delegate?.context(self, didFailMultiConnectConnectionWith: jsonValue(parameters as AnyObject))\n}\npublic init(serviceType: String) {\n@@ -281,8 +281,7 @@ extension PeerAvailability {\n#if TEST\n// We use background queue because CI tests use main_queue synchronously\n// Otherwise we won't be able to get centralManager state.\n- let centralManagerDispatchQueue =\n- dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0)\n+ let centralManagerDispatchQueue = DispatchQueue.global()\n#else\nlet centralManagerDispatchQueue: DispatchQueue? = nil\n#endif\n@@ -383,7 +382,7 @@ extension PeerAvailability {\n}\npublic func connect(_ parameters: [AnyObject]) -> String {\n- return jsonValue([JSONKey.err.rawValue : AppContextError.connectNotSupported.description])\n+ return jsonValue([JSONKey.err.rawValue : AppContextError.connectNotSupported.description] as AnyObject)\n}\n}\n@@ -396,8 +395,8 @@ extension AppContext: CBCentralManagerDelegate {\nbluetoothState = .on\nbluetoothLowEnergyState = .on\n#if TEST\n- NSNotificationCenter.defaultCenter().postNotificationName(\n- Constants.NSNotificationName.centralBluetoothManagerDidChangeState,\n+ NotificationCenter.default.post(\n+ name: NSNotification.Name(rawValue: Constants.NSNotificationName.centralBluetoothManagerDidChangeState),\nobject: self\n)\n#endif\n@@ -405,8 +404,8 @@ extension AppContext: CBCentralManagerDelegate {\nbluetoothState = .off\nbluetoothLowEnergyState = .off\n#if TEST\n- NSNotificationCenter.defaultCenter().postNotificationName(\n- Constants.NSNotificationName.centralBluetoothManagerDidChangeState,\n+ NotificationCenter.default.post(\n+ name: NSNotification.Name(rawValue: Constants.NSNotificationName.centralBluetoothManagerDidChangeState),\nobject: self\n)\n#endif\n" } ]
JavaScript
MIT License
thaliproject/thali_cordovaplugin
Update AppContext.swift.
675,379
16.03.2017 13:50:22
-10,800
ad39ceb36826075e808e7884b81cb88702576493
Update test infrastructure (AppContextTests.swift and AppContext+TestRuner.swift).
[ { "change_type": "MODIFY", "old_path": "src/ios/Testing/AppContext+TestRuner.swift", "new_path": "src/ios/Testing/AppContext+TestRuner.swift", "diff": "@@ -20,7 +20,6 @@ extension AppContext: TestRunnerProtocol {\nlet currentTestSuite = XCTestSuite(\nname: \"All tests\",\ntestCases: [\n- ThaliCore.allTestCases,\n[testCase(AppContextTests.allTests)]\n].flatMap { $0 }\n)\n" }, { "change_type": "MODIFY", "old_path": "src/ios/Testing/AppContextTests.swift", "new_path": "src/ios/Testing/AppContextTests.swift", "diff": "@@ -15,7 +15,7 @@ import UIKit\n// MARK: - Random string generator\nextension String {\n- static func random(length: Int) -> String {\n+ static func random(_ length: Int) -> String {\nlet letters: String = \"abcdefghkmnopqrstuvxyzABCDEFGHKLMNOPQRSTUXYZ\"\nvar randomString = \"\"\n@@ -193,7 +193,7 @@ class AppContextTests: XCTestCase {\nvar bluetoothChangingStateGroup: DispatchGroup?\noverride func setUp() {\n- let serviceType = String.random(length: 8)\n+ let serviceType = String.random(8)\ncontext = AppContext(serviceType: serviceType)\n}\n@@ -246,7 +246,7 @@ class AppContextTests: XCTestCase {\nfunc testDidRegisterToNative() {\nvar error: Error?\ndo {\n- try context.didRegisterToNative([\"test\", \"test\"])\n+ try context.didRegisterToNative([\"test\" as AnyObject, \"test\" as AnyObject])\n} catch let err {\nerror = err\n}\n@@ -254,7 +254,7 @@ class AppContextTests: XCTestCase {\nvar contextError: AppContextError?\ndo {\nlet notAString = 42\n- try context.didRegisterToNative([notAString])\n+ try context.didRegisterToNative([notAString as AnyObject])\n} catch let err as AppContextError {\ncontextError = err\n} catch let error {\n@@ -269,7 +269,7 @@ class AppContextTests: XCTestCase {\nfunc testThaliCoreErrors() {\n// testing parameters count\n- context.multiConnectToPeer([\"\"]) {\n+ context.multiConnectToPeer([\"\" as AnyObject]) {\nguard let err = $0 as? AppContextError else {\nXCTFail(\"unexpected error \\($0)\")\nreturn\n@@ -277,7 +277,7 @@ class AppContextTests: XCTestCase {\nXCTAssertEqual(err, AppContextError.badParameters)\n}\n// testing parameter types\n- context.multiConnectToPeer([2, 2]) {\n+ context.multiConnectToPeer([2 as AnyObject, 2 as AnyObject]) {\nguard let err = $0 as? AppContextError else {\nXCTFail(\"unexpected error \\($0)\")\nreturn\n@@ -298,16 +298,16 @@ class AppContextTests: XCTestCase {\nfunc testJsonValue() {\nvar jsonDict: [String : AnyObject] = [\"number\" : 4.2 as AnyObject]\nvar jsonString = \"{\\\"number\\\":4.2}\"\n- XCTAssertEqual(jsonValue(jsonDict), jsonString)\n+ XCTAssertEqual(jsonValue(jsonDict as AnyObject), jsonString)\njsonDict = [\"string\" : \"42\" as AnyObject]\njsonString = \"{\\\"string\\\":\\\"42\\\"}\"\n- XCTAssertEqual(jsonValue(jsonDict), jsonString)\n+ XCTAssertEqual(jsonValue(jsonDict as AnyObject), jsonString)\njsonDict = [\"null\" : NSNull()]\njsonString = \"{\\\"null\\\":null}\"\n- XCTAssertEqual(jsonValue(jsonDict), jsonString)\n+ XCTAssertEqual(jsonValue(jsonDict as AnyObject), jsonString)\njsonDict = [\"bool\" : true as AnyObject]\njsonString = \"{\\\"bool\\\":true}\"\n- XCTAssertEqual(jsonValue(jsonDict), jsonString)\n+ XCTAssertEqual(jsonValue(jsonDict as AnyObject), jsonString)\n}\nfunc testListeningAdvertisingUpdateOnStartAdvertising() {\n@@ -339,7 +339,7 @@ class AppContextTests: XCTestCase {\n[weak foundPeerFromAnotherContextExpectation] peers in\nfoundPeerFromAnotherContextExpectation?.fulfill()\n}\n- let serviceType = String.random(length: 8)\n+ let serviceType = String.random(8)\nlet context1 = AppContext(serviceType: serviceType)\ncontext1.delegate = delegateMock\nlet context2 = AppContext(serviceType: serviceType)\n@@ -371,7 +371,7 @@ class AppContextTests: XCTestCase {\nvar contextError: AppContextError?\ndo {\nlet notAString = 42\n- try context.disconnect([notAString])\n+ try context.disconnect([notAString as AnyObject])\n} catch let err as AppContextError {\ncontextError = err\n} catch let error {\n@@ -388,7 +388,7 @@ class AppContextTests: XCTestCase {\n// MARK: Private helpers\n@objc fileprivate func centralBluetoothManagerStateChanged(_ notification: Notification) {\n- if notification.name == Constants.NSNotificationName.centralBluetoothManagerDidChangeState {\n+ if notification.name == NSNotification.Name(rawValue: Constants.NSNotificationName.centralBluetoothManagerDidChangeState) {\nexpectationThatCoreBluetoothStateIsChanged?.fulfill()\nif let bluetoothChangingStateGroup = bluetoothChangingStateGroup {\nbluetoothChangingStateGroup.leave()\n" } ]
JavaScript
MIT License
thaliproject/thali_cordovaplugin
Update test infrastructure (AppContextTests.swift and AppContext+TestRuner.swift).
675,379
16.03.2017 13:50:58
-10,800
69839bb533bb029cf36e2a91d75c7c529a835e57
Build ThaliCoreCITests with Debug scheme only.
[ { "change_type": "MODIFY", "old_path": "thali/install/ios/nativeInstaller.js", "new_path": "thali/install/ios/nativeInstaller.js", "diff": "@@ -285,11 +285,13 @@ function biuldSwiftXCTest(checkoutDir, buildDir, buildWithTests) {\nfunction buildFramework(projectDir, outputDir, buildWithTests) {\nvar projectName = 'ThaliCore';\nvar projectScheme = 'ThaliCore';\n+ var projectConfiguration = 'Release';\n+\nif (buildWithTests) {\nprojectScheme = 'ThaliCoreCITests';\n+ projectConfiguration = 'Debug';\n}\n- var projectConfiguration = 'Debug';\nvar sdk = 'iphoneos';\nvar projectPath = path.join(projectDir, projectName + '.xcodeproj');\nvar buildDir = path.join(projectDir, 'build');\n" } ]
JavaScript
MIT License
thaliproject/thali_cordovaplugin
Build ThaliCoreCITests with Debug scheme only.
675,379
16.03.2017 15:28:44
-10,800
be90731424310198446e02f26edd4552edb92abc
Comment adding old XCTeset framework.
[ { "change_type": "MODIFY", "old_path": "thali/install/ios/nativeInstaller.js", "new_path": "thali/install/ios/nativeInstaller.js", "diff": "@@ -108,16 +108,16 @@ function updateProjectFrameworks(\n// Add the frameworks again.\n// This time they will have the code-sign option set\n// so they get code signed when being deployed to devices.\n- if (buildWithTests) {\n- console.log('Adding XCTest.framework');\n- var xcTestFrameworkPath = '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/Frameworks/XCTest.framework';\n- // '/Applications/Xcode.app/Contents/Developer/Platforms/\n- // iPhoneSimulator.platform/Developer/Library/Frameworks/XCTest\n- // .framework';\n- xcodeProject.addFramework(\n- xcTestFrameworkPath,\n- {customFramework: true, embed: true, link: true, sign: true});\n- }\n+ // if (buildWithTests) {\n+ // console.log('Adding XCTest.framework');\n+ // var xcTestFrameworkPath = '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/Frameworks/XCTest.framework';\n+ // // '/Applications/Xcode.app/Contents/Developer/Platforms/\n+ // // iPhoneSimulator.platform/Developer/Library/Frameworks/XCTest\n+ // // .framework';\n+ // xcodeProject.addFramework(\n+ // xcTestFrameworkPath,\n+ // {customFramework: true, embed: true, link: true, sign: true});\n+ // }\n}\nfunction updateProjectTestingInfrastructure(\n" } ]
JavaScript
MIT License
thaliproject/thali_cordovaplugin
Comment adding old XCTeset framework.
675,379
16.03.2017 15:29:12
-10,800
54d29ed9c709da9f84d829f52d3236b6c8144fb4
Update deployment target for ThaliCore to 10.0.
[ { "change_type": "MODIFY", "old_path": "thali/install/ios/nativeInstaller.js", "new_path": "thali/install/ios/nativeInstaller.js", "diff": "@@ -303,6 +303,7 @@ function buildFramework(projectDir, outputDir, buildWithTests) {\n' -configuration ' + projectConfiguration +\n' -sdk ' + sdk +\n' ONLY_ACTIVE_ARCH=NO ' +\n+ ' IPHONEOS_DEPLOYMENT_TARGET=10.0' +\n' BUILD_DIR=' + '\\\"' + buildDir + '\\\"' +\n' clean build';\n" } ]
JavaScript
MIT License
thaliproject/thali_cordovaplugin
Update deployment target for ThaliCore to 10.0.
675,379
16.03.2017 15:29:43
-10,800
9a1b12aa582995d3b273e3dc688c2e3f69cd3ddf
Update project configuration for CocoaAsyncSocket framework.
[ { "change_type": "MODIFY", "old_path": "thali/install/ios/nativeInstaller.js", "new_path": "thali/install/ios/nativeInstaller.js", "diff": "@@ -224,6 +224,11 @@ function biuldCocoaAsyncSocket(checkoutDir, buildDir, buildWithTests) {\nvar projectScheme = 'iOS Framework';\nvar projectConfiguration = 'Release';\n+\n+ if (buildWithTests) {\n+ projectConfiguration = 'Debug';\n+ }\n+\nvar sdk = 'iphoneos';\nvar projectPath = path.join(checkoutDir, projectDir, projectName + '.xcodeproj');\nvar buildDir = path.join(buildDir, projectName);\n" } ]
JavaScript
MIT License
thaliproject/thali_cordovaplugin
Update project configuration for CocoaAsyncSocket framework.
675,379
16.03.2017 15:30:10
-10,800
8a224d4835c0fd1dcdc5e7a1eea594415e86e0e0
Add copying of CocoaAsyncSocket to final build dir.
[ { "change_type": "MODIFY", "old_path": "thali/install/ios/nativeInstaller.js", "new_path": "thali/install/ios/nativeInstaller.js", "diff": "@@ -250,6 +250,17 @@ function biuldCocoaAsyncSocket(checkoutDir, buildDir, buildWithTests) {\n.then(function () {\nreturn fs.ensureDir(buildDir);\n})\n+ .then(function () {\n+ var frameworkBuildDir = path.join(\n+ buildDir, projectConfiguration + '-' + sdk, projectName + '.framework');\n+ var frameworkOutputDir = path.join(\n+ buildDir, 'Release' + '-' + sdk, projectName + '.framework');\n+\n+ console.log('copy from ' + frameworkBuildDir);\n+ console.log('copy to ' + frameworkOutputDir);\n+\n+ return fs.copy(frameworkBuildDir, frameworkOutputDir, { clobber: false });\n+ });\n}\nfunction biuldSwiftXCTest(checkoutDir, buildDir, buildWithTests) {\n" } ]
JavaScript
MIT License
thaliproject/thali_cordovaplugin
Add copying of CocoaAsyncSocket to final build dir.
675,381
16.03.2017 17:28:52
-10,800
d1b7cb9a7c5426e1dad1f1daa843e8434fe321db
Fix watcher's unavailability event
[ { "change_type": "MODIFY", "old_path": "thali/NextGeneration/thaliWifiInfrastructure.js", "new_path": "thali/NextGeneration/thaliWifiInfrastructure.js", "diff": "@@ -778,9 +778,6 @@ function (peer) {\nThaliWifiInfrastructure.prototype._watchForPeerAvailability =\nfunction (peer) {\n- var peerIdentifier = peer.peerIdentifier;\n- var connectionType = peer.connectionType;\n-\nvar now = Date.now();\nvar unavailabilityThreshold =\nthaliConfig.TCP_PEER_UNAVAILABILITY_THRESHOLD;\n@@ -792,7 +789,12 @@ function (peer) {\n}\nthis._removeAvailabilityWatcherFromPeerIfExists(peer);\n- this.emit('wifiPeerAvailabilityChanged', peer);\n+ this.emit('wifiPeerAvailabilityChanged', {\n+ peerIdentifier: peer.peerIdentifier,\n+ generation: null,\n+ portNumber: null,\n+ hostAddress: null\n+ });\n};\n" } ]
JavaScript
MIT License
thaliproject/thali_cordovaplugin
Fix watcher's unavailability event
675,378
16.03.2017 17:47:15
-10,800
50788d384ef48f98824533301c324d9867d8d503
Update terminateListener method
[ { "change_type": "MODIFY", "old_path": "thali/NextGeneration/thaliMobileNativeWrapper.js", "new_path": "thali/NextGeneration/thaliMobileNativeWrapper.js", "diff": "@@ -808,6 +808,9 @@ module.exports.disconnect = function (peerIdentifier, portNumber) {\n* @returns {Promise<?error>}\n*/\nmodule.exports._terminateListener = function (peerIdentifier, port) {\n+ if (platform.isIOS) {\n+ return Promise.reject(new Error('Not connect platform'));\n+ }\nreturn gPromiseQueue.enqueue(function (resolve, reject) {\ngServersManager.terminateOutgoingConnection(peerIdentifier, port)\n.then(function () {\n" } ]
JavaScript
MIT License
thaliproject/thali_cordovaplugin
Update terminateListener method
675,379
17.03.2017 11:30:52
-10,800
d1c7c5d262e65edf5e2190561ee4342f79ed8b79
Improve logging during running nativeInstaller.js.
[ { "change_type": "MODIFY", "old_path": "thali/install/ios/nativeInstaller.js", "new_path": "thali/install/ios/nativeInstaller.js", "diff": "@@ -150,18 +150,15 @@ function addFramework(\nvar checkoutDir = path.join(frameworkOutputDir, 'Carthage', 'Checkouts');\nvar buildDir = path.join(checkoutDir, 'thali-ios', 'Carthage', 'Build');\n- console.log('checkout dir is ' + checkoutDir);\n- console.log('build dir is ' + buildDir);\n+ console.log('Building CocoaAsyncSocket.framework');\nreturn biuldCocoaAsyncSocket(checkoutDir, buildDir, buildWithTests)\n})\n.then (function () {\n- console.log('Building CocoaAsyncSocket done!');\n+ console.log('Building CocoaAsyncSocket.framework has been finished');\nvar checkoutDir = path.join(frameworkOutputDir, 'Carthage', 'Checkouts');\nvar buildDir = path.join(checkoutDir, 'thali-ios', 'Carthage', 'Build');\n- console.log('checkout dir is ' + checkoutDir);\n- console.log('build dir is ' + buildDir);\nreturn biuldSwiftXCTest(checkoutDir, buildDir, buildWithTests)\n})\n@@ -226,6 +223,7 @@ function biuldCocoaAsyncSocket(checkoutDir, buildDir, buildWithTests) {\nvar projectConfiguration = 'Release';\nif (buildWithTests) {\n+ console.log('Building in debug mode');\nprojectConfiguration = 'Debug';\n}\n@@ -256,9 +254,6 @@ function biuldCocoaAsyncSocket(checkoutDir, buildDir, buildWithTests) {\nvar frameworkOutputDir = path.join(\nbuildDir, 'Release' + '-' + sdk, projectName + '.framework');\n- console.log('copy from ' + frameworkBuildDir);\n- console.log('copy to ' + frameworkOutputDir);\n-\nreturn fs.copy(frameworkBuildDir, frameworkOutputDir, { clobber: false });\n});\n}\n@@ -304,6 +299,7 @@ function buildFramework(projectDir, outputDir, buildWithTests) {\nvar projectConfiguration = 'Release';\nif (buildWithTests) {\n+ console.log('Building in debug mode');\nprojectScheme = 'ThaliCoreCITests';\nprojectConfiguration = 'Debug';\n}\n@@ -324,10 +320,12 @@ function buildFramework(projectDir, outputDir, buildWithTests) {\n' clean build';\nconsole.log('Building ThaliCore.framework');\n+ console.log('Build command:\\n' + buildCmd);\n// todo: fixed buffer size should be fixed with streaming in #1001\nreturn exec(buildCmd, { maxBuffer: 10*1024*1024 } )\n.then(function () {\n+ console.log('Building ThaliCore.framework has been finished');\nreturn fs.ensureDir(outputDir);\n})\n.then(function () {\n" } ]
JavaScript
MIT License
thaliproject/thali_cordovaplugin
Improve logging during running nativeInstaller.js.
675,379
17.03.2017 11:32:24
-10,800
f539fcd5a2f5efb43e34f7144db49cf34b5432e9
Add some build properties to main Xcode project in order to use current Swift version.
[ { "change_type": "MODIFY", "old_path": "thali/install/ios/nativeInstaller.js", "new_path": "thali/install/ios/nativeInstaller.js", "diff": "@@ -45,8 +45,66 @@ function updateProjectBuildProperties(xcodeProject, buildWithTests) {\n// I believe that this line of code will be removed in the future\nxcodeProject.removeBuildProperty(\n'EMBEDDED_CONTENT_CONTAINS_SWIFT');\n+\n+ xcodeProject.removeBuildProperty(\n+ 'ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES');\n+ xcodeProject.addBuildProperty(\n+ 'ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES', 'YES');\n+\n+ xcodeProject.removeBuildProperty(\n+ 'IPHONEOS_DEPLOYMENT_TARGET');\n+ xcodeProject.addBuildProperty(\n+ 'IPHONEOS_DEPLOYMENT_TARGET', '10.0');\n+\n+ xcodeProject.removeBuildProperty(\n+ 'SWIFT_VERSION');\n+ xcodeProject.addBuildProperty(\n+ 'SWIFT_VERSION', '3.0');\n+\n+ xcodeProject.removeBuildProperty(\n+ 'CLANG_WARN_ENUM_CONVERSION');\n+ xcodeProject.addBuildProperty(\n+ 'CLANG_WARN_ENUM_CONVERSION', 'YES');\n+\n+ xcodeProject.removeBuildProperty(\n+ 'CLANG_WARN_INFINITE_RECURSION');\n+ xcodeProject.addBuildProperty(\n+ 'CLANG_WARN_INFINITE_RECURSION', 'YES');\n+\n+ xcodeProject.removeBuildProperty(\n+ 'CLANG_WARN_SUSPICIOUS_MOVE');\n+ xcodeProject.addBuildProperty(\n+ 'CLANG_WARN_SUSPICIOUS_MOVE', 'YES');\n+\n+ xcodeProject.removeBuildProperty(\n+ 'CLANG_WARN_UNREACHABLE_CODE');\n+ xcodeProject.addBuildProperty(\n+ 'CLANG_WARN_UNREACHABLE_CODE', 'YES');\n+\n+ xcodeProject.removeBuildProperty(\n+ 'ENABLE_STRICT_OBJC_MSGSEND');\n+ xcodeProject.addBuildProperty(\n+ 'ENABLE_STRICT_OBJC_MSGSEND', 'YES');\n+\n+ xcodeProject.removeBuildProperty(\n+ 'ENABLE_TESTABILITY');\n+ xcodeProject.addBuildProperty(\n+ 'ENABLE_TESTABILITY', 'YES');\n+\n+ xcodeProject.removeBuildProperty(\n+ 'GCC_NO_COMMON_BLOCKS');\n+ xcodeProject.addBuildProperty(\n+ 'GCC_NO_COMMON_BLOCKS', 'YES');\n+\n+ xcodeProject.removeBuildProperty(\n+ 'GCC_WARN_64_TO_32_BIT_CONVERSION');\n+ xcodeProject.addBuildProperty(\n+ 'GCC_WARN_64_TO_32_BIT_CONVERSION', 'YES');\n+\n+ xcodeProject.removeBuildProperty(\n+ 'SWIFT_OPTIMIZATION_LEVEL');\nxcodeProject.addBuildProperty(\n- 'EMBEDDED_CONTENT_CONTAINS_SWIFT', 'YES');\n+ 'SWIFT_OPTIMIZATION_LEVEL', '-Owholemodule');\nif (buildWithTests) {\nxcodeProject.removeBuildProperty(\n" } ]
JavaScript
MIT License
thaliproject/thali_cordovaplugin
Add some build properties to main Xcode project in order to use current Swift version.
675,379
17.03.2017 11:32:37
-10,800
e6dc0bea6f6f93e41a69d67289d858d117b2abcf
Remove ThaliCoreCITests usage. Update Cartfile.resolved.
[ { "change_type": "MODIFY", "old_path": "lib/ios/Cartfile.resolved", "new_path": "lib/ios/Cartfile.resolved", "diff": "github \"robbiehanson/CocoaAsyncSocket\" \"7.6.0\"\ngithub \"thaliproject/swift-corelibs-xctest\" \"9f415647a545b45d0fd349590788b160e1a67e49\"\n-github \"thaliproject/thali-ios\" \"c836bcb715fde3ed2ec7dc6e96d089892261c3bf\"\n+github \"thaliproject/thali-ios\" \"26c54b8c34dba8aade68c41021cd0d4023cec18a\"\n" }, { "change_type": "MODIFY", "old_path": "src/ios/Testing/AppContext+TestRuner.swift", "new_path": "src/ios/Testing/AppContext+TestRuner.swift", "diff": "import Foundation\nimport SwiftXCTest\nimport ThaliCore\n-import ThaliCoreCITests\nextension AppContext: TestRunnerProtocol {\n" }, { "change_type": "MODIFY", "old_path": "src/ios/Testing/AppContextTests.swift", "new_path": "src/ios/Testing/AppContextTests.swift", "diff": "import SwiftXCTest\nimport ThaliCore\n-import ThaliCoreCITests\nimport UIKit\n// MARK: - Random string generator\n" } ]
JavaScript
MIT License
thaliproject/thali_cordovaplugin
Remove ThaliCoreCITests usage. Update Cartfile.resolved.
675,379
17.03.2017 12:57:16
-10,800
ba6e0c64e5df50093a0f75e771ae02f87d941b2c
Add phase that copies frameworks into iOS infrustructure dir to be able to build ThaliTest app.
[ { "change_type": "MODIFY", "old_path": "thali/install/ios/nativeInstaller.js", "new_path": "thali/install/ios/nativeInstaller.js", "diff": "@@ -313,6 +313,14 @@ function biuldCocoaAsyncSocket(checkoutDir, buildDir, buildWithTests) {\nbuildDir, 'Release' + '-' + sdk, projectName + '.framework');\nreturn fs.copy(frameworkBuildDir, frameworkOutputDir, { clobber: false });\n+ })\n+ .then(function () {\n+ var frameworkBuildDir = path.join(\n+ buildDir, projectConfiguration + '-' + sdk, projectName + '.framework');\n+ var thaliCoreFrameworkOutputDir = path.join(\n+ checkoutDir, '..', '..', projectName + '.framework');\n+\n+ return fs.copy(frameworkBuildDir, thaliCoreFrameworkOutputDir, { clobber: false });\n});\n}\n@@ -320,6 +328,7 @@ function biuldSwiftXCTest(checkoutDir, buildDir, buildWithTests) {\nvar projectDir = 'swift-corelibs-xctest';\nvar projectName = 'XCTest'\nvar projectScheme = 'SwiftXCTest-iOS';\n+ var frameworkName = 'SwiftXCTest';\nvar projectConfiguration = 'Release';\nvar sdk = 'iphoneos';\n@@ -343,6 +352,17 @@ function biuldSwiftXCTest(checkoutDir, buildDir, buildWithTests) {\n.then(function () {\nreturn fs.ensureDir(buildDir);\n})\n+ .then(function () {\n+ var frameworkBuildDir = path.join(\n+ buildDir, projectConfiguration + '-' + sdk, frameworkName + '.framework');\n+ var thaliCoreFrameworkOutputDir = path.join(\n+ checkoutDir, '..', '..', frameworkName + '.framework');\n+\n+ console.log('from: ', frameworkBuildDir);\n+ console.log('to : ', thaliCoreFrameworkOutputDir);\n+\n+ return fs.copy(frameworkBuildDir, thaliCoreFrameworkOutputDir, { clobber: false });\n+ });\n}\n/**\n" } ]
JavaScript
MIT License
thaliproject/thali_cordovaplugin
Add phase that copies frameworks into iOS infrustructure dir to be able to build ThaliTest app.
675,379
17.03.2017 13:31:57
-10,800
c2caefb6e70e0cd0aa088ad82e88e809db17ac50
Trigger the build.
[ { "change_type": "MODIFY", "old_path": "build.sh", "new_path": "build.sh", "diff": "#!/usr/bin/env bash\n-### START - JXcore Test Server --------.......................\n+### START - JXcore Test Server --------......................\n### Testing environment prepares separate packages for each node.\n### Package builder calls this script with each node's IP address\n### Make sure multiple calls to this script file compiles the application file\n" } ]
JavaScript
MIT License
thaliproject/thali_cordovaplugin
Trigger the build.
675,379
20.03.2017 14:27:12
-10,800
e4c439489541845d7b44472dfb8d707279f0f67b
Remove commented code. Embed SwiftXCTest and CocoaAsyncSocket to fix crashes in runtime.
[ { "change_type": "MODIFY", "old_path": "thali/install/ios/nativeInstaller.js", "new_path": "thali/install/ios/nativeInstaller.js", "diff": "@@ -163,19 +163,13 @@ function updateProjectFrameworks(\npath.join(frameworkOutputDir, 'ThaliCore.framework'),\n{customFramework: true, embed: true, link: true, sign: true});\n- // Add the frameworks again.\n- // This time they will have the code-sign option set\n- // so they get code signed when being deployed to devices.\n- // if (buildWithTests) {\n- // console.log('Adding XCTest.framework');\n- // var xcTestFrameworkPath = '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/Frameworks/XCTest.framework';\n- // // '/Applications/Xcode.app/Contents/Developer/Platforms/\n- // // iPhoneSimulator.platform/Developer/Library/Frameworks/XCTest\n- // // .framework';\n- // xcodeProject.addFramework(\n- // xcTestFrameworkPath,\n- // {customFramework: true, embed: true, link: true, sign: true});\n- // }\n+ xcodeProject.addFramework(\n+ path.join(frameworkOutputDir, 'SwiftXCTest.framework'),\n+ {customFramework: true, embed: true, link: true, sign: true});\n+\n+ xcodeProject.addFramework(\n+ path.join(frameworkOutputDir, 'CocoaAsyncSocket.framework'),\n+ {customFramework: true, embed: true, link: true, sign: true});\n}\nfunction updateProjectTestingInfrastructure(\n" } ]
JavaScript
MIT License
thaliproject/thali_cordovaplugin
Remove commented code. Embed SwiftXCTest and CocoaAsyncSocket to fix crashes in runtime.
675,378
17.03.2017 16:34:20
-10,800
aab4ee756217ba75980567b516401d2b7e7f7cdf
Implement test for discoveryAdvertisingStateUpdateNonTCP
[ { "change_type": "MODIFY", "old_path": "test/www/jxcore/bv_tests/testThaliMobileNative.js", "new_path": "test/www/jxcore/bv_tests/testThaliMobileNative.js", "diff": "@@ -882,3 +882,53 @@ function (t) {\nboundListener.listener(peers);\n});\n});\n+\n+test('discoveryAdvertisingStateUpdateNonTCP is called', function (t) {\n+ var callCount = 0;\n+ Mobile('discoveryAdvertisingStateUpdateNonTCP').registerToNative(\n+ function (state) {\n+ callCount++;\n+ switch (callCount) {\n+ case 1:\n+ t.equal(state.discoveryActive, true,\n+ 'discoveryActive should be false');\n+ t.equal(state.advertisingActive, false,\n+ 'advertisingActive should be true');\n+ Mobile('startUpdateAdvertisingAndListening').callNative(4242, function (err) {\n+ t.notOk(err, 'Can call startUpdateAdvertisingAndListeningwithout error');\n+ });\n+ break;\n+ case 2:\n+ t.equal(state.discoveryActive, true,\n+ 'discoveryActive should be false');\n+ t.equal(state.advertisingActive, true,\n+ 'advertisingActive should be true');\n+ Mobile('stopListeningForAdvertisements').callNative(function (err) {\n+ t.notOk(err, 'Can call stopListeningForAdvertisements error');\n+ });\n+ break;\n+ case 3:\n+ t.equal(state.discoveryActive, false,\n+ 'discoveryActive should be false');\n+ t.equal(state.advertisingActive, true,\n+ 'advertisingActive should be true');\n+ Mobile('stopAdvertisingAndListening').callNative(function (err) {\n+ t.notOk(err, 'Can call stopAdvertisingAndListening error');\n+ });\n+ break;\n+ case 4:\n+ t.equal(state.discoveryActive, false,\n+ 'discoveryActive should be false');\n+ t.equal(state.advertisingActive, false,\n+ 'advertisingActive should be true');\n+ t.end();\n+ break;\n+ default:\n+ break;\n+ }\n+ });\n+\n+ Mobile('startListeningForAdvertisements').callNative(function (err) {\n+ t.notOk(err, 'Can call startListeningForAdvertisements error');\n+ });\n+});\n" } ]
JavaScript
MIT License
thaliproject/thali_cordovaplugin
Implement test for discoveryAdvertisingStateUpdateNonTCP
675,378
17.03.2017 18:03:12
-10,800
1515ce529958082e692287d263c89d67f7e0a741
Update ThaliMobile with global sandbox
[ { "change_type": "MODIFY", "old_path": "test/www/jxcore/bv_tests/testThaliMobile.js", "new_path": "test/www/jxcore/bv_tests/testThaliMobile.js", "diff": "@@ -23,13 +23,16 @@ var net = require('net');\nvar radioState = ThaliMobileNative.radioState;\nvar connectionTypes = ThaliMobileNativeWrapper.connectionTypes;\nvar verifyCombinedResultSuccess = testUtils.verifyCombinedResultSuccess;\n+var sandbox;\nvar test = tape({\nsetup: function (t) {\n+ sandbox = sinon.sandbox.create();\nt.notOk(ThaliMobile.isStarted(), 'ThaliMobile should be stopped');\nt.end();\n},\nteardown: function (t) {\n+ sandbox.restore();\nThaliMobile.stop()\n.then(function (combinedResult) {\nverifyCombinedResultSuccess(t, combinedResult);\n@@ -230,7 +233,6 @@ test('#start subscribes to the WiFi infrastructure events and #stop ' +\nreturn true;\n},\nfunction (t) {\n- var sandbox = sinon.sandbox.create();\nvar wifiEmitter = ThaliMobile._getThaliWifiInfrastructure();\nvar nativeEmitter = ThaliMobileNativeWrapper.emitter;\n@@ -275,7 +277,6 @@ test('#start subscribes to the WiFi infrastructure events and #stop ' +\n})\n.catch(t.fail)\n.then(function () {\n- sandbox.restore();\nt.end();\n});\n}\n" } ]
JavaScript
MIT License
thaliproject/thali_cordovaplugin
Update ThaliMobile with global sandbox
675,378
20.03.2017 10:50:28
-10,800
c420e15e4cd9d48cb9d2723ee69c7095147b7fab
Update connectionTypePeersLimits for internal support only. Update PeersLimitReached event
[ { "change_type": "MODIFY", "old_path": "test/www/jxcore/bv_tests/testThaliMobile.js", "new_path": "test/www/jxcore/bv_tests/testThaliMobile.js", "diff": "@@ -2218,29 +2218,29 @@ test('If there are more then PEERS_LIMIT peers presented ' +\nvar PEERS_LIMIT = 1;\nvar CURRENT_MULTI_PEER_CONNECTIVITY_FRAMEWORK_PEERS_LIMIT =\n- ThaliMobile.connectionTypePeersLimits\n+ ThaliMobile._connectionTypePeersLimits\n[connectionTypes.MULTI_PEER_CONNECTIVITY_FRAMEWORK];\nvar CURRENT_BLUETOOTH_PEERS_LIMIT =\n- ThaliMobile.connectionTypePeersLimits[connectionTypes.BLUETOOTH];\n+ ThaliMobile._connectionTypePeersLimits[connectionTypes.BLUETOOTH];\nvar CURRENT_TCP_NATIVE_PEERS_LIMIT =\n- ThaliMobile.connectionTypePeersLimits[connectionTypes.TCP_NATIVE];\n+ ThaliMobile._connectionTypePeersLimits[connectionTypes.TCP_NATIVE];\n- ThaliMobile.connectionTypePeersLimits\n+ ThaliMobile._connectionTypePeersLimits\n[connectionTypes.MULTI_PEER_CONNECTIVITY_FRAMEWORK] = PEERS_LIMIT;\n- ThaliMobile.connectionTypePeersLimits[connectionTypes.BLUETOOTH] =\n+ ThaliMobile._connectionTypePeersLimits[connectionTypes.BLUETOOTH] =\nPEERS_LIMIT;\n- ThaliMobile.connectionTypePeersLimits[connectionTypes.TCP_NATIVE] =\n+ ThaliMobile._connectionTypePeersLimits[connectionTypes.TCP_NATIVE] =\nPEERS_LIMIT;\nfunction finishTest (connectionType) {\n- ThaliMobile.connectionTypePeersLimits\n+ ThaliMobile._connectionTypePeersLimits\n[connectionTypes.MULTI_PEER_CONNECTIVITY_FRAMEWORK] =\nCURRENT_MULTI_PEER_CONNECTIVITY_FRAMEWORK_PEERS_LIMIT;\n- ThaliMobile.connectionTypePeersLimits[connectionTypes.BLUETOOTH] =\n+ ThaliMobile._connectionTypePeersLimits[connectionTypes.BLUETOOTH] =\nCURRENT_BLUETOOTH_PEERS_LIMIT;\n- ThaliMobile.connectionTypePeersLimits[connectionTypes.TCP_NATIVE] =\n+ ThaliMobile._connectionTypePeersLimits[connectionTypes.TCP_NATIVE] =\nCURRENT_TCP_NATIVE_PEERS_LIMIT;\nt.end();\n}\n" }, { "change_type": "MODIFY", "old_path": "thali/NextGeneration/thaliMobile.js", "new_path": "thali/NextGeneration/thaliMobile.js", "diff": "@@ -1496,7 +1496,7 @@ connectionTypePeersLimits[connectionTypes.BLUETOOTH] =\nconnectionTypePeersLimits[connectionTypes.TCP_NATIVE] =\nthaliConfig.TCP_NATIVE_PEERS_LIMIT;\n-module.exports.connectionTypePeersLimits = connectionTypePeersLimits;\n+module.exports._connectionTypePeersLimits = connectionTypePeersLimits;\nvar emitIfConnectionTypePeersLimitReached = function (connectionType) {\nvar connectionTypePeers = peerAvailabilities[connectionType];\n@@ -1504,7 +1504,7 @@ var emitIfConnectionTypePeersLimitReached = function (connectionType) {\nvar peersLimit = connectionTypePeersLimits[connectionType];\nif (connectionTypePeersCount > peersLimit) {\nmodule.exports.emitter\n- .emit(connectionType + 'PeersLimitReached', {\n+ .emit(connectionType + '-PeersLimitReached', {\nlimit: peersLimit,\ncount: connectionTypePeersCount\n});\n@@ -1519,7 +1519,7 @@ Object.keys(connectionTypes)\n.forEach(function (key) {\nvar connectionType = connectionTypes[key];\n- module.exports.emitter.on(connectionType + 'PeersLimitReached',\n+ module.exports.emitter.on(connectionType + '-PeersLimitReached',\nfunction (info) {\nemitDiscoveryDOS({\nconnectionType: connectionType,\n" } ]
JavaScript
MIT License
thaliproject/thali_cordovaplugin
Update connectionTypePeersLimits for internal support only. Update PeersLimitReached event
675,379
20.03.2017 13:14:06
-10,800
d2009a0b2d71e2d7fe743777b4cded44ec662134
Rename TEST_DEVELOPMENT_TEAM variable to THALI_TEST_DEVELOPMENT_TEAM.
[ { "change_type": "MODIFY", "old_path": "thali/install/setUpTests.sh", "new_path": "thali/install/setUpTests.sh", "diff": "@@ -198,7 +198,7 @@ build_ios_if_possible()\nbuild \\\nCONFIGURATION_BUILD_DIR=\"${IOS_PROJECT_DIR}/build/device\" \\\nSHARED_PRECOMPS_DIR=\"${IOS_PROJECT_DIR}/build/sharedpch\" \\\n- DEVELOPMENT_TEAM=\"${TEST_DEVELOPMENT_TEAM:-3648SALNRR}\" \\\n+ DEVELOPMENT_TEAM=\"${THALI_TEST_DEVELOPMENT_TEAM:-3648SALNRR}\" \\\n)\necho \"end building ${PROJECT_NAME} iOS app\"\n" } ]
JavaScript
MIT License
thaliproject/thali_cordovaplugin
Rename TEST_DEVELOPMENT_TEAM variable to THALI_TEST_DEVELOPMENT_TEAM.
675,379
20.03.2017 14:41:00
-10,800
14f1591db5b6e5b9238cd4f828abea4976a0cea6
Fixed some typos in nativeInstaller.js.
[ { "change_type": "MODIFY", "old_path": "thali/install/ios/nativeInstaller.js", "new_path": "thali/install/ios/nativeInstaller.js", "diff": "@@ -204,7 +204,7 @@ function addFramework(\nvar buildDir = path.join(checkoutDir, 'thali-ios', 'Carthage', 'Build');\nconsole.log('Building CocoaAsyncSocket.framework');\n- return biuldCocoaAsyncSocket(checkoutDir, buildDir, buildWithTests)\n+ return buildCocoaAsyncSocket(checkoutDir, buildDir, buildWithTests)\n})\n.then (function () {\nconsole.log('Building CocoaAsyncSocket.framework has been finished');\n@@ -212,7 +212,7 @@ function addFramework(\nvar checkoutDir = path.join(frameworkOutputDir, 'Carthage', 'Checkouts');\nvar buildDir = path.join(checkoutDir, 'thali-ios', 'Carthage', 'Build');\n- return biuldSwiftXCTest(checkoutDir, buildDir, buildWithTests)\n+ return buildSwiftXCTest(checkoutDir, buildDir, buildWithTests)\n})\n.then (function () {\n// We need to build ThaliCore.framework before embedding it into the project\n@@ -267,7 +267,7 @@ function checkoutThaliCoreViaCarthage(cartfileDir, outputDir, buildWithTests) {\n})\n}\n-function biuldCocoaAsyncSocket(checkoutDir, buildDir, buildWithTests) {\n+function buildCocoaAsyncSocket(checkoutDir, buildDir, buildWithTests) {\nvar projectDir = 'CocoaAsyncSocket';\nvar projectName = 'CocoaAsyncSocket';\nvar projectScheme = 'iOS Framework';\n@@ -318,7 +318,7 @@ function biuldCocoaAsyncSocket(checkoutDir, buildDir, buildWithTests) {\n});\n}\n-function biuldSwiftXCTest(checkoutDir, buildDir, buildWithTests) {\n+function buildSwiftXCTest(checkoutDir, buildDir, buildWithTests) {\nvar projectDir = 'swift-corelibs-xctest';\nvar projectName = 'XCTest'\nvar projectScheme = 'SwiftXCTest-iOS';\n" } ]
JavaScript
MIT License
thaliproject/thali_cordovaplugin
Fixed some typos in nativeInstaller.js.
675,378
20.03.2017 16:11:31
-10,800
130407f97e0e67de65fbe0b2730c074661e89b61
Update tests for peerAvailabilities
[ { "change_type": "MODIFY", "old_path": "test/www/jxcore/bv_tests/testThaliMobile.js", "new_path": "test/www/jxcore/bv_tests/testThaliMobile.js", "diff": "@@ -2054,11 +2054,17 @@ test('#stop should change peers', function (t) {\nvar availabilityHandler = function(peer) {\nspy();\n- if(spy.callCount === 2) {\n+\n+ switch (spy.callCount) {\n+ case 1:\n+ t.equal(Object.getOwnPropertyNames(\n+ ThaliMobile._peerAvailabilities[peer.connectionType]).length, 1,\n+ 'Peer availabilities has one entry for our connection type');\n+ break;\n+ case 2:\nt.equal(Object.getOwnPropertyNames(\nThaliMobile._peerAvailabilities[peer.connectionType]).length, 1,\n'Peer availabilities has one entry for our connection type');\n-\nThaliMobile.stop().then(function(){\nObject.getOwnPropertyNames(connectionTypes)\n.forEach(function (connectionKey) {\n@@ -2069,11 +2075,13 @@ test('#stop should change peers', function (t) {\n});\nt.end();\n});\n+ break;\n+ default:\n+ break;\n}\n};\nThaliMobile.emitter.on('peerAvailabilityChanged', availabilityHandler);\n-\nemitNativePeerAvailability(nativePeer);\nemitWifiPeerAvailability(wifiPeer);\n})\n" } ]
JavaScript
MIT License
thaliproject/thali_cordovaplugin
Update tests for peerAvailabilities
675,378
20.03.2017 17:14:58
-10,800
3d6928245cbd67021cc86eb1eb61ccf3a94d2ecc
create simple test for sandbox
[ { "change_type": "MODIFY", "old_path": "test/www/jxcore/bv_tests/testTests.js", "new_path": "test/www/jxcore/bv_tests/testTests.js", "diff": "var tape = require('../lib/thaliTape');\nvar platform = require('thali/NextGeneration/utils/platform');\nvar Promise = require('lie');\n+var sinon = require('sinon');\nvar customData = 'custom data';\n@@ -29,6 +30,18 @@ test('another', function (t) {\nt.end();\n});\n+var testObject = {\n+ testMethod: function() {\n+ logger.debug(\"test object for global sinon sansbox\");\n+ }\n+};\n+\n+test('test sinon sansbox', function (t) {\n+ var sandbox = sinon.sandbox.create();\n+ sinon.spy(testObject, \"testMethod\");\n+ t.end();\n+});\n+\nif (!tape.coordinated) {\nreturn;\n}\n" } ]
JavaScript
MIT License
thaliproject/thali_cordovaplugin
create simple test for sandbox
675,379
21.03.2017 13:56:23
-10,800
a32d62413251ade348c01e31818cadc027a211b3
Remove commented and obsolete code in setUpTests.sh.
[ { "change_type": "MODIFY", "old_path": "thali/install/setUpTests.sh", "new_path": "thali/install/setUpTests.sh", "diff": "@@ -177,16 +177,6 @@ build_ios_if_possible()\ncordova prepare ios --device\n- # TODO: we need new cordova release to make it work\n- # (\\\n- # cd $IOS_PROJECT_DIR && \\\n- # cordova build --device -d \\\n- # --buildFlag=\"DEVELOPMENT_TEAM=${TEST_DEVELOPMENT_TEAM:-3648SALNRR}\" \\\n- # --buildFlag=\"GCC_PREPROCESSOR_DEFINITIONS=DEBUG=1 TEST=1\" \\\n- # --buildFlag=\"OTHER_SWIFT_FLAGS='-DTEST'\" \\\n- # --buildFlag=\"SWIFT_VERSION='3.0'\"\n- # )\n-\n(\\\ncd $IOS_PROJECT_DIR && \\\nxcodebuild \\\n" } ]
JavaScript
MIT License
thaliproject/thali_cordovaplugin
Remove commented and obsolete code in setUpTests.sh.
675,378
22.03.2017 12:11:21
-10,800
3ed0d6eaf163f8d137ee7599c664a2c3ed281463
Update copy for discoveryAdvertisingStateUpdateNonTCP is called test
[ { "change_type": "MODIFY", "old_path": "test/www/jxcore/bv_tests/testThaliMobileNative.js", "new_path": "test/www/jxcore/bv_tests/testThaliMobileNative.js", "diff": "@@ -904,7 +904,7 @@ test('discoveryAdvertisingStateUpdateNonTCP is called', function (t) {\nt.equal(state.advertisingActive, true,\n'advertisingActive should be true');\nMobile('stopListeningForAdvertisements').callNative(function (err) {\n- t.notOk(err, 'Can call stopListeningForAdvertisements error');\n+ t.notOk(err, 'Can call stopListeningForAdvertisements without error');\n});\nbreak;\ncase 3:\n@@ -913,7 +913,7 @@ test('discoveryAdvertisingStateUpdateNonTCP is called', function (t) {\nt.equal(state.advertisingActive, true,\n'advertisingActive should be true');\nMobile('stopAdvertisingAndListening').callNative(function (err) {\n- t.notOk(err, 'Can call stopAdvertisingAndListening error');\n+ t.notOk(err, 'Can call stopAdvertisingAndListening without error');\n});\nbreak;\ncase 4:\n@@ -929,6 +929,6 @@ test('discoveryAdvertisingStateUpdateNonTCP is called', function (t) {\n});\nMobile('startListeningForAdvertisements').callNative(function (err) {\n- t.notOk(err, 'Can call startListeningForAdvertisements error');\n+ t.notOk(err, 'Can call startListeningForAdvertisements without error');\n});\n});\n" } ]
JavaScript
MIT License
thaliproject/thali_cordovaplugin
Update copy for discoveryAdvertisingStateUpdateNonTCP is called test
675,379
22.03.2017 15:07:22
-10,800
331388053ef4d01893f60f0a8716ac7f4609aa49
Simplify nativeInstaller.js. Update Cartfile.resolved.
[ { "change_type": "MODIFY", "old_path": "lib/ios/Cartfile.resolved", "new_path": "lib/ios/Cartfile.resolved", "diff": "github \"robbiehanson/CocoaAsyncSocket\" \"7.6.0\"\ngithub \"thaliproject/swift-corelibs-xctest\" \"9f415647a545b45d0fd349590788b160e1a67e49\"\n-github \"thaliproject/thali-ios\" \"26c54b8c34dba8aade68c41021cd0d4023cec18a\"\n+github \"thaliproject/thali-ios\" \"6df330dabf7fd2e41d55578652bbc46d221de008\"\n" }, { "change_type": "MODIFY", "old_path": "thali/install/ios/nativeInstaller.js", "new_path": "thali/install/ios/nativeInstaller.js", "diff": "@@ -200,21 +200,6 @@ function addFramework(\n.then (function () {\nconsole.log('Checkouting done!');\n- var checkoutDir = path.join(frameworkOutputDir, 'Carthage', 'Checkouts');\n- var buildDir = path.join(checkoutDir, 'thali-ios', 'Carthage', 'Build');\n-\n- console.log('Building CocoaAsyncSocket.framework');\n- return buildCocoaAsyncSocket(checkoutDir, buildDir, buildWithTests)\n- })\n- .then (function () {\n- console.log('Building CocoaAsyncSocket.framework has been finished');\n-\n- var checkoutDir = path.join(frameworkOutputDir, 'Carthage', 'Checkouts');\n- var buildDir = path.join(checkoutDir, 'thali-ios', 'Carthage', 'Build');\n-\n- return buildSwiftXCTest(checkoutDir, buildDir, buildWithTests)\n- })\n- .then (function () {\n// We need to build ThaliCore.framework before embedding it into the project\nreturn buildFramework(\nframeworkProjectDir, frameworkOutputDir, buildWithTests)\n@@ -256,10 +241,10 @@ function addFramework(\nfunction checkoutThaliCoreViaCarthage(cartfileDir, outputDir, buildWithTests) {\nvar changeDirCmd = 'cd ' + cartfileDir;\n- var carthageCmd = 'carthage checkout';\n+ var carthageCmd = 'carthage update --no-build';\nvar checkoutCmd = changeDirCmd + ' && ' + carthageCmd;\n- console.log('Checkouting ThaliCore-iOS and its dependencies');\n+ console.log('Checkouting ThaliCore and its dependencies');\nreturn exec(checkoutCmd, { maxBuffer: 10*1024*1024 } )\n.then(function () {\n@@ -267,98 +252,6 @@ function checkoutThaliCoreViaCarthage(cartfileDir, outputDir, buildWithTests) {\n})\n}\n-function buildCocoaAsyncSocket(checkoutDir, buildDir, buildWithTests) {\n- var projectDir = 'CocoaAsyncSocket';\n- var projectName = 'CocoaAsyncSocket';\n- var projectScheme = 'iOS Framework';\n-\n- var projectConfiguration = 'Release';\n-\n- if (buildWithTests) {\n- console.log('Building in debug mode');\n- projectConfiguration = 'Debug';\n- }\n-\n- var sdk = 'iphoneos';\n- var projectPath = path.join(checkoutDir, projectDir, projectName + '.xcodeproj');\n- var buildDir = path.join(buildDir, projectName);\n-\n- var changeDirCmd = 'cd ' + checkoutDir + '/' + projectName;\n- var buildCmd = 'set -o pipefail && ' +\n- 'xcodebuild -project' +\n- ' \\\"' + projectPath + '\\\"' +\n- ' -scheme ' + '\\\"' + projectScheme + '\\\"' +\n- ' -configuration ' + projectConfiguration +\n- ' -sdk ' + sdk +\n- ' ONLY_ACTIVE_ARCH=NO ' +\n- ' BUILD_DIR=' + '\\\"' + buildDir + '\\\"' +\n- ' clean build';\n-\n- var changeDirAndBuildCmd = changeDirCmd + ' && ' + buildCmd;\n-\n- return exec(changeDirAndBuildCmd, { maxBuffer: 10*1024*1024 } )\n- .then(function () {\n- return fs.ensureDir(buildDir);\n- })\n- .then(function () {\n- var frameworkBuildDir = path.join(\n- buildDir, projectConfiguration + '-' + sdk, projectName + '.framework');\n- var frameworkOutputDir = path.join(\n- buildDir, 'Release' + '-' + sdk, projectName + '.framework');\n-\n- return fs.copy(frameworkBuildDir, frameworkOutputDir, { clobber: false });\n- })\n- .then(function () {\n- var frameworkBuildDir = path.join(\n- buildDir, projectConfiguration + '-' + sdk, projectName + '.framework');\n- var thaliCoreFrameworkOutputDir = path.join(\n- checkoutDir, '..', '..', projectName + '.framework');\n-\n- return fs.copy(frameworkBuildDir, thaliCoreFrameworkOutputDir, { clobber: false });\n- });\n-}\n-\n-function buildSwiftXCTest(checkoutDir, buildDir, buildWithTests) {\n- var projectDir = 'swift-corelibs-xctest';\n- var projectName = 'XCTest'\n- var projectScheme = 'SwiftXCTest-iOS';\n- var frameworkName = 'SwiftXCTest';\n-\n- var projectConfiguration = 'Release';\n- var sdk = 'iphoneos';\n- var projectPath = path.join(checkoutDir, projectDir, projectName + '.xcodeproj');\n- var buildDir = path.join(buildDir, projectName);\n-\n- var changeDirCmd = 'cd ' + checkoutDir + '/' + projectDir;\n- var buildCmd = 'set -o pipefail && ' +\n- 'xcodebuild -project' +\n- ' \\\"' + projectPath + '\\\"' +\n- ' -scheme ' + '\\\"' + projectScheme + '\\\"' +\n- ' -configuration ' + projectConfiguration +\n- ' -sdk ' + sdk +\n- ' ONLY_ACTIVE_ARCH=NO ' +\n- ' BUILD_DIR=' + '\\\"' + buildDir + '\\\"' +\n- ' clean build';\n-\n- var changeDirAndBuildCmd = changeDirCmd + ' && ' + buildCmd;\n-\n- return exec(changeDirAndBuildCmd, { maxBuffer: 10*1024*1024 } )\n- .then(function () {\n- return fs.ensureDir(buildDir);\n- })\n- .then(function () {\n- var frameworkBuildDir = path.join(\n- buildDir, projectConfiguration + '-' + sdk, frameworkName + '.framework');\n- var thaliCoreFrameworkOutputDir = path.join(\n- checkoutDir, '..', '..', frameworkName + '.framework');\n-\n- console.log('from: ', frameworkBuildDir);\n- console.log('to : ', thaliCoreFrameworkOutputDir);\n-\n- return fs.copy(frameworkBuildDir, thaliCoreFrameworkOutputDir, { clobber: false });\n- });\n-}\n-\n/**\n* @param {string} projectDir Xcode project directory\n* @param {string} outputDir Framework output directory\n@@ -366,6 +259,10 @@ function buildSwiftXCTest(checkoutDir, buildDir, buildWithTests) {\n* @returns {Promise} Output of exec\n*/\nfunction buildFramework(projectDir, outputDir, buildWithTests) {\n+\n+ var cocoaAsyncSocketFrameworkName = 'CocoaAsyncSocket';\n+ var XCTestFrameworkName = 'SwiftXCTest';\n+\nvar projectName = 'ThaliCore';\nvar projectScheme = 'ThaliCore';\nvar projectConfiguration = 'Release';\n@@ -401,12 +298,28 @@ function buildFramework(projectDir, outputDir, buildWithTests) {\nreturn fs.ensureDir(outputDir);\n})\n.then(function () {\n- var frameworkBuildDir = path.join(\n+ var thaliCoreFrameworkBuildDir = path.join(\nbuildDir, projectConfiguration + '-' + sdk, projectName + '.framework');\nvar frameworkOutputDir = path.join(\noutputDir, projectName + '.framework');\n- return fs.copy(frameworkBuildDir, frameworkOutputDir, { clobber: false });\n+ return fs.copy(thaliCoreFrameworkBuildDir, frameworkOutputDir, { clobber: false });\n+ })\n+ .then(function () {\n+ var cocoaAsyncSocketFrameworkBuildDir = path.join(\n+ projectDir, 'Carthage', 'Build', 'iOS', cocoaAsyncSocketFrameworkName + '.framework');\n+ var frameworkOutputDir = path.join(\n+ outputDir, cocoaAsyncSocketFrameworkName + '.framework');\n+\n+ return fs.copy(cocoaAsyncSocketFrameworkBuildDir, frameworkOutputDir, { clobber: false });\n+ })\n+ .then(function () {\n+ var swiftXCTestFrameworkBuildDir = path.join(\n+ projectDir, 'Carthage', 'Build', 'iOS', XCTestFrameworkName + '.framework');\n+ var frameworkOutputDir = path.join(\n+ outputDir, XCTestFrameworkName + '.framework');\n+\n+ return fs.copy(swiftXCTestFrameworkBuildDir, frameworkOutputDir, { clobber: false });\n});\n}\n" } ]
JavaScript
MIT License
thaliproject/thali_cordovaplugin
Simplify nativeInstaller.js. Update Cartfile.resolved.
675,378
23.03.2017 14:28:02
-10,800
332fdcded0335209128210e6a8c3279c53067cf1
Implement SinonTest module, create simple tests for sinon sandboxes
[ { "change_type": "MODIFY", "old_path": "test/www/jxcore/bv_tests/testTests.js", "new_path": "test/www/jxcore/bv_tests/testTests.js", "diff": "@@ -36,9 +36,19 @@ var testObject = {\n}\n};\n-test('test sinon sansbox', tape.sinonTest(function (t) {\n- var sandbox = sinon.sandbox.create();\n+var testSanboxObject = testObject;\n+\n+test('test sinon sansbox spy', tape.sinonTest(function (t) {\nthis.spy(testObject, \"testMethod\");\n+ t.equal(testObject.testMethod, testSanboxObject.testMethod,\n+ 'test sandbox spy works correctly');\n+ t.end();\n+}));\n+\n+test('test sinon sansbox stub', tape.sinonTest(function (t) {\n+ this.stub(testObject, \"testMethod\");\n+ t.notEqual(testObject.testMethod, testSanboxObject.testMethod,\n+ 'test sandbox stub works correctly');\nt.end();\n}));\n" }, { "change_type": "MODIFY", "old_path": "test/www/jxcore/lib/SinonTest.js", "new_path": "test/www/jxcore/lib/SinonTest.js", "diff": "var util = require('util');\nvar inherits = util.inherits;\nvar sinon = require('sinon');\n-var tape = require('../lib/thaliTape');\n-var newTape = require('../lib/thaliTape');\n-var EventEmitter = require('events').EventEmitter;\n-\nvar asserts = require('./utils/asserts');\nvar logger = require('thali/ThaliLogger')('SinonTest');\nfunction SinonTest (callback) {\n- // We are calling this function directly without 'new'.\n- if (!this) {\n- return new SinonTest(callback);\n+ return function (t) {\n+ var slice = Array.prototype.slice;\n+ var config = sinon.getConfig(sinon.config);\n+ config.injectInto = config.injectIntoThis && this || config.injectInto;\n+ var sandbox = sinon.sandbox.create(config);\n+ var args = slice.call(arguments);\n+ var tapeEnd = t.end;\n+ var exception, result;\n+\n+ if (typeof t.end === \"function\") {\n+ t.end = function end(res) {\n+ if (res) {\n+ sandbox.restore();\n+ } else {\n+ sandbox.verifyAndRestore();\n}\n- var sinonTest = sinon.test(callback);\n- return sinonTest;\n+ tapeEnd(res);\n+ };\n}\n-inherits(SinonTest, EventEmitter);\n+ try {\n+ result = callback.apply(this, args.concat(sandbox.args));\n+ } catch (e) {\n+ exception = e;\n+ t.fail(e);\n+ }\n+ return result;\n+ };\n+}\nmodule.exports = SinonTest;\n" } ]
JavaScript
MIT License
thaliproject/thali_cordovaplugin
Implement SinonTest module, create simple tests for sinon sandboxes
675,378
23.03.2017 16:37:08
-10,800
a06a2a709de71a4854f7e458c7196bb6fc2652a7
Implement simple tests for SinonTest module
[ { "change_type": "MODIFY", "old_path": "test/www/jxcore/bv_tests/testTests.js", "new_path": "test/www/jxcore/bv_tests/testTests.js", "diff": "@@ -31,24 +31,42 @@ test('another', function (t) {\n});\nvar testObject = {\n- testMethod: function() {\n- logger.debug(\"test object for global sinon sansbox\");\n+ testSpyMethod: function() {\n+ logger.debug('test spy method for global sinon sansbox');\n+ },\n+ testStubMethod: function () {\n+ return 'test stub method for global sinon sansbox'\n}\n};\nvar testSanboxObject = testObject;\ntest('test sinon sansbox spy', tape.sinonTest(function (t) {\n- this.spy(testObject, \"testMethod\");\n- t.equal(testObject.testMethod, testSanboxObject.testMethod,\n+ this.spy(testObject, 'testSpyMethod');\n+ t.equal(testObject.testSpyMethod, testSanboxObject.testSpyMethod,\n'test sandbox spy works correctly');\nt.end();\n}));\ntest('test sinon sansbox stub', tape.sinonTest(function (t) {\n- this.stub(testObject, \"testMethod\");\n- t.notEqual(testObject.testMethod, testSanboxObject.testMethod,\n- 'test sandbox stub works correctly');\n+ var callback = this.stub().returns(42);\n+ t.equal(callback(), 42, 'test sandbox stub works correctly');\n+ t.end();\n+}));\n+\n+test('test sinon sansbox stub override', tape.sinonTest(function (t) {\n+ var result = testObject.testStubMethod();\n+ var stub = this.stub(testObject, 'testStubMethod', function () { return \"test\";});\n+ t.notEqual(stub(), result, 'test sandbox stub works correctly');\n+ t.end();\n+}));\n+\n+test('test sinon sansbox mock', tape.sinonTest(function (t) {\n+ var mock = this.mock(testObject);\n+ mock.expects(\"testStubMethod\").twice();\n+ testObject.testStubMethod();\n+ testObject.testStubMethod();\n+ mock.verify();\nt.end();\n}));\n" } ]
JavaScript
MIT License
thaliproject/thali_cordovaplugin
Implement simple tests for SinonTest module
675,378
23.03.2017 17:18:26
-10,800
ea2ff16879c4e4d05789ee9fe1ebbe26e80e46a9
Update tests with sandbox
[ { "change_type": "MODIFY", "old_path": "test/www/jxcore/bv_tests/testPouchDBCheckpointPlugin.js", "new_path": "test/www/jxcore/bv_tests/testPouchDBCheckpointPlugin.js", "diff": "var tape = require('../lib/thaliTape');\nvar testUtils = require('../lib/testUtils');\n-var sinon = require('sinon');\nvar randomString = require('randomstring');\nvar PouchDB = testUtils.getLevelDownPouchDb()\n@@ -59,9 +58,9 @@ function () {\n// incomplete solution\nreturn true;\n},\n-function (t) {\n- var spy = sinon.spy();\n- var anotherSpy = sinon.spy();\n+tape.sinonTest(function (t) {\n+ var spy = this.spy();\n+ var anotherSpy = this.spy();\nvar endTestIfBothSpiesWereCalledOnce = function (test) {\nif (spy.callCount > 1 || anotherSpy.callCount > 1) {\n@@ -84,7 +83,7 @@ function (t) {\n});\ndb.put(new Doc()).catch(t.end);\n-});\n+}));\ntest('Call of onCheckpointReached handler on multiple db changes ' +\n'that are in the checkpoints plugin delay interval',\n@@ -93,9 +92,9 @@ function () {\n// incomplete solution\nreturn true;\n},\n-function (t) {\n+tape.sinonTest(function (t) {\nvar ENSURE_DELAY = 1000;\n- var spy = sinon.spy();\n+ var spy = this.spy();\ndb.onCheckpointReached(function () {\nspy();\n@@ -117,7 +116,7 @@ function (t) {\n.catch(function (error) {\nt.end(error);\n});\n-});\n+}));\ntest('Call of onCheckpointReached handler on multiple db changes ' +\n'that are out of the checkpoints plugin delay interval',\n@@ -126,8 +125,8 @@ function () {\n// incomplete solution\nreturn true;\n},\n-function (t) {\n- var spy = sinon.spy();\n+tape.sinonTest(function (t) {\n+ var spy = this.spy();\nvar handler = function () {\nspy();\n@@ -148,4 +147,4 @@ function (t) {\n.catch(function (error) {\nt.end(error);\n});\n-});\n+}));\n" }, { "change_type": "MODIFY", "old_path": "test/www/jxcore/bv_tests/testSSDPServer.js", "new_path": "test/www/jxcore/bv_tests/testSSDPServer.js", "diff": "var tape = require('../lib/thaliTape');\nvar Promise = require('bluebird');\n-var sinon = require('sinon');\nvar express = require('express');\nvar ThaliMobile = require('thali/NextGeneration/thaliMobile');\n@@ -20,16 +19,11 @@ function callArg(arg) {\narg();\n}\n-var sandbox = null;\n-\nvar test = tape({\nsetup: function (t) {\n- sandbox = sinon.sandbox.create();\nt.end();\n},\nteardown: function (t) {\n- sandbox.restore();\n- sandbox = null;\nt.end();\n}\n});\n@@ -39,7 +33,7 @@ test(\nfunction () {\nreturn global.NETWORK_TYPE !== networkTypes.WIFI;\n},\n- function (t) {\n+ tape.sinonTest(function (t) {\nfunction toggleWifi(value) {\nThaliMobileNativeWrapper.emitter.emit('networkChangedNonTCP', {\nwifi: value? 'on' : 'off',\n@@ -53,13 +47,13 @@ test(\nvar wifiInfrastructure = new ThaliWifiInfrastructure();\nvar serverStartSpy =\n- sandbox.spy(wifiInfrastructure._getSSDPServer(), 'start');\n+ this.spy(wifiInfrastructure._getSSDPServer(), 'start');\nvar serverStopSpy =\n- sandbox.spy(wifiInfrastructure._getSSDPServer(), 'stop');\n+ this.spy(wifiInfrastructure._getSSDPServer(), 'stop');\nvar clientStartSpy =\n- sandbox.spy(wifiInfrastructure._getSSDPClient(), 'start');\n+ this.spy(wifiInfrastructure._getSSDPClient(), 'start');\nvar clientStopSpy =\n- sandbox.spy(wifiInfrastructure._getSSDPClient(), 'stop');\n+ this.spy(wifiInfrastructure._getSSDPClient(), 'stop');\nwifiInfrastructure.start(express.Router(), pskIdToSecret)\n.then(function () {\n@@ -101,7 +95,7 @@ test(\n'should not be in started state');\nt.end();\n});\n- }\n+ })\n);\nfunction changeBssid (value) {\n@@ -152,15 +146,15 @@ test(\nfunction () {\nreturn global.NETWORK_TYPE !== networkTypes.WIFI;\n},\n- function (t) {\n+ tape.sinonTest(function (t) {\nvar wifiInfrastructure = new ThaliWifiInfrastructure();\nvar ssdpServer = wifiInfrastructure._getSSDPServer();\nvar ssdpClient = wifiInfrastructure._getSSDPClient();\nvar stubs = {\n- serverStart: sandbox.stub(ssdpServer, 'start', callArg),\n- serverStop: sandbox.stub(ssdpServer, 'stop', callArg),\n- clientStart: sandbox.stub(ssdpClient, 'start', callArg),\n- clientStop: sandbox.stub(ssdpClient, 'stop', callArg)\n+ serverStart: this.stub(ssdpServer, 'start', callArg),\n+ serverStop: this.stub(ssdpServer, 'stop', callArg),\n+ clientStart: this.stub(ssdpClient, 'start', callArg),\n+ clientStop: this.stub(ssdpClient, 'stop', callArg)\n};\nvar context = { t: t, stubs: stubs };\nvar testBssid = testBssidChangeReaction.bind(null, context);\n@@ -198,7 +192,7 @@ test(\n'should not be in started state');\nt.end();\n});\n- }\n+ })\n);\ntest(\n@@ -207,15 +201,15 @@ test(\nfunction () {\nreturn global.NETWORK_TYPE !== networkTypes.WIFI;\n},\n- function (t) {\n+ tape.sinonTest(function (t) {\nvar wifiInfrastructure = new ThaliWifiInfrastructure();\nvar ssdpServer = wifiInfrastructure._getSSDPServer();\nvar ssdpClient = wifiInfrastructure._getSSDPClient();\nvar stubs = {\n- serverStart: sandbox.stub(ssdpServer, 'start', callArg),\n- serverStop: sandbox.stub(ssdpServer, 'stop', callArg),\n- clientStart: sandbox.stub(ssdpClient, 'start', callArg),\n- clientStop: sandbox.stub(ssdpClient, 'stop', callArg)\n+ serverStart: this.stub(ssdpServer, 'start', callArg),\n+ serverStop: this.stub(ssdpServer, 'stop', callArg),\n+ clientStart: this.stub(ssdpClient, 'start', callArg),\n+ clientStop: this.stub(ssdpClient, 'stop', callArg)\n};\nvar context = { t: t, stubs: stubs };\nvar testBssid = testBssidChangeReaction.bind(null, context);\n@@ -244,5 +238,5 @@ test(\n'should not be in started state');\nt.end();\n});\n- }\n+ })\n);\n" } ]
JavaScript
MIT License
thaliproject/thali_cordovaplugin
Update tests with sandbox
675,378
24.03.2017 13:17:56
-10,800
457d5d97cfbfc5b1faef4af2714ec9392ab402cc
Update tests with sandbox (testThaliManager, testThaliMobile). Update sinon config using sandbox with issue (https://github.com/thaliproject/jxcore/issues/86)
[ { "change_type": "MODIFY", "old_path": "test/www/jxcore/bv_tests/testTests.js", "new_path": "test/www/jxcore/bv_tests/testTests.js", "diff": "var tape = require('../lib/thaliTape');\nvar platform = require('thali/NextGeneration/utils/platform');\nvar Promise = require('lie');\n-var sinon = require('sinon');\nvar logger = require('thali/ThaliLogger')('testTests');\nvar customData = 'custom data';\n" }, { "change_type": "MODIFY", "old_path": "test/www/jxcore/bv_tests/testThaliManager.js", "new_path": "test/www/jxcore/bv_tests/testThaliManager.js", "diff": "@@ -10,7 +10,6 @@ var PouchDB = require('pouchdb');\nvar express = require('express');\nvar expressPouchDB = require('express-pouchdb');\n-var sinon = require('sinon');\nvar proxyquire = require('proxyquire').noCallThru();\nvar Salti = require('salti');\n@@ -41,57 +40,57 @@ var test = tape({\n}\n});\n-function Mocks(t) {\n+function Mocks(t, sandboxObject) {\n// All objects should be cloned in order to prevent\n// 'already wrapped' error by 'sinon.spy'.\nthis.t = t;\n- this.express = sinon.spy(express);\n- this.expressPouchDB = sinon.spy(expressPouchDB);\n- this.LevelDownPouchDB = sinon.spy(testUtils.getLevelDownPouchDb());\n+ this.express = sandboxObject.spy(express);\n+ this.expressPouchDB = sandboxObject.spy(expressPouchDB);\n+ this.LevelDownPouchDB = sandboxObject.spy(testUtils.getLevelDownPouchDb());\nthis.ThaliMobile = extend({}, ThaliMobile);\n- this.MobileStart = sinon.spy(this.ThaliMobile, 'start');\n- this.MobileStop = sinon.spy(this.ThaliMobile, 'stop');\n+ this.MobileStart = sandboxObject.spy(this.ThaliMobile, 'start');\n+ this.MobileStop = sandboxObject.spy(this.ThaliMobile, 'stop');\n- this.MobileStartLA = sinon.spy(\n+ this.MobileStartLA = sandboxObject.spy(\nthis.ThaliMobile, 'startListeningForAdvertisements'\n);\n- this.MobileStartUAA = sinon.spy(\n+ this.MobileStartUAA = sandboxObject.spy(\nthis.ThaliMobile, 'startUpdateAdvertisingAndListening'\n);\n- this.Notification = sinon.spy(\n+ this.Notification = sandboxObject.spy(\nThaliSendNotificationBasedOnReplication\n);\nthis.Notification.prototype = extend(\n{},\nThaliSendNotificationBasedOnReplication.prototype\n);\n- this.NotificationStart = sinon.spy(\n+ this.NotificationStart = sandboxObject.spy(\nthis.Notification.prototype, 'start'\n);\n- this.NotificationStop = sinon.spy(\n+ this.NotificationStop = sandboxObject.spy(\nthis.Notification.prototype, 'stop'\n);\n- this.Replication = sinon.spy(\n+ this.Replication = sandboxObject.spy(\nThaliPullReplicationFromNotification\n);\nthis.Replication.prototype = extend(\n{},\nThaliPullReplicationFromNotification.prototype\n);\n- this.ReplicationStart = sinon.spy(\n+ this.ReplicationStart = sandboxObject.spy(\nthis.Replication.prototype, 'start'\n);\n- this.ReplicationStop = sinon.spy(\n+ this.ReplicationStop = sandboxObject.spy(\nthis.Replication.prototype, 'stop'\n);\n- this.Salti = sinon.spy(Salti);\n+ this.Salti = sandboxObject.spy(Salti);\nthis.ThaliManager =\nproxyquire('thali/NextGeneration/thaliManager', {\n'./replication/thaliSendNotificationBasedOnReplication':\n@@ -380,7 +379,7 @@ Mocks.prototype.checkSalti = function(dbName) {\n);\n};\n-test('test thali manager spies', function (t) {\n+test('test thali manager spies', tape.sinonTest(function (t) {\n// This function will return all participant's public keys\n// except local 'publicKeyForLocalDevice' one.\nvar partnerKeys;\n@@ -392,7 +391,7 @@ test('test thali manager spies', function (t) {\npartnerKeys = [];\n}\n- var mocks = new Mocks(t);\n+ var mocks = new Mocks(t, this);\n// Creating thali manager with mocks.\nvar dbName = testUtils.getRandomPouchDBName();\n@@ -418,9 +417,9 @@ test('test thali manager spies', function (t) {\nmocks.checkStop();\nt.end();\n});\n-});\n+}));\n-test('test thali manager multiple starts and stops', function (t) {\n+test('test thali manager multiple starts and stops', tape.sinonTest(function (t) {\n// This function will return all participant's public keys\n// except local 'publicKeyForLocalDevice' one.\nvar partnerKeys;\n@@ -432,7 +431,7 @@ test('test thali manager multiple starts and stops', function (t) {\npartnerKeys = [];\n}\n- var mocks = new Mocks(t);\n+ var mocks = new Mocks(t, this);\n// Creating thali manager with mocks.\nvar dbName = testUtils.getRandomPouchDBName();\n@@ -518,4 +517,4 @@ test('test thali manager multiple starts and stops', function (t) {\n.then(function () {\nt.end();\n});\n-});\n+}));\n" }, { "change_type": "MODIFY", "old_path": "test/www/jxcore/bv_tests/testThaliMobile.js", "new_path": "test/www/jxcore/bv_tests/testThaliMobile.js", "diff": "@@ -9,7 +9,6 @@ var tape = require('../lib/thaliTape');\nvar testUtils = require('../lib/testUtils.js');\nvar express = require('express');\nvar validations = require('thali/validations');\n-var sinon = require('sinon');\nvar uuid = require('uuid');\nvar nodessdp = require('node-ssdp');\nvar objectAssign = require('object-assign');\n@@ -23,16 +22,13 @@ var net = require('net');\nvar radioState = ThaliMobileNative.radioState;\nvar connectionTypes = ThaliMobileNativeWrapper.connectionTypes;\nvar verifyCombinedResultSuccess = testUtils.verifyCombinedResultSuccess;\n-var sandbox;\nvar test = tape({\nsetup: function (t) {\n- sandbox = sinon.sandbox.create();\nt.notOk(ThaliMobile.isStarted(), 'ThaliMobile should be stopped');\nt.end();\n},\nteardown: function (t) {\n- sandbox.restore();\nThaliMobile.stop()\n.then(function (combinedResult) {\nverifyCombinedResultSuccess(t, combinedResult);\n@@ -232,14 +228,14 @@ test('#start subscribes to the WiFi infrastructure events and #stop ' +\n// NATIVE and for BOTH modes\nreturn true;\n},\n- function (t) {\n+ tape.sinonTest(function (t) {\nvar wifiEmitter = ThaliMobile._getThaliWifiInfrastructure();\nvar nativeEmitter = ThaliMobileNativeWrapper.emitter;\n- var wifiOnSpy = sandbox.spy(wifiEmitter, 'on');\n- var nativeOnSpy = sandbox.spy(nativeEmitter, 'on');\n- var wifiOffSpy = sandbox.spy(wifiEmitter, 'removeListener');\n- var nativeOffSpy = sandbox.spy(nativeEmitter, 'removeListener');\n+ var wifiOnSpy = this.spy(wifiEmitter, 'on');\n+ var nativeOnSpy = this.spy(nativeEmitter, 'on');\n+ var wifiOffSpy = this.spy(wifiEmitter, 'removeListener');\n+ var nativeOffSpy = this.spy(nativeEmitter, 'removeListener');\nfunction resetSpies() {\nwifiOnSpy.reset();\n@@ -279,7 +275,7 @@ test('#start subscribes to the WiFi infrastructure events and #stop ' +\n.then(function () {\nt.end();\n});\n- }\n+ })\n);\ntest('does not emit duplicate discoveryAdvertisingStateUpdate',\n@@ -288,8 +284,8 @@ test('does not emit duplicate discoveryAdvertisingStateUpdate',\n// the native layer\nreturn global.NETWORK_TYPE !== ThaliMobile.networkTypes.WIFI;\n},\n- function (t) {\n- var spy = sinon.spy();\n+ tape.sinonTest(function (t) {\n+ var spy = this.spy();\nThaliMobile.start(express.Router()).then(function () {\nreturn ThaliMobile.startListeningForAdvertisements();\n}).then(function () {\n@@ -323,12 +319,12 @@ test('does not emit duplicate discoveryAdvertisingStateUpdate',\n'discoveryAdvertisingStateUpdateNonTCP', testStatus\n);\n});\n- }\n+ })\n);\n-test('does not send duplicate availability changes', function (t) {\n+test('does not send duplicate availability changes', tape.sinonTest(function (t) {\nvar nativePeer = generateLowerLevelPeers().nativePeer;\n- var spy = sinon.spy(ThaliMobile.emitter, 'emit');\n+ var spy = this.spy(ThaliMobile.emitter, 'emit');\nemitNativePeerAvailability(nativePeer);\nprocess.nextTick(function () {\nt.equals(spy.callCount, 1, 'should be called once');\n@@ -339,7 +335,7 @@ test('does not send duplicate availability changes', function (t) {\nt.end();\n});\n});\n-});\n+}));\ntest('can get the network status', function (t) {\nThaliMobile.getNetworkStatus()\n@@ -365,14 +361,12 @@ test('wifi peer is marked unavailable if announcements stop',\nfunction () {\nreturn global.NETWORK_TYPE !== ThaliMobile.networkTypes.WIFI;\n},\n- function (t) {\n- // Store the original threshold so that it can be restored\n- // at the end of the test.\n- var originalThreshold = thaliConfig.TCP_PEER_UNAVAILABILITY_THRESHOLD;\n+ tape.sinonTest(function (t) {\n// Make the threshold a bit shorter so that the test doesn't\n// have to wait for so long.\n- thaliConfig.TCP_PEER_UNAVAILABILITY_THRESHOLD =\n- thaliConfig.SSDP_ADVERTISEMENT_INTERVAL * 2;\n+ var threshold = thaliConfig.SSDP_ADVERTISEMENT_INTERVAL * 2;\n+ this.stub(thaliConfig, 'TCP_PEER_UNAVAILABILITY_THRESHOLD', threshold);\n+\nvar testPeerIdentifier = uuid.v4();\nvar testServerHostAddress = randomstring.generate({\ncharset: 'hex', // to get lowercase chars for the host address\n@@ -393,7 +387,7 @@ test('wifi peer is marked unavailable if announcements stop',\ngeneration: 0\n}));\n- var spy = sinon.spy();\n+ var spy = this.spy();\nvar availabilityChangedHandler = function (peer) {\nif (peer.peerIdentifier !== testPeerIdentifier) {\nreturn;\n@@ -409,7 +403,6 @@ test('wifi peer is marked unavailable if announcements stop',\nThaliMobile.emitter.removeListener('peerAvailabilityChanged',\navailabilityChangedHandler);\ntestServer.stop(function () {\n- thaliConfig.TCP_PEER_UNAVAILABILITY_THRESHOLD = originalThreshold;\nt.end();\n});\n}\n@@ -426,17 +419,15 @@ test('wifi peer is marked unavailable if announcements stop',\n// Handler above should get called.\n});\n});\n- }\n+ })\n);\ntest('native peer should be removed if no availability updates ' +\n'were received during availability timeout',\n- function (t) {\n- var originalThreshold = thaliConfig.NON_TCP_PEER_UNAVAILABILITY_THRESHOLD;\n+ tape.sinonTest(function (t) {\n// Make the threshold a bit shorter so that the test doesn't\n// have to wait for so long.\n- thaliConfig.NON_TCP_PEER_UNAVAILABILITY_THRESHOLD = 100;\n-\n+ this.stub(thaliConfig, 'NON_TCP_PEER_UNAVAILABILITY_THRESHOLD', 100);\nt.timeoutAfter(thaliConfig.NON_TCP_PEER_UNAVAILABILITY_THRESHOLD * 3);\nvar nativePeer = generateLowerLevelPeers().nativePeer;\n@@ -455,8 +446,6 @@ test('native peer should be removed if no availability updates ' +\ncase 2:\nt.equal(peerStatus.peerAvailable, false,\n'peer is not availabel because it was too silent');\n- // restore everything\n- thaliConfig.NON_TCP_PEER_UNAVAILABILITY_THRESHOLD = originalThreshold;\nThaliMobile.emitter\n.removeListener('peerAvailabilityChanged', availabilityHandler);\nt.end();\n@@ -468,7 +457,7 @@ test('native peer should be removed if no availability updates ' +\nThaliMobile.start(express.Router()).then(function () {\nemitNativePeerAvailability(nativePeer);\n});\n- }\n+ })\n);\ntest('peerAvailabilityChanged - peer added/removed to/from cache (native)',\n@@ -724,15 +713,13 @@ test('native available - peer with the same port and generation but with ' +\nfunction () {\nreturn !platform.isAndroid;\n},\n- function (t) {\n+ tape.sinonTest(function (t) {\nvar nativePeer = generateLowerLevelPeers().nativePeer;\nvar callCount = 0;\n// make update window shorter because nobody wants to wait 51 seconds for\n// test to complete\n- var originalUpdateWindow = thaliConfig.UPDATE_WINDOWS_FOREGROUND_MS;\n- thaliConfig.UPDATE_WINDOWS_FOREGROUND_MS = 0.1;\n-\n+ this.stub(thaliConfig, 'UPDATE_WINDOWS_FOREGROUND_MS', 0.1);\nt.timeoutAfter(thaliConfig.UPDATE_WINDOWS_FOREGROUND_MS * 1000);\nvar availabilityHandler = function (peerStatus) {\n@@ -761,7 +748,6 @@ test('native available - peer with the same port and generation but with ' +\nThaliMobile.emitter.on('peerAvailabilityChanged', availabilityHandler);\nfunction end() {\n- thaliConfig.UPDATE_WINDOWS_FOREGROUND_MS = originalUpdateWindow;\nThaliMobile.emitter\n.removeListener('peerAvailabilityChanged', availabilityHandler);\nt.end();\n@@ -769,7 +755,7 @@ test('native available - peer with the same port and generation but with ' +\nnativePeer.generation = 2;\nemitNativePeerAvailability(nativePeer);\n- }\n+ })\n);\ntest('native available - peer with greater generation is cached (MPCF)',\n@@ -1275,7 +1261,7 @@ test('multiconnect failure - new peer is ignored (MPCF)',\n// return !platform.isIOS;\nreturn true;\n},\n- function (t) {\n+ tape.sinonTest(function (t) {\nvar nativePeer = generateLowerLevelPeers().nativePeer;\nvar failedPeer = {\n@@ -1283,7 +1269,7 @@ test('multiconnect failure - new peer is ignored (MPCF)',\nconnectionType: getNativeConnectionType()\n};\n- var availabilityHandler = sinon.spy();\n+ var availabilityHandler = this.spy();\nfunction end() {\nvar cache = ThaliMobile._getPeerAvailabilities();\n@@ -1302,7 +1288,7 @@ test('multiconnect failure - new peer is ignored (MPCF)',\nThaliMobileNativeWrapper.emitter.emit('failedNativeConnection', failedPeer);\nend();\n- }\n+ })\n);\ntest('multiconnect failure - cached peer fires peerAvailabilityChanged (MPCF)',\n@@ -1572,7 +1558,7 @@ test('#getPeerHostInfo - returns discovered cached native peer and calls ' +\nfunction () {\nreturn !platform.isIOS;\n},\n- function (t) {\n+ tape.sinonTest(function (t) {\nvar peer = {\npeerIdentifier: 'foo',\npeerAvailable: true,\n@@ -1581,7 +1567,7 @@ test('#getPeerHostInfo - returns discovered cached native peer and calls ' +\n};\nvar resolvedPortNumber = 12345;\n- var multiConnectStub = sinon.stub(\n+ var multiConnectStub = this.stub(\nThaliMobileNativeWrapper,\n'_multiConnect',\nfunction (peerId) {\n@@ -1607,10 +1593,9 @@ test('#getPeerHostInfo - returns discovered cached native peer and calls ' +\n})\n.catch(t.fail)\n.then(function () {\n- multiConnectStub.restore();\nt.end();\n});\n- }\n+ })\n);\ntest('#getPeerHostInfo - returns discovered cached wifi peer',\n@@ -1672,8 +1657,10 @@ test('#disconnect delegates native peers to the native wrapper',\nfunction () {\nreturn global.NETWORK_TYPE === ThaliMobile.networkTypes.WIFI;\n},\n- function (t) {\n+ tape.sinonTest(function (t) {\nvar nativePeer = generateLowerLevelPeers().nativePeer;\n+ var nativeDisconnectSpy =\n+ this.spy(ThaliMobileNativeWrapper, 'disconnect');\nvar availabilityHandler = function (peerStatus) {\nif (peerStatus.peerIdentifier !== nativePeer.peerIdentifier) {\n@@ -1682,9 +1669,6 @@ test('#disconnect delegates native peers to the native wrapper',\nThaliMobile.emitter\n.removeListener('peerAvailabilityChanged', availabilityHandler);\n- var nativeDisconnectSpy =\n- sinon.spy(ThaliMobileNativeWrapper, 'disconnect');\n-\nThaliMobile\n.disconnect(\nnativePeer.peerIdentifier,\n@@ -1703,7 +1687,6 @@ test('#disconnect delegates native peers to the native wrapper',\n), 'native wrapper `disconnect` called with peer data');\n})\n.then(function () {\n- nativeDisconnectSpy.restore();\nt.end();\n});\n};\n@@ -1713,7 +1696,7 @@ test('#disconnect delegates native peers to the native wrapper',\nThaliMobile.start(express.Router()).then(function () {\nemitNativePeerAvailability(nativePeer);\n});\n- }\n+ })\n);\ntest('network changes emitted correctly',\n@@ -2033,7 +2016,7 @@ test('If a peer is not available (and hence is not in the thaliMobile cache)' +\nreturn !platform.isAndroid ||\nglobal.NETWORK_TYPE !== ThaliMobile.networkTypes.NATIVE;\n},\n- function (t) {\n+ tape.sinonTest(function (t) {\nvar somePeerIdentifier = uuid.v4();\nvar socket;\n@@ -2079,7 +2062,7 @@ test('If a peer is not available (and hence is not in the thaliMobile cache)' +\ncleanUp();\nreturn Promise.resolve();\n}\n- sinon.stub(ThaliMobileNativeWrapper, 'disconnect', disconnect);\n+ this.stub(ThaliMobileNativeWrapper, 'disconnect', disconnect);\nThaliMobile.start(\nexpress.Router(),\n@@ -2107,7 +2090,7 @@ test('If a peer is not available (and hence is not in the thaliMobile cache)' +\nThaliMobileNativeWrapper.terminateListener = originalListener;\ncleanUp();\n});\n- }\n+ })\n);\ntest('does not fire duplicate events after peer listener recreation',\n@@ -2262,8 +2245,8 @@ test('peer should be found once after listening and discovery started',\nfunction () {\nreturn global.NETWORK_TYPE !== ThaliMobile.networkTypes.WIFI;\n},\n-function (t) {\n- var spy = sinon.spy();\n+tape.sinonTest(function (t) {\n+ var spy = this.spy();\nvar availabilityChangedHandler = function (peer) {\n// Only count changes that mark peer becoming available.\nif (peer.hostAddress !== null && peer.portNumber !== null) {\n@@ -2298,7 +2281,7 @@ function (t) {\ndone();\n}, timeout);\n});\n-});\n+}));\nvar participantState = {\nrunning: 'running',\n" }, { "change_type": "MODIFY", "old_path": "test/www/jxcore/runTests.js", "new_path": "test/www/jxcore/runTests.js", "diff": "@@ -13,6 +13,12 @@ if (!process.env.SSDP_NT) {\nlength: 'http://www.thaliproject.org/ssdp'.length\n});\n}\n+// Override sinon timers\n+// issue https://github.com/thaliproject/jxcore/issues/86\n+var sinon = require('sinon');\n+sinon.config = {\n+ useFakeTimers: false\n+};\nvar thaliTape = require('./lib/thaliTape');\nvar testUtils = require('./lib/testUtils');\n" } ]
JavaScript
MIT License
thaliproject/thali_cordovaplugin
Update tests with sandbox (testThaliManager, testThaliMobile). Update sinon config using sandbox with issue (https://github.com/thaliproject/jxcore/issues/86)
675,378
24.03.2017 14:54:47
-10,800
7c2daf7921994e30cf014e0e178b69b5430824ae
Implement updates according to the PR 1825
[ { "change_type": "MODIFY", "old_path": "test/www/jxcore/bv_tests/testThaliMobile.js", "new_path": "test/www/jxcore/bv_tests/testThaliMobile.js", "diff": "@@ -2043,15 +2043,6 @@ test('does not fire duplicate events after peer listener recreation',\ntest('#stop should change peers', function (t) {\nvar spy = sinon.spy();\n- ThaliMobile.start(express.Router(), new Buffer('foo'),\n- ThaliMobile.networkTypes.BOTH)\n- .then(function () {\n- return ThaliMobile.startListeningForAdvertisements();\n- })\n- .then(function () {\n- var nativePeer = generateLowerLevelPeers().nativePeer;\n- var wifiPeer = generateLowerLevelPeers().wifiPeer;\n-\nvar availabilityHandler = function(peer) {\nspy();\n@@ -2073,7 +2064,7 @@ test('#stop should change peers', function (t) {\nThaliMobile._peerAvailabilities[connectionType]).length,\n0, 'No peers');\n});\n- t.end();\n+ finishTest();\n});\nbreak;\ndefault:\n@@ -2081,13 +2072,28 @@ test('#stop should change peers', function (t) {\n}\n};\n+ function finishTest() {\n+ ThaliMobile.emitter\n+ .removeListener('peerAvailabilityChanged', availabilityHandler);\n+ t.end();\n+ }\n+\n+ ThaliMobile.start(express.Router(), new Buffer('foo'),\n+ ThaliMobile.networkTypes.BOTH)\n+ .then(function () {\n+ return ThaliMobile.startListeningForAdvertisements();\n+ })\n+ .then(function () {\n+ var nativePeer = generateLowerLevelPeers().nativePeer;\n+ var wifiPeer = generateLowerLevelPeers().wifiPeer;\n+\nThaliMobile.emitter.on('peerAvailabilityChanged', availabilityHandler);\nemitNativePeerAvailability(nativePeer);\nemitWifiPeerAvailability(wifiPeer);\n})\n.catch(function (err) {\nt.fail('Failed out with ' + err);\n- t.end();\n+ finishTest();\n});\n});\n" }, { "change_type": "MODIFY", "old_path": "thali/NextGeneration/thaliWifiInfrastructure.js", "new_path": "thali/NextGeneration/thaliWifiInfrastructure.js", "diff": "@@ -773,28 +773,26 @@ function (newStatus) {\nThaliWifiInfrastructure.prototype._hadlePeerAvailabilityWatchers =\nfunction (peer) {\n+ var peerIdentifier = peer.peerIdentifier;\nif (peer.hostAddress && peer.portNumber) {\n- this._addAvailabilityWatcherToPeerIfNotExist(peer);\n+ this._addAvailabilityWatcherToPeerIfNotExist(peerIdentifier);\n} else {\n- this._removeAvailabilityWatcherFromPeerIfExists(peer);\n+ this._removeAvailabilityWatcherFromPeerIfExists(peerIdentifier);\n}\n};\nThaliWifiInfrastructure.prototype._isAvailabilityWatcherForPeerExist =\n-function (peer) {\n- var peerIdentifier = peer.peerIdentifier;\n-\n+function (peerIdentifier) {\nreturn !!(this.peerAvailabilities.watchers &&\nthis.peerAvailabilities.watchers[peerIdentifier]);\n};\nThaliWifiInfrastructure.prototype._watchForPeerAvailability =\n-function (peer) {\n+function (peerIdentifier) {\nvar now = Date.now();\nvar unavailabilityThreshold =\nthaliConfig.TCP_PEER_UNAVAILABILITY_THRESHOLD;\n- var peerIdentifier = peer.peerIdentifier;\n// If the time from the latest availability advertisement doesn't\n// exceed the threshold, no need to do anything.\n@@ -803,7 +801,7 @@ function (peer) {\nreturn;\n}\n- this._removeAvailabilityWatcherFromPeerIfExists(peer);\n+ this._removeAvailabilityWatcherFromPeerIfExists(peerIdentifier);\nthis.emit('wifiPeerAvailabilityChanged', {\npeerIdentifier: peerIdentifier,\ngeneration: null,\n@@ -814,13 +812,11 @@ function (peer) {\nThaliWifiInfrastructure.prototype._addAvailabilityWatcherToPeerIfNotExist =\n-function (peer) {\n+function (peerIdentifier) {\nvar self = this;\n- var peerIdentifier = peer.peerIdentifier;\n-\nthis.peerAvailabilities.timers[peerIdentifier] = Date.now();\n- if (this._isAvailabilityWatcherForPeerExist(peer)) {\n+ if (this._isAvailabilityWatcherForPeerExist(peerIdentifier)) {\nreturn;\n}\n@@ -828,16 +824,14 @@ function (peer) {\nthaliConfig.TCP_PEER_UNAVAILABILITY_THRESHOLD;\nthis.peerAvailabilities.watchers[peerIdentifier] =\nsetInterval((self._watchForPeerAvailability).bind(self),\n- unavailabilityThreshold, peer);\n+ unavailabilityThreshold, peerIdentifier);\n};\nThaliWifiInfrastructure.prototype._removeAvailabilityWatcherFromPeerIfExists =\n-function (peer) {\n- if (!this._isAvailabilityWatcherForPeerExist(peer)) {\n+function (peerIdentifier) {\n+ if (!this._isAvailabilityWatcherForPeerExist(peerIdentifier)) {\nreturn;\n}\n- var peerIdentifier = peer.peerIdentifier;\n-\nvar interval = this.peerAvailabilities.watchers[peerIdentifier];\nclearInterval(interval);\n@@ -851,11 +845,7 @@ function() {\nvar self = this;\nObject.keys(this.peerAvailabilities.watchers)\n.forEach(function (peerIdentifier) {\n- var assumingPeer = {\n- peerIdentifier: peerIdentifier\n- };\n-\n- self._removeAvailabilityWatcherFromPeerIfExists(assumingPeer);\n+ self._removeAvailabilityWatcherFromPeerIfExists(peerIdentifier);\n});\n};\n" } ]
JavaScript
MIT License
thaliproject/thali_cordovaplugin
Implement updates according to the PR 1825
675,378
24.03.2017 15:31:54
-10,800
2ae155d6581aa3d17b055baad6c7396cc3b47018
Update tests for ThaliMobileNativeWrapper with sinon
[ { "change_type": "MODIFY", "old_path": "test/www/jxcore/bv_tests/testThaliMobileNativeWrapper.js", "new_path": "test/www/jxcore/bv_tests/testThaliMobileNativeWrapper.js", "diff": "@@ -346,7 +346,7 @@ test('all services are stopped when we call stop', function (t) {\nvar verifyCallWithArguments = function (t, callName, parameters) {\nvar mockServersManager = {};\n- var spy = sinon.spy();\n+ var spy = this.spy();\nvar serversManagerEquivalentCallName = callName === '_terminateConnection' ?\n'terminateIncomingConnection' : 'terminateOutgoingConnection';\nmockServersManager[serversManagerEquivalentCallName] = function () {\n@@ -369,9 +369,9 @@ var verifyCallWithArguments = function (t, callName, parameters) {\ntest('make sure terminateConnection is properly hooked up',\ntestUtils.skipOnIOS,\n- function (t) {\n- verifyCallWithArguments(t, '_terminateConnection', ['connection-id']);\n- }\n+ tape.sinonTest(function (t) {\n+ verifyCallWithArguments.call(this, t, '_terminateConnection', ['connection-id']);\n+ })\n);\ntest('make sure terminateConnection is return error if we get called on iOS',\n@@ -393,9 +393,9 @@ test('make sure terminateConnection is return error if we get called on iOS',\ntest('make sure terminateListener is properly hooked up',\ntestUtils.skipOnIOS,\n- function (t) {\n- verifyCallWithArguments(t, '_terminateListener', ['peer-id', 8080]);\n- }\n+ tape.sinonTest(function (t) {\n+ verifyCallWithArguments.call(this, t, '_terminateListener', ['peer-id', 8080]);\n+ })\n);\ntest('make sure terminateListener is return error if we get called on iOS',\n@@ -848,11 +848,11 @@ test('can still do HTTP requests between peers with coordinator', function (t) {\ntest('calls correct starts when network changes',\ntestUtils.skipOnIOS, // uses toggleBluetooth\n- function (t) {\n+ tape.sinonTest(function (t) {\nvar listeningSpy =\n- sinon.spy(thaliMobileNativeWrapper, 'startListeningForAdvertisements');\n+ this.spy(thaliMobileNativeWrapper, 'startListeningForAdvertisements');\nvar advertisingSpy =\n- sinon.spy(thaliMobileNativeWrapper, 'startUpdateAdvertisingAndListening');\n+ this.spy(thaliMobileNativeWrapper, 'startUpdateAdvertisingAndListening');\nreturn thaliMobileNativeWrapper.start(express.Router())\n.then(function () {\n@@ -905,11 +905,9 @@ test('calls correct starts when network changes',\nreturn thaliMobileNativeWrapper.stop();\n})\n.then(function () {\n- listeningSpy.restore();\n- advertisingSpy.restore();\nt.end();\n});\n- }\n+ })\n);\n// The connection cut is implemented as a separate test instead\n" } ]
JavaScript
MIT License
thaliproject/thali_cordovaplugin
Update tests for ThaliMobileNativeWrapper with sinon
675,378
24.03.2017 18:06:19
-10,800
32b0ee13cbc4e8338e42c9e28f607470b1361e69
Update tests for thaliMobileNativeWrapper and thaliNotificationAction
[ { "change_type": "MODIFY", "old_path": "test/www/jxcore/bv_tests/testThaliMobileNativeWrapper.js", "new_path": "test/www/jxcore/bv_tests/testThaliMobileNativeWrapper.js", "diff": "@@ -8,7 +8,6 @@ if (global.NETWORK_TYPE === ThaliMobile.networkTypes.WIFI) {\nvar express = require('express');\nvar net = require('net');\nvar Promise = require('lie');\n-var sinon = require('sinon');\nvar testUtils = require('../lib/testUtils.js');\nif (typeof Mobile === 'undefined') {\n@@ -1043,13 +1042,13 @@ test('We fire nonTCPPeerAvailabilityChangedEvent with the same generation ' +\nreturn true;\n// return platform.isIOS\n},\n- function (t) {\n+ tape.sinonTest(function (t) {\ntrivialEndToEndTest(t, function (peerId) {\nvar beforeRecreatePeer = null;\nvar afterRecreatePeer = null;\nvar isKilled = false;\nvar serversManager = thaliMobileNativeWrapper._getServersManager();\n- var smEmitSpy = sinon.spy(serversManager, 'emit');\n+ var smEmitSpy = this.spy(serversManager, 'emit');\nfunction finishTest() {\nt.ok(isKilled, 'mux must be destroyed');\n@@ -1083,7 +1082,6 @@ test('We fire nonTCPPeerAvailabilityChangedEvent with the same generation ' +\n'nonTCPPeerAvailabilityChangedEvent',\nnonTCPAvailableHandler\n);\n- smEmitSpy.restore();\nt.end();\n}\n@@ -1116,5 +1114,5 @@ test('We fire nonTCPPeerAvailabilityChangedEvent with the same generation ' +\nthaliMobileNativeWrapper.emitter\n.on('nonTCPPeerAvailabilityChangedEvent', nonTCPAvailableHandler);\n});\n- }\n+ })\n);\n" }, { "change_type": "MODIFY", "old_path": "test/www/jxcore/bv_tests/testThaliNotificationAction.js", "new_path": "test/www/jxcore/bv_tests/testThaliNotificationAction.js", "diff": "var tape = require('../lib/thaliTape');\nvar express = require('express');\nvar crypto = require('crypto');\n-var sinon = require('sinon');\nvar Promise = require('lie');\nvar testUtils = require('../lib/testUtils.js');\nvar httpTester = require('../lib/httpTester.js');\n@@ -109,11 +108,8 @@ var addressBookCallback = function (unencryptedKeyId) {\nreturn null;\n};\n-var sandbox = null;\n-\nvar test = tape({\nsetup: function (t) {\n- sandbox = sinon.sandbox.create();\nglobals = new GlobalVariables();\nglobals.init()\n.then(function () {\n@@ -125,7 +121,6 @@ var test = tape({\n});\n},\nteardown: function (t) {\n- sandbox.restore();\nglobals.kill()\n.then(function () {\nt.end();\n@@ -137,14 +132,14 @@ var test = tape({\n}\n});\n-test('Test BEACONS_RETRIEVED_AND_PARSED locally', function (t) {\n+test('Test BEACONS_RETRIEVED_AND_PARSED locally', tape.sinonTest(function (t) {\nt.plan(8);\nhttpTester.runServer(globals.expressRouter,\nthaliConfig.NOTIFICATION_BEACON_PATH,\n200, globals.preambleAndBeacons, 1);\n- sandbox.stub(ThaliMobile, 'getPeerHostInfo')\n+ this.stub(ThaliMobile, 'getPeerHostInfo')\n.withArgs(globals.testPeer.peerIdentifier, globals.testPeer.connectionType)\n.returns(Promise.resolve(globals.testPeerHostInfo));\n@@ -190,15 +185,15 @@ test('Test BEACONS_RETRIEVED_AND_PARSED locally', function (t) {\n.catch(function (failure) {\nt.fail(failure.stack);\n});\n-});\n+}));\n-test('Test HTTP_BAD_RESPONSE locally', function (t) {\n+test('Test HTTP_BAD_RESPONSE locally', tape.sinonTest(function (t) {\nt.plan(2);\nhttpTester.runServer(globals.expressRouter,\nthaliConfig.NOTIFICATION_BEACON_PATH, 503, 'hello', 1);\n- sandbox.stub(ThaliMobile, 'getPeerHostInfo')\n+ this.stub(ThaliMobile, 'getPeerHostInfo')\n.withArgs(globals.testPeer.peerIdentifier, globals.testPeer.connectionType)\n.returns(Promise.resolve(globals.testPeerHostInfo));\n@@ -226,15 +221,15 @@ test('Test HTTP_BAD_RESPONSE locally', function (t) {\n.catch(function (err) {\nt.fail('Test failed:' + err.message);\n});\n-});\n+}));\n-test('Test NETWORK_PROBLEM locally', function (t) {\n+test('Test NETWORK_PROBLEM locally', tape.sinonTest(function (t) {\nt.plan(2);\ntestUtils.makeDomainUnresolvable('unresolvable_domain');\nglobals.testPeerHostInfo.hostAddress = 'unresolvable_domain';\n- sandbox.stub(ThaliMobile, 'getPeerHostInfo')\n+ this.stub(ThaliMobile, 'getPeerHostInfo')\n.withArgs(globals.testPeer.peerIdentifier, globals.testPeer.connectionType)\n.returns(Promise.resolve(globals.testPeerHostInfo));\n@@ -266,14 +261,14 @@ test('Test NETWORK_PROBLEM locally', function (t) {\n'reject reason should be: Could not establish TCP connection'\n);\n});\n-});\n+}));\n-test('Action fails when getPeerHostInfo fails', function (t) {\n+test('Action fails when getPeerHostInfo fails', tape.sinonTest(function (t) {\nt.plan(2);\nvar errorMessage = 'Unspecified error';\n- sandbox.stub(\n+ this.stub(\nThaliMobile,\n'getPeerHostInfo',\nfunction () {\n@@ -304,16 +299,16 @@ test('Action fails when getPeerHostInfo fails', function (t) {\n}).catch(function (err) {\nt.equals(err.message, errorMessage, 'correct error message');\n});\n-});\n+}));\n-test('Call the start two times', function (t) {\n+test('Call the start two times', tape.sinonTest(function (t) {\nt.plan(3);\nhttpTester.runServer(globals.expressRouter,\nthaliConfig.NOTIFICATION_BEACON_PATH,\n200, globals.preambleAndBeacons, 1);\n- sandbox.stub(ThaliMobile, 'getPeerHostInfo')\n+ this.stub(ThaliMobile, 'getPeerHostInfo')\n.withArgs(globals.testPeer.peerIdentifier, globals.testPeer.connectionType)\n.returns(Promise.resolve(globals.testPeerHostInfo));\n@@ -350,12 +345,12 @@ test('Call the start two times', function (t) {\n.catch(function (err) {\nt.equals(err.message, ThaliPeerAction.DOUBLE_START, 'Call start once');\n});\n-});\n+}));\n-test('Call the kill before calling the start', function (t) {\n+test('Call the kill before calling the start', tape.sinonTest(function (t) {\nt.plan(2);\n- sandbox.stub(ThaliMobile, 'getPeerHostInfo')\n+ this.stub(ThaliMobile, 'getPeerHostInfo')\n.withArgs(globals.testPeer.peerIdentifier, globals.testPeer.connectionType)\n.returns(Promise.resolve(globals.testPeerHostInfo));\n@@ -382,9 +377,9 @@ test('Call the kill before calling the start', function (t) {\nt.equals(err.message, ThaliPeerAction.START_AFTER_KILLED,\n'Start after killed');\n});\n-});\n+}));\n-test('Call the kill immediately after the start', function (t) {\n+test('Call the kill immediately after the start', tape.sinonTest(function (t) {\nt.plan(2);\n// Sets 2000 milliseconds delay for request handling.\n@@ -393,7 +388,7 @@ test('Call the kill immediately after the start', function (t) {\nglobals.testPeerHostInfo.suggestedTCPTimeout = 1;\n- sandbox.stub(ThaliMobile, 'getPeerHostInfo')\n+ this.stub(ThaliMobile, 'getPeerHostInfo')\n.withArgs(globals.testPeer.peerIdentifier, globals.testPeer.connectionType)\n.returns(Promise.resolve(globals.testPeerHostInfo));\n@@ -424,9 +419,10 @@ test('Call the kill immediately after the start', function (t) {\n});\nact.kill();\n-});\n+}));\n-test('Call the kill while waiting a response from the server', function (t) {\n+test('Call the kill while waiting a response from the server',\n+ tape.sinonTest(function (t) {\nt.plan(2);\n// Sets 10000 milliseconds delay for request handling.\n@@ -436,7 +432,7 @@ test('Call the kill while waiting a response from the server', function (t) {\n// Sets 10000 milliseconds TCP timeout.\nglobals.testPeerHostInfo.suggestedTCPTimeout = 10000;\n- sandbox.stub(ThaliMobile, 'getPeerHostInfo')\n+ this.stub(ThaliMobile, 'getPeerHostInfo')\n.withArgs(globals.testPeer.peerIdentifier, globals.testPeer.connectionType)\n.returns(Promise.resolve(globals.testPeerHostInfo));\n@@ -476,9 +472,11 @@ test('Call the kill while waiting a response from the server', function (t) {\nsetTimeout( function () {\nact.kill();\n}, 2000);\n-});\n+ })\n+);\n-test('Test to exceed the max content size locally', function (t) {\n+test('Test to exceed the max content size locally',\n+ tape.sinonTest(function (t) {\nt.plan(2);\nvar buffer = new Buffer(1024);\n@@ -491,7 +489,7 @@ test('Test to exceed the max content size locally', function (t) {\n// Sets 10000 milliseconds TCP timeout.\nglobals.testPeerHostInfo.suggestedTCPTimeout = 10000;\n- sandbox.stub(ThaliMobile, 'getPeerHostInfo')\n+ this.stub(ThaliMobile, 'getPeerHostInfo')\n.withArgs(globals.testPeer.peerIdentifier, globals.testPeer.connectionType)\n.returns(Promise.resolve(globals.testPeerHostInfo));\n@@ -519,11 +517,12 @@ test('Test to exceed the max content size locally', function (t) {\n.catch(function (failure) {\nt.fail('Test failed:' + failure);\n});\n-});\n+ })\n+);\ntest('Close the server socket while the client is waiting a response ' +\n'from the server. Local test.',\n- function (t) {\n+ tape.sinonTest(function (t) {\nt.plan(2);\n// Sets 10000 milliseconds delay for request handling.\n@@ -533,7 +532,7 @@ test('Close the server socket while the client is waiting a response ' +\n// Sets 10000 milliseconds TCP timeout.\nglobals.testPeerHostInfo.suggestedTCPTimeout = 10000;\n- sandbox.stub(ThaliMobile, 'getPeerHostInfo')\n+ this.stub(ThaliMobile, 'getPeerHostInfo')\n.withArgs(\nglobals.testPeer.peerIdentifier,\nglobals.testPeer.connectionType\n@@ -579,11 +578,12 @@ test('Close the server socket while the client is waiting a response ' +\nglobals.expressServer = null;\n});\n}, 2000);\n- });\n+ })\n+);\ntest('Close the client socket while the client is waiting a response ' +\n'from the server. Local test.',\n- function (t) {\n+ tape.sinonTest(function (t) {\nt.plan(2);\n// Sets 10000 milliseconds delay for request handling.\n@@ -593,7 +593,7 @@ test('Close the client socket while the client is waiting a response ' +\n// Sets 10000 milliseconds TCP timeout.\nglobals.testPeerHostInfo.suggestedTCPTimeout = 10000;\n- sandbox.stub(ThaliMobile, 'getPeerHostInfo')\n+ this.stub(ThaliMobile, 'getPeerHostInfo')\n.withArgs(\nglobals.testPeer.peerIdentifier,\nglobals.testPeer.connectionType\n@@ -639,4 +639,5 @@ test('Close the client socket while the client is waiting a response ' +\n});\n});\n}, 2000);\n- });\n+ })\n+);\n" }, { "change_type": "MODIFY", "old_path": "test/www/jxcore/lib/SinonTest.js", "new_path": "test/www/jxcore/lib/SinonTest.js", "diff": "@@ -16,16 +16,20 @@ function SinonTest (callback) {\nvar args = slice.call(arguments);\nvar tapeEnd = t.end;\nvar exception, result;\n+ var ok;\nif (typeof t.end === \"function\") {\n- t.end = function end(res) {\n- if (res) {\n+ t.on(\"result\", function(res) {\n+ ok = res.ok;\n+ })\n+\n+ t.on(\"end\", function(res) {\n+ if (!ok) {\nsandbox.restore();\n} else {\nsandbox.verifyAndRestore();\n}\n- tapeEnd(res);\n- };\n+ })\n}\ntry {\n" } ]
JavaScript
MIT License
thaliproject/thali_cordovaplugin
Update tests for thaliMobileNativeWrapper and thaliNotificationAction
675,378
27.03.2017 10:52:48
-10,800
657239bfba59934bc8e49835a21f6caf678cda44
Update ThaliWifiInfrastructure with minor fixes.
[ { "change_type": "MODIFY", "old_path": "thali/NextGeneration/thaliWifiInfrastructure.js", "new_path": "thali/NextGeneration/thaliWifiInfrastructure.js", "diff": "@@ -19,12 +19,11 @@ var PromiseQueue = require('./promiseQueue');\nvar USN = require('./utils/usn');\nvar platform = require('./utils/platform');\nvar common = require('./utils/common');\n+var thaliMobileNativeWrapper = require('./thaliMobileNativeWrapper');\nvar enqueued = common.enqueuedMethod;\nvar enqueuedAtTop = common.enqueuedAtTopMethod;\n-var thaliMobileNativeWrapper = require('./thaliMobileNativeWrapper');\n-\nvar muteRejection = (function () {\nfunction returnNull () { return null; }\nfunction returnArg (arg) { return arg; }\n@@ -681,7 +680,7 @@ ThaliWifiInfrastructure.prototype._setUpEvents = function() {\nself.listener.on('stateChange', emitStateUpdate);\nself.listener.on('wifiPeerAvailabilityChanged', function (peer) {\n- self._hadlePeerAvailabilityWatchers(peer);\n+ self._handlePeerAvailabilityWatchers(peer);\nself.emit('wifiPeerAvailabilityChanged', peer);\n});\n};\n@@ -771,23 +770,12 @@ function (newStatus) {\n});\n};\n-ThaliWifiInfrastructure.prototype._hadlePeerAvailabilityWatchers =\n-function (peer) {\n- var peerIdentifier = peer.peerIdentifier;\n- if (peer.hostAddress && peer.portNumber) {\n- this._addAvailabilityWatcherToPeerIfNotExist(peerIdentifier);\n- } else {\n- this._removeAvailabilityWatcherFromPeerIfExists(peerIdentifier);\n- }\n-};\n-\n-ThaliWifiInfrastructure.prototype._isAvailabilityWatcherForPeerExist =\n+ThaliWifiInfrastructure.prototype._doesAvailabilityWatcherForPeerExist =\nfunction (peerIdentifier) {\nreturn !!(this.peerAvailabilities.watchers &&\nthis.peerAvailabilities.watchers[peerIdentifier]);\n};\n-\nThaliWifiInfrastructure.prototype._watchForPeerAvailability =\nfunction (peerIdentifier) {\nvar now = Date.now();\n@@ -810,26 +798,25 @@ function (peerIdentifier) {\n});\n};\n-\nThaliWifiInfrastructure.prototype._addAvailabilityWatcherToPeerIfNotExist =\nfunction (peerIdentifier) {\nvar self = this;\n- this.peerAvailabilities.timers[peerIdentifier] = Date.now();\n+ self.peerAvailabilities.timers[peerIdentifier] = Date.now();\n- if (this._isAvailabilityWatcherForPeerExist(peerIdentifier)) {\n+ if (self._doesAvailabilityWatcherForPeerExist(peerIdentifier)) {\nreturn;\n}\nvar unavailabilityThreshold =\nthaliConfig.TCP_PEER_UNAVAILABILITY_THRESHOLD;\n- this.peerAvailabilities.watchers[peerIdentifier] =\n+ self.peerAvailabilities.watchers[peerIdentifier] =\nsetInterval((self._watchForPeerAvailability).bind(self),\nunavailabilityThreshold, peerIdentifier);\n};\nThaliWifiInfrastructure.prototype._removeAvailabilityWatcherFromPeerIfExists =\nfunction (peerIdentifier) {\n- if (!this._isAvailabilityWatcherForPeerExist(peerIdentifier)) {\n+ if (!this._doesAvailabilityWatcherForPeerExist(peerIdentifier)) {\nreturn;\n}\nvar interval = this.peerAvailabilities.watchers[peerIdentifier];\n@@ -839,7 +826,6 @@ function (peerIdentifier) {\ndelete this.peerAvailabilities.timers[peerIdentifier];\n};\n-\nThaliWifiInfrastructure.prototype._removeAllAvailabilityWatchersFromPeers =\nfunction() {\nvar self = this;\n@@ -849,6 +835,16 @@ function() {\n});\n};\n+ThaliWifiInfrastructure.prototype._handlePeerAvailabilityWatchers =\n+function (peer) {\n+ var peerIdentifier = peer.peerIdentifier;\n+ if (peer.hostAddress && peer.portNumber) {\n+ this._addAvailabilityWatcherToPeerIfNotExist(peerIdentifier);\n+ } else {\n+ this._removeAvailabilityWatcherFromPeerIfExists(peerIdentifier);\n+ }\n+};\n+\n/**\n* This method MUST be called before any other method here other than\n* registering for events on the emitter. This method only registers the router\n" } ]
JavaScript
MIT License
thaliproject/thali_cordovaplugin
Update ThaliWifiInfrastructure with minor fixes.
675,384
27.03.2017 16:42:56
-10,800
82d90ee36a3ffab5b86e89165666055fc9eb9681
Put NSNull instead of nil to didResolveMultiConnectWithSyncValue method
[ { "change_type": "MODIFY", "old_path": "src/ios/AppContext.swift", "new_path": "src/ios/AppContext.swift", "diff": "@@ -248,8 +248,17 @@ extension PeerAvailability {\nfileprivate func handleMultiConnectResolved(withSyncValue value: String, port: UInt16?,\nerror: Error?) {\n- let errorValue = error != nil ? errorDescription(error!) : nil\n- let listeningPort = port != nil ? NSNumber(value: port! as UInt16) : nil\n+ var errorValue: NSObject = NSNull()\n+ var listeningPort: NSObject = NSNull()\n+\n+ if let error = error {\n+ errorValue = error.localizedDescription as NSString\n+ }\n+\n+ if let port = port {\n+ listeningPort = NSNumber(value: port as UInt16)\n+ }\n+\ndelegate?.context(self,\ndidResolveMultiConnectWithSyncValue: value,\nerror: errorValue as NSObject?,\n@@ -260,7 +269,7 @@ extension PeerAvailability {\nerror: Error?) {\nlet parameters = [\n\"peerIdentifier\" : identifier,\n- \"error\" : error != nil ? errorDescription(error!) : nil\n+ \"error\" : error?.localizedDescription\n]\ndelegate?.context(self, didFailMultiConnectConnectionWith: jsonValue(parameters as AnyObject))\n}\n@@ -446,10 +455,3 @@ extension AppContext: CBCentralManagerDelegate {\n\"startListeningForAdvertisements\"\n@objc open static let disconnect: String = \"disconnect\"\n}\n-\n-func errorDescription(_ error: Error) -> String {\n- if let thaliCoreError = error as? ThaliCoreError {\n- return thaliCoreError.rawValue\n- }\n- return (error as NSError).localizedDescription\n-}\n" }, { "change_type": "MODIFY", "old_path": "src/ios/Testing/AppContextTests.swift", "new_path": "src/ios/Testing/AppContextTests.swift", "diff": "@@ -288,10 +288,6 @@ class AppContextTests: XCTestCase {\nfunc testErrorDescription() {\nXCTAssertEqual(ThaliCoreError.IllegalPeerID.rawValue,\nerrorDescription(ThaliCoreError.IllegalPeerID))\n-\n- let unknownError = AppContextError.unknownError\n- XCTAssertEqual((unknownError as NSError).localizedDescription,\n- errorDescription(unknownError))\n}\nfunc testJsonValue() {\n" } ]
JavaScript
MIT License
thaliproject/thali_cordovaplugin
Put NSNull instead of nil to didResolveMultiConnectWithSyncValue method
675,378
28.03.2017 16:09:58
-10,800
de7a3d0a278ff0769957881fb10affb6c8b876a4
Update sinon's sandboxing functionality according to the pr 1847
[ { "change_type": "MODIFY", "old_path": "test/www/jxcore/bv_tests/testTests.js", "new_path": "test/www/jxcore/bv_tests/testTests.js", "diff": "@@ -34,15 +34,16 @@ var testObject = {\nlogger.debug('test spy method for global sinon sansbox');\n},\ntestStubMethod: function () {\n- return 'test stub method for global sinon sansbox'\n+ return 'test stub method for global sinon sansbox';\n}\n};\nvar testSanboxObject = testObject;\ntest('test sinon sansbox spy', tape.sinonTest(function (t) {\n- this.spy(testObject, 'testSpyMethod');\n- t.equal(testObject.testSpyMethod, testSanboxObject.testSpyMethod,\n+ var spy = this.spy(testObject, 'testSpyMethod');\n+ testObject.testSpyMethod();\n+ t.equal(spy.callCount, 1,\n'test sandbox spy works correctly');\nt.end();\n}));\n@@ -55,20 +56,26 @@ test('test sinon sansbox stub', tape.sinonTest(function (t) {\ntest('test sinon sansbox stub override', tape.sinonTest(function (t) {\nvar result = testObject.testStubMethod();\n- var stub = this.stub(testObject, 'testStubMethod', function () { return \"test\";});\n+ var stub = this.stub(testObject, 'testStubMethod', function () { return 'test';});\nt.notEqual(stub(), result, 'test sandbox stub works correctly');\nt.end();\n}));\ntest('test sinon sansbox mock', tape.sinonTest(function (t) {\nvar mock = this.mock(testObject);\n- mock.expects(\"testStubMethod\").twice();\n+ mock.expects('testStubMethod').twice();\ntestObject.testStubMethod();\ntestObject.testStubMethod();\nmock.verify();\nt.end();\n}));\n+test('test sinon sansbox restore after test end', tape.sinonTest(function (t) {\n+ var result = testObject.testStubMethod();\n+ t.equal(result, 'test stub method for global sinon sansbox', 'test restore');\n+ t.end();\n+}));\n+\nif (!tape.coordinated) {\nreturn;\n}\n" }, { "change_type": "MODIFY", "old_path": "test/www/jxcore/bv_tests/testThaliManager.js", "new_path": "test/www/jxcore/bv_tests/testThaliManager.js", "diff": "@@ -40,57 +40,57 @@ var test = tape({\n}\n});\n-function Mocks(t, sandboxObject) {\n+function Mocks(t, sandbox) {\n// All objects should be cloned in order to prevent\n// 'already wrapped' error by 'sinon.spy'.\nthis.t = t;\n- this.express = sandboxObject.spy(express);\n- this.expressPouchDB = sandboxObject.spy(expressPouchDB);\n- this.LevelDownPouchDB = sandboxObject.spy(testUtils.getLevelDownPouchDb());\n+ this.express = sandbox.spy(express);\n+ this.expressPouchDB = sandbox.spy(expressPouchDB);\n+ this.LevelDownPouchDB = sandbox.spy(testUtils.getLevelDownPouchDb());\nthis.ThaliMobile = extend({}, ThaliMobile);\n- this.MobileStart = sandboxObject.spy(this.ThaliMobile, 'start');\n- this.MobileStop = sandboxObject.spy(this.ThaliMobile, 'stop');\n+ this.MobileStart = sandbox.spy(this.ThaliMobile, 'start');\n+ this.MobileStop = sandbox.spy(this.ThaliMobile, 'stop');\n- this.MobileStartLA = sandboxObject.spy(\n+ this.MobileStartLA = sandbox.spy(\nthis.ThaliMobile, 'startListeningForAdvertisements'\n);\n- this.MobileStartUAA = sandboxObject.spy(\n+ this.MobileStartUAA = sandbox.spy(\nthis.ThaliMobile, 'startUpdateAdvertisingAndListening'\n);\n- this.Notification = sandboxObject.spy(\n+ this.Notification = sandbox.spy(\nThaliSendNotificationBasedOnReplication\n);\nthis.Notification.prototype = extend(\n{},\nThaliSendNotificationBasedOnReplication.prototype\n);\n- this.NotificationStart = sandboxObject.spy(\n+ this.NotificationStart = sandbox.spy(\nthis.Notification.prototype, 'start'\n);\n- this.NotificationStop = sandboxObject.spy(\n+ this.NotificationStop = sandbox.spy(\nthis.Notification.prototype, 'stop'\n);\n- this.Replication = sandboxObject.spy(\n+ this.Replication = sandbox.spy(\nThaliPullReplicationFromNotification\n);\nthis.Replication.prototype = extend(\n{},\nThaliPullReplicationFromNotification.prototype\n);\n- this.ReplicationStart = sandboxObject.spy(\n+ this.ReplicationStart = sandbox.spy(\nthis.Replication.prototype, 'start'\n);\n- this.ReplicationStop = sandboxObject.spy(\n+ this.ReplicationStop = sandbox.spy(\nthis.Replication.prototype, 'stop'\n);\n- this.Salti = sandboxObject.spy(Salti);\n+ this.Salti = sandbox.spy(Salti);\nthis.ThaliManager =\nproxyquire('thali/NextGeneration/thaliManager', {\n'./replication/thaliSendNotificationBasedOnReplication':\n" }, { "change_type": "MODIFY", "old_path": "test/www/jxcore/bv_tests/testThaliMobile.js", "new_path": "test/www/jxcore/bv_tests/testThaliMobile.js", "diff": "var ThaliMobile = require('thali/NextGeneration/thaliMobile');\nvar ThaliMobileNativeWrapper = require('thali/NextGeneration/thaliMobileNativeWrapper');\nvar ThaliMobileNative = require('thali/NextGeneration/thaliMobileNative');\n-var USN = require('thali/NextGeneration/utils/usn');\nvar thaliConfig = require('thali/NextGeneration/thaliConfig');\nvar tape = require('../lib/thaliTape');\nvar testUtils = require('../lib/testUtils.js');\nvar express = require('express');\nvar validations = require('thali/validations');\nvar uuid = require('uuid');\n-var nodessdp = require('node-ssdp');\nvar objectAssign = require('object-assign');\nvar randomstring = require('randomstring');\nvar logger = require('thali/ThaliLogger')('testThaliMobile');\n@@ -285,7 +283,6 @@ test('does not send duplicate availability changes', tape.sinonTest(function (t)\nemitNativePeerAvailability(nativePeer);\nprocess.nextTick(function () {\nt.equals(spy.callCount, 1, 'should not have been called more than once');\n- ThaliMobile.emitter.emit.restore();\nt.end();\n});\n});\n@@ -1401,7 +1398,7 @@ test('#getPeerHostInfo - returns discovered cached native peer and calls ' +\n};\nvar resolvedPortNumber = 12345;\n- var multiConnectStub = this.stub(\n+ this.stub(\nThaliMobileNativeWrapper,\n'_multiConnect',\nfunction (peerId) {\n@@ -1553,8 +1550,8 @@ test('network changes emitted correctly',\n// TODO Android can send event with 'wifi': 'off' and without\n// 'bssidName' and 'ssidName'.\n// t.equals(networkStatus.wifi, 'off', 'wifi should be off');\n- t.ok(networkStatus.bssidName == null, 'bssid should be null');\n- t.ok(networkStatus.ssidName == null, 'ssid should be null');\n+ t.ok(networkStatus.bssidName === null, 'bssid should be null');\n+ t.ok(networkStatus.ssidName === null, 'ssid should be null');\nresolve();\n}\nThaliMobile.emitter.once('networkChanged', networkChangedHandler);\n@@ -1892,7 +1889,6 @@ test('If a peer is not available (and hence is not in the thaliMobile cache)' +\nfunction disconnect (peerIdentifier) {\nt.equal(peerIdentifier, somePeerIdentifier, 'Peer still matches');\nt.ok(connectionErrorReceived, 'We got the connection error');\n- ThaliMobileNativeWrapper.disconnect.restore();\ncleanUp();\nreturn Promise.resolve();\n}\n@@ -2110,7 +2106,7 @@ test('If there are more then PEERS_LIMIT peers presented ' +\nThaliMobile._connectionTypePeersLimits[connectionTypes.TCP_NATIVE] =\nPEERS_LIMIT;\n- function finishTest (connectionType) {\n+ function finishTest () {\nThaliMobile._connectionTypePeersLimits\n[connectionTypes.MULTI_PEER_CONNECTIVITY_FRAMEWORK] =\nCURRENT_MULTI_PEER_CONNECTIVITY_FRAMEWORK_PEERS_LIMIT;\n" }, { "change_type": "MODIFY", "old_path": "test/www/jxcore/bv_tests/testThaliNotificationClient.js", "new_path": "test/www/jxcore/bv_tests/testThaliNotificationClient.js", "diff": "@@ -146,8 +146,8 @@ var test = tape({\n}\n});\n-function stubGetPeerHostInfo() {\n- return this.stub(\n+function stubGetPeerHostInfo(sandbox) {\n+ return sandbox.stub(\nThaliMobile,\n'getPeerHostInfo',\nfunction (peerIdentifier, connectionType) {\n@@ -164,8 +164,7 @@ test('Add two Peers.', tape.sinonTest(function (t) {\n// Expected result:\n// Two peers are added into the dictionary\n-\n- var getPeerHostInfoStub = stubGetPeerHostInfo.call(this);\n+ var getPeerHostInfoStub = stubGetPeerHostInfo(this);\nvar notificationClient =\nnew ThaliNotificationClient(globals.peerPoolInterfaceStub,\n@@ -231,8 +230,7 @@ test('TCP_NATIVE peer loses DNS', tape.sinonTest(function (t) {\n// 2. Event: connectionType is TCP_NATIVE, hostaddress is not set\n// Expected result: Peer will be removed from the dictionary\n-\n- var getPeerHostInfoStub = stubGetPeerHostInfo.call(this);\n+ var getPeerHostInfoStub = stubGetPeerHostInfo(this);\nvar notificationClient =\nnew ThaliNotificationClient(globals.peerPoolInterfaceStub,\n@@ -262,7 +260,7 @@ test('Received beacons with no values for us', tape.sinonTest(function (t) {\nnew ThaliNotificationClient(globals.peerPoolInterface,\nglobals.targetDeviceKeyExchangeObjects[0]);\n- var getPeerHostInfoStub = stubGetPeerHostInfo.call(this);\n+ var getPeerHostInfoStub = stubGetPeerHostInfo(this);\nvar enqueueStub = this.stub(\nglobals.peerPoolInterface,\n@@ -379,7 +377,7 @@ test('Resolves an action locally', tape.sinonTest(function (t) {\n// Expected result:\n// Action is getting resolved ok\n- var getPeerHostInfoStub = stubGetPeerHostInfo.call(this);\n+ var getPeerHostInfoStub = stubGetPeerHostInfo(this);\n// Simulates how the peer pool runs actions\nvar enqueueStub = this.stub(\n@@ -445,7 +443,7 @@ test('Emits error event when peerPool.enqueue throws', tape.sinonTest(function (\n// default several minutes timeout\nt.timeoutAfter(20);\n- var getPeerHostInfoStub = stubGetPeerHostInfo.call(this);\n+ var getPeerHostInfoStub = stubGetPeerHostInfo(this);\nvar peerPool = {\nenqueue: function () {\nthrow new Error('oops');\n@@ -485,7 +483,7 @@ test('Resolves an action locally using ThaliPeerPoolDefault', tape.sinonTest(fun\n// Expected result:\n// Action is getting resolved ok\n- var getPeerHostInfoStub = stubGetPeerHostInfo.call(this);\n+ var getPeerHostInfoStub = stubGetPeerHostInfo(this);\nvar peerPool = new ThaliPeerPoolDefault();\npeerPool.start();\n@@ -667,7 +665,7 @@ test('hostaddress is removed when the action is running. ', tape.sinonTest(funct\n};\nvar enqueueStub = this.stub(globals.peerPoolInterface, 'enqueue', enqueue);\n- var getPeerHostInfoStub = stubGetPeerHostInfo.call(this);\n+ var getPeerHostInfoStub = stubGetPeerHostInfo(this);\nhttpTester.runServer(globals.expressRouter,\nthaliConfig.NOTIFICATION_BEACON_PATH,\n@@ -819,7 +817,7 @@ test(\n};\nvar enqueueStub = this.stub(globals.peerPoolInterface, 'enqueue', enqueue);\n- var getPeerHostInfoStub = stubGetPeerHostInfo.call(this);\n+ var getPeerHostInfoStub = stubGetPeerHostInfo(this);\nnotificationClient.start([globals.sourcePublicKey]);\nnotificationClient._peerAvailabilityChanged(globals.TCPEvent);\n" }, { "change_type": "MODIFY", "old_path": "test/www/jxcore/bv_tests/testThaliNotificationLocal.js", "new_path": "test/www/jxcore/bv_tests/testThaliNotificationLocal.js", "diff": "@@ -79,8 +79,8 @@ var GlobalVariables = function () {\n};\n-function stubGetPeerHostInfo() {\n- return this.stub(\n+function stubGetPeerHostInfo(sandbox) {\n+ return sandbox.stub(\nThaliMobile,\n'getPeerHostInfo',\nfunction (peerIdentifier, connectionType) {\n@@ -157,7 +157,7 @@ test('Client to server request locally',\n};\nthis.stub(peerPool, 'enqueue', enqueue);\n- var getPeerHostInfoStub = stubGetPeerHostInfo.call(this);\n+ var getPeerHostInfoStub = stubGetPeerHostInfo(this);\n// Initialize the ThaliNotificationClient\nvar notificationClient =\n" }, { "change_type": "MODIFY", "old_path": "test/www/jxcore/bv_tests/testThaliNotificationServer.js", "new_path": "test/www/jxcore/bv_tests/testThaliNotificationServer.js", "diff": "@@ -90,6 +90,8 @@ GlobalVariables.prototype.init = function () {\n*/\nGlobalVariables.prototype.kill = function () {\nvar self = this;\n+ globalVariables.spyStartUpdateAdvertisingAndListening.restore();\n+ globalVariables.spyStopAdvertisingAndListening.restore();\nreturn new Promise(function (resolve, reject) {\nif (self.expressServer) {\nself.expressServer.closeAll(function (error) {\n@@ -135,8 +137,6 @@ var test = tape({\n},\nteardown: function (t) {\nglobalVariables.kill().then(function () {\n- globalVariables.spyStartUpdateAdvertisingAndListening.restore();\n- globalVariables.spyStopAdvertisingAndListening.restore();\nt.end();\n}).catch(function (failure) {\nt.fail('Server cleaning failed:' + failure);\n" }, { "change_type": "MODIFY", "old_path": "test/www/jxcore/bv_tests/testThaliWifiInfrastructure.js", "new_path": "test/www/jxcore/bv_tests/testThaliWifiInfrastructure.js", "diff": "@@ -26,7 +26,6 @@ var logger = require('thali/ThaliLogger')('testThaliWifiInfrastructure');\nvar wifiInfrastructure = new ThaliWifiInfrastructure();\n-var connectionTypes = ThaliMobileNativeWrapper.connectionTypes;\nvar pskIdentity = 'I am an id!';\nvar pskKey = new Buffer('And I am a secret!!!!');\n@@ -247,9 +246,10 @@ test('messages with invalid location or USN should be ignored', function (t) {\ntest('Delayed own message are still ignored after advertisement has been ' +\n'toggled on and off several times', tape.sinonTest(function (t) {\n+ var self = this;\nvar HISTORY_SIZE = 4;\n- this.stub(thaliConfig, 'SSDP_OWN_PEERS_HISTORY_SIZE', HISTORY_SIZE);\n+ self.stub(thaliConfig, 'SSDP_OWN_PEERS_HISTORY_SIZE', HISTORY_SIZE);\nfunction captureMessages (callback) {\nvar captureSize = HISTORY_SIZE * 2; // capture both alive and bye messages\n@@ -258,7 +258,7 @@ test('Delayed own message are still ignored after advertisement has been ' +\n});\nvar capturedMessages = [];\n- this.stub(\n+ self.stub(\nwifiInfrastructure._getSSDPServer(),\n'_send',\nfunction (message) {\n@@ -290,7 +290,7 @@ test('Delayed own message are still ignored after advertisement has been ' +\nwifiInfrastructure.startUpdateAdvertisingAndListening();\n}\n- captureMessages.call(this, function (messages) {\n+ captureMessages(function (messages) {\nvar allMessagesIgnored = messages.every(function (message) {\nreturn !wifiInfrastructure.listener._handleMessage(message);\n});\n@@ -1067,6 +1067,6 @@ test('startUpdateAdvertisingAndListening does not send ssdp:byebye notifications\n// some USN value should be advertised.\nwifiInfrastructure.startUpdateAdvertisingAndListening().then(function () {\npeerIdentifier = wifiInfrastructure._getCurrentPeer().peerIdentifier;\n- })\n+ });\n});\n});\n" }, { "change_type": "RENAME", "old_path": "test/www/jxcore/lib/SinonTest.js", "new_path": "test/www/jxcore/lib/sinonTest.js", "diff": "'use strict';\n-var util = require('util');\n-var inherits = util.inherits;\nvar sinon = require('sinon');\n-var asserts = require('./utils/asserts');\n-var logger = require('thali/ThaliLogger')('SinonTest');\n-\n-function SinonTest (callback) {\n+function sinonTest (callback) {\nreturn function (t) {\nvar slice = Array.prototype.slice;\nvar config = sinon.getConfig(sinon.config);\nconfig.injectInto = config.injectIntoThis && this || config.injectInto;\nvar sandbox = sinon.sandbox.create(config);\nvar args = slice.call(arguments);\n- var tapeEnd = t.end;\n- var exception, result;\n+ var result;\nvar ok;\n- if (typeof t.end === \"function\") {\n- t.on(\"result\", function(res) {\n+ if (typeof t.end === 'function') {\n+ t.on('result', function(res) {\nok = res.ok;\n- })\n+ });\n- t.on(\"end\", function(res) {\n+ t.on('end', function() {\nif (!ok) {\nsandbox.restore();\n} else {\nsandbox.verifyAndRestore();\n}\n- })\n+ });\n}\ntry {\nresult = callback.apply(this, args.concat(sandbox.args));\n} catch (e) {\n- exception = e;\nt.fail(e);\n}\nreturn result;\n};\n}\n-module.exports = SinonTest;\n+module.exports = sinonTest;\n" }, { "change_type": "MODIFY", "old_path": "test/www/jxcore/lib/thaliTape.js", "new_path": "test/www/jxcore/lib/thaliTape.js", "diff": "@@ -38,5 +38,5 @@ if (typeof jxcore === 'undefined' || typeof Mobile !== 'undefined') {\nexports = require('./SimpleTape');\nexports.coordinated = false;\n}\n-exports.sinonTest = require('./SinonTest');\n+exports.sinonTest = require('./sinonTest');\nmodule.exports = exports;\n" }, { "change_type": "MODIFY", "old_path": "thali/NextGeneration/thaliMobile.js", "new_path": "thali/NextGeneration/thaliMobile.js", "diff": "@@ -1117,7 +1117,7 @@ var handleRecreatedPeer = function (nativePeer) {\n});\n}\n}\n-}\n+};\nThaliMobileNativeWrapper.emitter.on('nonTCPPeerAvailabilityChangedEvent',\nfunction (nativePeer) {\n@@ -1416,7 +1416,7 @@ var emitIfConnectionTypePeersLimitReached = function (connectionType) {\ncount: connectionTypePeersCount\n});\n}\n-}\n+};\nvar emitDiscoveryDOS = function (dosInfo) {\nmodule.exports.emitter.emit('discoveryDOS', dosInfo);\n@@ -1433,7 +1433,7 @@ Object.keys(connectionTypes)\nlimit: info.limit,\ncount: info.count\n});\n- })\n+ });\n});\n" } ]
JavaScript
MIT License
thaliproject/thali_cordovaplugin
Update sinon's sandboxing functionality according to the pr 1847
675,381
28.03.2017 18:48:13
-10,800
d9ed552ec6a79a8fe4eea8017c953989c68ac0f2
fix sinonTest wrapped test behavior Wrapped test should behave the same way as original one. So when original function throws, wrapped function should throw too.
[ { "change_type": "MODIFY", "old_path": "test/www/jxcore/lib/sinonTest.js", "new_path": "test/www/jxcore/lib/sinonTest.js", "diff": "@@ -4,12 +4,10 @@ var sinon = require('sinon');\nfunction sinonTest (callback) {\nreturn function (t) {\n- var slice = Array.prototype.slice;\nvar config = sinon.getConfig(sinon.config);\nconfig.injectInto = config.injectIntoThis && this || config.injectInto;\nvar sandbox = sinon.sandbox.create(config);\n- var args = slice.call(arguments);\n- var result;\n+ var args = Array.prototype.slice.call(arguments);\nvar ok;\nif (typeof t.end === 'function') {\n@@ -26,12 +24,7 @@ function sinonTest (callback) {\n});\n}\n- try {\n- result = callback.apply(this, args.concat(sandbox.args));\n- } catch (e) {\n- t.fail(e);\n- }\n- return result;\n+ return callback.apply(this, args.concat(sandbox.args));\n};\n}\n" } ]
JavaScript
MIT License
thaliproject/thali_cordovaplugin
fix sinonTest wrapped test behavior Wrapped test should behave the same way as original one. So when original function throws, wrapped function should throw too.
675,379
31.03.2017 14:07:26
-10,800
8fc802d78a1a0e86b1c13c18dcec23e1e3753d26
Fixing build issue. Fixing bridging header in JXCoreExtension.m file. Fixing unknown identifier error in AppContextTests.swift.
[ { "change_type": "MODIFY", "old_path": "src/ios/JXcoreExtension.m", "new_path": "src/ios/JXcoreExtension.m", "diff": "// To use swift code (AppContext.swift) in objc we need to import autogenerated\n// bridging header. PROJECT_NAME pattern is replaced with actual project name\n// during before_plugin_install phase\n-#import \"%PROJECT_NAME%-swift.h\"\n+#import \"%PROJECT_NAME%-Swift.h\"\n// JXcoreExtension implementation.\n@interface JXcoreExtension (AppContextDelegate) <AppContextDelegate>\n" }, { "change_type": "MODIFY", "old_path": "src/ios/Testing/AppContextTests.swift", "new_path": "src/ios/Testing/AppContextTests.swift", "diff": "@@ -287,7 +287,7 @@ class AppContextTests: XCTestCase {\nfunc testErrorDescription() {\nXCTAssertEqual(ThaliCoreError.IllegalPeerID.rawValue,\n- errorDescription(ThaliCoreError.IllegalPeerID))\n+ ThaliCoreError.IllegalPeerID.errorDescription)\n}\nfunc testJsonValue() {\n" } ]
JavaScript
MIT License
thaliproject/thali_cordovaplugin
Fixing build issue. Fixing bridging header in JXCoreExtension.m file. Fixing unknown identifier error in AppContextTests.swift.
675,373
31.03.2017 17:06:08
-10,800
ae914df44be51b1bfd3041ff6d1b4719767c3756
Update compile sdk version to 25
[ { "change_type": "MODIFY", "old_path": "thali/package.json", "new_path": "thali/package.json", "diff": "\"androidConfig\": {\n\"minSdkVersion\": \"21\",\n\"buildToolsVersion\": \"25.0.2\",\n- \"compileSdkVersion\": \"android-23\"\n+ \"compileSdkVersion\": \"android-25\"\n},\n\"btconnectorlib2\": \"0.3.9\",\n\"jxcore-cordova\": \"0.1.10\",\n" } ]
JavaScript
MIT License
thaliproject/thali_cordovaplugin
Update compile sdk version to 25
675,379
04.04.2017 12:50:27
-10,800
411576925e169b8546762c74a75c4e750c5d125b
Update code to mirror lowercase enum values from ThaliCore.
[ { "change_type": "MODIFY", "old_path": "src/ios/AppContext.swift", "new_path": "src/ios/AppContext.swift", "diff": "@@ -364,7 +364,7 @@ extension PeerAvailability {\nguard self.bluetoothState == .on || NetworkReachability().isWiFiEnabled()\nelse {\nself.handleMultiConnectConnectionFailure(withIdentifier: identifierString,\n- error: ThaliCoreError.RadioTurnedOff)\n+ error: ThaliCoreError.radioTurnedOff)\nreturn\n}\nself.browserManager.connectToPeer(identifierString, syncValue: syncValue) {\n" }, { "change_type": "MODIFY", "old_path": "src/ios/Testing/AppContextTests.swift", "new_path": "src/ios/Testing/AppContextTests.swift", "diff": "@@ -286,8 +286,8 @@ class AppContextTests: XCTestCase {\n}\nfunc testErrorDescription() {\n- XCTAssertEqual(ThaliCoreError.IllegalPeerID.rawValue,\n- ThaliCoreError.IllegalPeerID.errorDescription)\n+ XCTAssertEqual(ThaliCoreError.illegalPeerID.rawValue,\n+ ThaliCoreError.illegalPeerID.errorDescription)\n}\nfunc testJsonValue() {\n" } ]
JavaScript
MIT License
thaliproject/thali_cordovaplugin
Update code to mirror lowercase enum values from ThaliCore.
675,379
04.04.2017 13:26:59
-10,800
5252520b97ce6ac65edb155bcc80a2aae7047f44
Update swiftlint version to 0.17.0.
[ { "change_type": "MODIFY", "old_path": "thali/install/validateBuildEnvironment.js", "new_path": "thali/install/validateBuildEnvironment.js", "diff": "@@ -33,7 +33,7 @@ const versions =\ncordova: '6.4.0',\njava: '1.8.0_102',\ngit: '2.10.0',\n- swiftlint: '0.16.1',\n+ swiftlint: '0.17.0',\ncarthage: '0.20.0',\nsinopiaNode: ' ',\nsinopiaJxCore: ' '\n" } ]
JavaScript
MIT License
thaliproject/thali_cordovaplugin
Update swiftlint version to 0.17.0.
675,378
07.04.2017 18:13:03
-10,800
9526b8023eab8dfa5f88dbbe9f8f720e66254058
Add test for shift data via parallel connections Add test for shift data via parallel connections
[ { "change_type": "MODIFY", "old_path": "test/www/jxcore/bv_tests/testThaliMobileNative.js", "new_path": "test/www/jxcore/bv_tests/testThaliMobileNative.js", "diff": "@@ -128,6 +128,83 @@ test('Can call stopUpdateAdvertisingAndListening twice without start and ' +\n});\n});\n+test('Can shift data via parallel connections', function (t) {\n+ var dataLength = 22;\n+\n+ var formatPrintableData = function (data) {\n+ return data;\n+ };\n+\n+ var server = net.createServer(function (socket) {\n+ var ended = false;\n+ var buffer = '';\n+ socket.on('data', function (chunk) {\n+ buffer += chunk.toString();\n+\n+ // when received all data, send it back\n+ if (buffer.length === dataLength) {\n+ var rawData = new Buffer(buffer);\n+ socket.write(rawData, function () {\n+ logger.debug('Server data flushed');\n+ });\n+ ended = true;\n+ }\n+ });\n+ socket.on('error', function (error) {\n+ t.fail(error.message);\n+ });\n+ });\n+ server = makeIntoCloseAllServer(server);\n+ serverToBeClosed = server;\n+\n+ function shiftData(sock, exchangeData) {\n+ return new Promise(function (resolve, reject) {\n+ sock.on('error', function (error) {\n+ reject(error);\n+ });\n+\n+ var receivedData = '';\n+ sock.on('data', function (chunk) {\n+ receivedData += chunk.toString();\n+ if (receivedData === exchangeData) {\n+ sock.end();\n+ }\n+ });\n+ sock.on('end', function () {\n+ t.equal(receivedData, exchangeData, 'got the same data back');\n+ resolve();\n+ });\n+\n+ var rawData = new Buffer(exchangeData);\n+ sock.write(rawData, function () {\n+ logger.debug('Client data flushed');\n+ });\n+ });\n+ }\n+\n+ server.listen(0, function () {\n+ var port = server.address().port;\n+ findPeerAndConnect(port).then(function (info) {\n+ var nativePort = info.connection.listeningPort;\n+ return Promise.all([\n+ connect(net, { port: nativePort }),\n+ connect(net, { port: nativePort }),\n+ connect(net, { port: nativePort }),\n+ ]);\n+ }).then(function (sockets) {\n+ return Promise.all(sockets.map(function (socket, index) {\n+ var string = 'small amount of data ' + index;\n+ t.equal(string.length, dataLength, 'correct string length');\n+ return shiftData(socket, string);\n+ }));\n+ })\n+ .catch(t.fail)\n+ .then(function () {\n+ t.end();\n+ });\n+ });\n+});\n+\nif (!tape.coordinated) {\nreturn;\n}\n" } ]
JavaScript
MIT License
thaliproject/thali_cordovaplugin
Add test for shift data via parallel connections Add test for shift data via parallel connections
675,378
07.04.2017 18:37:29
-10,800
2b8622197900a0e35c1bb19ea52795d78cfa1cf6
Update test functions, review with eslint
[ { "change_type": "MODIFY", "old_path": "test/www/jxcore/bv_tests/testThaliMobileNative.js", "new_path": "test/www/jxcore/bv_tests/testThaliMobileNative.js", "diff": "@@ -128,15 +128,61 @@ test('Can call stopUpdateAdvertisingAndListening twice without start and ' +\n});\n});\n-test('Can shift data via parallel connections', function (t) {\n- var dataLength = 22;\n+function findPeerAndConnect(advertisingPort) {\n+ return new Promise(function (resolve, reject) {\n+ var connecting = false;\n+ Mobile('peerAvailabilityChanged').registerToNative(function (peers) {\n+ peers.forEach(function (peer) {\n+ if (peer.peerAvailable && !connecting) {\n+ connecting = true;\n+ thaliMobileNativeTestUtils.connectToPeer(peer)\n+ .then(function (connection) {\n+ resolve({\n+ connection: connection,\n+ peer: peer\n+ });\n+ })\n+ .catch(function (error) {\n+ error.peer = peer;\n+ reject(error);\n+ });\n+ }\n+ });\n+ });\n+ Mobile('startUpdateAdvertisingAndListening')\n+ .callNative(advertisingPort, function (err) {\n+ if (err) {\n+ return reject(err);\n+ }\n+ Mobile('startListeningForAdvertisements').callNative(function (err) {\n+ if (err) {\n+ return reject(err);\n+ }\n+ });\n+ });\n+ });\n+}\n- var formatPrintableData = function (data) {\n- return data;\n+function connect(module, options) {\n+ return new Promise(function (resolve, reject) {\n+ var connectErrorHandler = function (error) {\n+ console.log('Connection to the %d port on localhost failed: %s', options.port, error.stack);\n+ reject(error);\n};\n+ console.log('Connecting to the localhost:%d', options.port);\n+ var client = module.connect(options, function () {\n+ client.removeListener('error', connectErrorHandler);\n+ console.log('Connected to the localhost:%d', options.port);\n+ resolve(client);\n+ });\n+ client.once('error', connectErrorHandler);\n+ });\n+}\n+\n+test('Can shift data via parallel connections', function (t) {\n+ var dataLength = 22;\nvar server = net.createServer(function (socket) {\n- var ended = false;\nvar buffer = '';\nsocket.on('data', function (chunk) {\nbuffer += chunk.toString();\n@@ -147,7 +193,6 @@ test('Can shift data via parallel connections', function (t) {\nsocket.write(rawData, function () {\nlogger.debug('Server data flushed');\n});\n- ended = true;\n}\n});\nsocket.on('error', function (error) {\n@@ -955,7 +1000,8 @@ function (t) {\nt.end();\n});\n- thaliMobileNativeTestUtils.startAndListen(t, pretendLocalMux, function (peers) {\n+ thaliMobileNativeTestUtils.startAndListen(t, pretendLocalMux,\n+ function (peers) {\nboundListener.listener(peers);\n});\n});\n" } ]
JavaScript
MIT License
thaliproject/thali_cordovaplugin
Update test functions, review with eslint
675,378
12.04.2017 11:58:39
-10,800
c045007e71fdc3965540a446191adde6874459d7
update http tests
[ { "change_type": "ADD", "old_path": null, "new_path": "test/www/jxcore/bv_tests/testHttp.js", "diff": "+'use strict';\n+\n+var http = require('http');\n+var tape = require('../lib/thaliTape');\n+var Promise = require('lie');\n+var EE = require('events').EventEmitter;\n+var ThaliMobileNativeWrapper =\n+ require('thali/NextGeneration/thaliMobileNativeWrapper');\n+var ThaliMobile = require('thali/NextGeneration/thaliMobile');\n+var platform = require('thali/NextGeneration/utils/platform');\n+\n+var router = function () {};\n+\n+var test = tape({\n+ setup: function (t) {\n+ t.end();\n+ },\n+ teardown: function (t) {\n+ ThaliMobileNativeWrapper.stop().then(function () {\n+ t.end();\n+ }).catch(t.end);\n+ }\n+});\n+\n+function listen(server, port) {\n+ return new Promise(function (resolve, reject) {\n+ server.once('error', reject);\n+ server.listen(port, function () {\n+ server.removeListener('error', reject);\n+ resolve(server);\n+ });\n+ });\n+}\n+\n+function makeRequest(hostname, port, method, path, data) {\n+ return new Promise(function (resolve, reject) {\n+ var options = {\n+ hostname: hostname,\n+ port: port,\n+ method: method,\n+ path: path\n+ };\n+ var request = http.request(options, function (response) {\n+ request.removeListener('error', reject);\n+ response.once('error', reject);\n+\n+ var received = [];\n+ response.on('data', function (chunk) {\n+ received.push(chunk);\n+ });\n+ response.on('end', function () {\n+ response.removeListener('error', reject);\n+ var data = Buffer.concat(received);\n+ resolve(data);\n+ });\n+ });\n+\n+ request.once('error', reject);\n+ if (data) {\n+ request.write(data);\n+ }\n+ request.end();\n+ });\n+}\n+\n+test('Single local http request', function (t) {\n+ var server = http.createServer(function (request, response) {\n+ var reply = request.method + ' ' + request.url;\n+ response.end(reply);\n+ });\n+\n+ listen(server, 0).then(function () {\n+ var port = server.address().port;\n+ console.log('listening on %d', port);\n+ return makeRequest('127.0.0.1', port, 'GET', '/path');\n+ }).then(function (data) {\n+ t.equal(data.toString(), 'GET /path');\n+ return null;\n+ }).catch(t.fail).then(t.end);\n+});\n+\n+test('Multiple local http requests', function (t) {\n+ var server = http.createServer(function (request, response) {\n+ var reply = request.method + ' ' + request.url;\n+ response.end(reply);\n+ });\n+\n+ listen(server, 0).then( function () {\n+ var port = server.address().port;\n+ console.log('listening on %d', port);\n+ return Promise.all([\n+ makeRequest('127.0.0.1', port, 'GET', '/path0'),\n+ makeRequest('127.0.0.1', port, 'GET', '/path1'),\n+ makeRequest('127.0.0.1', port, 'GET', '/path2'),\n+ ]);\n+ }).then(function (data) {\n+ t.equal(data[0].toString(), 'GET /path0');\n+ t.equal(data[1].toString(), 'GET /path1');\n+ t.equal(data[2].toString(), 'GET /path2');\n+ return null;\n+ }).catch(t.fail).then(t.end);\n+});\n+\n+var peerFinder = function () {\n+ var peers = {};\n+ var ee = new EE();\n+ var handler = function (peer) {\n+ if (peer.peerAvailable) {\n+ peers[peer.peerIdentifier] = peer;\n+ } else {\n+ delete peers[peer.peerIdentifier];\n+ }\n+ ee.emit('peerschanged');\n+ };\n+\n+ function values(obj) {\n+ return Object.keys(obj).map(function (k) { return obj[k]; });\n+ }\n+\n+ function find(numberOfPeers) {\n+ var keys = Object.keys(peers);\n+ if (keys.length >= numberOfPeers) {\n+ return Promise.resolve(values(peers));\n+ }\n+ return new Promise(function (resolve) {\n+ ee.on('peerschanged', function fn () {\n+ var keys = Object.keys(peers);\n+ if (keys.length >= numberOfPeers) {\n+ ee.removeListener('peerschanged', fn);\n+ resolve(values(peers));\n+ }\n+ });\n+ });\n+ }\n+\n+ ThaliMobileNativeWrapper.emitter.on(\n+ 'nonTCPPeerAvailabilityChangedEvent', handler\n+ );\n+ find.cleanup = function () {\n+ ee.removeAllListeners('peerschanged');\n+ ThaliMobileNativeWrapper.emitter.removeListener(\n+ 'nonTCPPeerAvailabilityChangedEvent', handler\n+ );\n+ };\n+\n+ return find;\n+};\n+\n+test('Single coordinated request ios native',\n+ function () {\n+ return platform.isAndroid ||\n+ global.NETWORK_TYPE === ThaliMobile.networkTypes.WIFI;\n+ },\n+ function (t) {\n+ var total = t.participants.length - 1;\n+ var find = peerFinder();\n+\n+ var server = http.createServer(function (request, response) {\n+ var reply = request.method + ' ' + request.url;\n+ response.end(reply);\n+ });\n+\n+ var listenNative = ThaliMobileNativeWrapper.start(router).then(function () {\n+ return ThaliMobileNativeWrapper.startListeningForAdvertisements();\n+ });\n+ var listenServer = listen(server, 0);\n+\n+ var findPeers = find(total);\n+\n+ Promise.all([ listenNative, listenServer ])\n+ .then(function (r) {\n+ var server = r[1];\n+ var port = server.address().port;\n+ console.log('listening on %d', port);\n+ return ThaliMobileNativeWrapper\n+ .startUpdateAdvertisingAndListening(port);\n+ })\n+ .then(function () {\n+ return findPeers;\n+ })\n+ .then(function (peers) {\n+ return Promise.all(peers.map(function (peer) {\n+ return ThaliMobileNativeWrapper._multiConnect(peer.peerIdentifier);\n+ }));\n+ })\n+ .then(function (ports) {\n+ return Promise.all(ports.map(function (port) {\n+ return makeRequest('127.0.0.1', port, 'GET', '/path');\n+ }));\n+ })\n+ .then(function (responses) {\n+ responses.forEach(function (r) {\n+ t.equal(r.toString(), 'GET /path');\n+ });\n+ })\n+ .catch(t.fail)\n+ .then(function () {\n+ find.cleanup();\n+ t.end();\n+ });\n+ });\n+\n+test('Multiple coordinated request ios native',\n+ function () {\n+ return platform.isAndroid ||\n+ global.NETWORK_TYPE === ThaliMobile.networkTypes.WIFI;\n+ },\n+ function (t) {\n+ var total = t.participants.length - 1;\n+ var find = peerFinder();\n+\n+ var server = http.createServer(function (request, response) {\n+ var reply = request.method + ' ' + request.url;\n+ response.end(reply);\n+ });\n+\n+ var listenNative = ThaliMobileNativeWrapper.start(router).then(function () {\n+ return ThaliMobileNativeWrapper.startListeningForAdvertisements();\n+ });\n+ var listenServer = listen(server, 0);\n+\n+ var findPeers = find(total);\n+\n+ Promise.all([ listenNative, listenServer ])\n+ .then(function (r) {\n+ var server = r[1];\n+ var port = server.address().port;\n+ console.log('listening on %d', port);\n+ return ThaliMobileNativeWrapper\n+ .startUpdateAdvertisingAndListening(port);\n+ })\n+ .then(function () {\n+ return findPeers;\n+ })\n+ .then(function (peers) {\n+ return Promise.all(peers.map(function (peer) {\n+ return ThaliMobileNativeWrapper._multiConnect(peer.peerIdentifier);\n+ }));\n+ })\n+ .then(function (ports) {\n+ return Promise.all(ports.map(function (port) {\n+ return Promise.all([\n+ makeRequest('127.0.0.1', port, 'GET', '/path0'),\n+ makeRequest('127.0.0.1', port, 'GET', '/path1'),\n+ makeRequest('127.0.0.1', port, 'GET', '/path2'),\n+ ]);\n+ }));\n+ })\n+ .then(function (responses) {\n+ responses.forEach(function (r) {\n+ t.equal(r[0].toString(), 'GET /path0');\n+ t.equal(r[1].toString(), 'GET /path1');\n+ t.equal(r[2].toString(), 'GET /path2');\n+ });\n+ })\n+ .catch(t.fail)\n+ .then(function () {\n+ find.cleanup();\n+ t.end();\n+ });\n+ });\n" } ]
JavaScript
MIT License
thaliproject/thali_cordovaplugin
update http tests
675,378
12.04.2017 12:25:13
-10,800
624ceb0478415607a7331a7a8c8496a0376addf9
Update and added tests for issue iOS can't handle parallel connection from Node Update and added tests for issue iOS can't handle parallel connection from Node
[ { "change_type": "MODIFY", "old_path": "test/www/jxcore/bv_tests/testThaliMobileNative.js", "new_path": "test/www/jxcore/bv_tests/testThaliMobileNative.js", "diff": "@@ -8,7 +8,9 @@ if (global.NETWORK_TYPE === ThaliMobile.networkTypes.WIFI) {\n}\nvar net = require('net');\n+var tls = require('tls');\nvar randomString = require('randomstring');\n+var thaliConfig = require('thali/NextGeneration/thaliConfig');\nvar tape = require('../lib/thaliTape');\nvar makeIntoCloseAllServer = require('thali/NextGeneration/makeIntoCloseAllServer');\nvar Promise = require('lie');\n@@ -128,128 +130,6 @@ test('Can call stopUpdateAdvertisingAndListening twice without start and ' +\n});\n});\n-function findPeerAndConnect(advertisingPort) {\n- return new Promise(function (resolve, reject) {\n- var connecting = false;\n- Mobile('peerAvailabilityChanged').registerToNative(function (peers) {\n- peers.forEach(function (peer) {\n- if (peer.peerAvailable && !connecting) {\n- connecting = true;\n- thaliMobileNativeTestUtils.connectToPeer(peer)\n- .then(function (connection) {\n- resolve({\n- connection: connection,\n- peer: peer\n- });\n- })\n- .catch(function (error) {\n- error.peer = peer;\n- reject(error);\n- });\n- }\n- });\n- });\n- Mobile('startUpdateAdvertisingAndListening')\n- .callNative(advertisingPort, function (err) {\n- if (err) {\n- return reject(err);\n- }\n- Mobile('startListeningForAdvertisements').callNative(function (err) {\n- if (err) {\n- return reject(err);\n- }\n- });\n- });\n- });\n-}\n-\n-function connect(module, options) {\n- return new Promise(function (resolve, reject) {\n- var connectErrorHandler = function (error) {\n- console.log('Connection to the %d port on localhost failed: %s', options.port, error.stack);\n- reject(error);\n- };\n- console.log('Connecting to the localhost:%d', options.port);\n- var client = module.connect(options, function () {\n- client.removeListener('error', connectErrorHandler);\n- console.log('Connected to the localhost:%d', options.port);\n- resolve(client);\n- });\n- client.once('error', connectErrorHandler);\n- });\n-}\n-\n-test('Can shift data via parallel connections', function (t) {\n- var dataLength = 22;\n-\n- var server = net.createServer(function (socket) {\n- var buffer = '';\n- socket.on('data', function (chunk) {\n- buffer += chunk.toString();\n-\n- // when received all data, send it back\n- if (buffer.length === dataLength) {\n- var rawData = new Buffer(buffer);\n- socket.write(rawData, function () {\n- logger.debug('Server data flushed');\n- });\n- }\n- });\n- socket.on('error', function (error) {\n- t.fail(error.message);\n- });\n- });\n- server = makeIntoCloseAllServer(server);\n- serverToBeClosed = server;\n-\n- function shiftData(sock, exchangeData) {\n- return new Promise(function (resolve, reject) {\n- sock.on('error', function (error) {\n- reject(error);\n- });\n-\n- var receivedData = '';\n- sock.on('data', function (chunk) {\n- receivedData += chunk.toString();\n- if (receivedData === exchangeData) {\n- sock.end();\n- }\n- });\n- sock.on('end', function () {\n- t.equal(receivedData, exchangeData, 'got the same data back');\n- resolve();\n- });\n-\n- var rawData = new Buffer(exchangeData);\n- sock.write(rawData, function () {\n- logger.debug('Client data flushed');\n- });\n- });\n- }\n-\n- server.listen(0, function () {\n- var port = server.address().port;\n- findPeerAndConnect(port).then(function (info) {\n- var nativePort = info.connection.listeningPort;\n- return Promise.all([\n- connect(net, { port: nativePort }),\n- connect(net, { port: nativePort }),\n- connect(net, { port: nativePort }),\n- ]);\n- }).then(function (sockets) {\n- return Promise.all(sockets.map(function (socket, index) {\n- var string = 'small amount of data ' + index;\n- t.equal(string.length, dataLength, 'correct string length');\n- return shiftData(socket, string);\n- }));\n- })\n- .catch(t.fail)\n- .then(function () {\n- t.end();\n- });\n- });\n-});\n-\nif (!tape.coordinated) {\nreturn;\n}\n@@ -290,7 +170,6 @@ test('peerAvailabilityChange is called', function (t) {\n});\n});\n-\nfunction connectionDiesClean(t, connection) {\nvar errorFired = false;\nvar endFired = false;\n@@ -425,6 +304,294 @@ test('Can connect to a remote peer', function (t) {\n}, 5000);\n});\n+function connect(module, options) {\n+ return new Promise(function (resolve, reject) {\n+ var connectErrorHandler = function (error) {\n+ console.log('Connection to the %d port on localhost failed: %s',\n+ options.port, error.stack);\n+ reject(error);\n+ };\n+ console.log('Connecting to the localhost:%d', options.port);\n+ var client = module.connect(options, function () {\n+ client.removeListener('error', connectErrorHandler);\n+ console.log('Connected to the localhost:%d', options.port);\n+ resolve(client);\n+ });\n+ client.once('error', connectErrorHandler);\n+ });\n+}\n+\n+function wairForEvent(emitter, event) {\n+ return new Promise(function (resolve) {\n+ emitter.once(event, resolve);\n+ });\n+}\n+\n+function shiftData (t, sock, exchangeData) {\n+ return new Promise(function (resolve, reject) {\n+ sock.on('error', function (error) {\n+ console.log('Client socket error:', error.message, error.stack);\n+ reject(error);\n+ });\n+\n+ var receivedData = '';\n+ sock.on('data', function (chunk) {\n+ receivedData += chunk.toString();\n+ if (receivedData === exchangeData) {\n+ sock.end();\n+ }\n+ });\n+ sock.on('end', function () {\n+ t.equal(receivedData, exchangeData, 'got the same data back');\n+ resolve();\n+ });\n+\n+ var rawData = new Buffer(exchangeData);\n+ logger.debug('Client sends data (%d bytes):',\n+ rawData.length);\n+ sock.write(rawData, function () {\n+ logger.debug('Client data flushed');\n+ });\n+ });\n+}\n+\n+function createServer (t, dataLength) {\n+ return net.createServer(function (socket) {\n+ var buffer = '';\n+ socket.on('data', function (chunk) {\n+ buffer += chunk.toString();\n+ logger.debug('Server received (%d bytes):', chunk.length);\n+\n+ // when received all data, send it back\n+ if (buffer.length === dataLength) {\n+ logger.debug('Server received all data: %s', buffer);\n+\n+ var rawData = new Buffer(buffer);\n+ logger.debug('Server sends data back to client (%d bytes):',\n+ rawData.length);\n+ socket.write(rawData, function () {\n+ logger.debug('Server data flushed');\n+ });\n+ }\n+ });\n+ socket.on('error', function (error) {\n+ t.fail(error.message);\n+ });\n+ });\n+}\n+\n+function onConnectFailure(t, error) {\n+ logger.debug(error);\n+ t.fail('Connect failed!');\n+ t.end();\n+}\n+\n+test('Can shift data', function (t) {\n+ var connecting = false;\n+ var exchangeData = 'small amount of data';\n+\n+ var server = createServer(t, exchangeData.length);\n+ server = makeIntoCloseAllServer(server);\n+ serverToBeClosed = server;\n+\n+ function onConnectSuccess(err, connection) {\n+ var nativePort = connection.listeningPort;\n+\n+ connect(net, { port: nativePort })\n+ .then(function (socket) {\n+ return shiftData(t, socket, exchangeData);\n+ })\n+ .catch(t.fail)\n+ .then(function () {\n+ t.end();\n+ });\n+ }\n+\n+ thaliMobileNativeTestUtils.startAndListen(t, server, function (peers) {\n+ peers.forEach(function (peer) {\n+ if (peer.peerAvailable && !connecting) {\n+ connecting = true;\n+ thaliMobileNativeTestUtils.connectToPeer(peer)\n+ .then(function (connection) {\n+ onConnectSuccess(null, connection, peer);\n+ })\n+ .catch(function (error) {\n+ onConnectFailure(t, error, null, peer);\n+ });\n+ }\n+ });\n+ });\n+});\n+\n+test('Can shift data via parallel connections', function (t) {\n+ var connecting = false;\n+ var dataLength = 10000;\n+\n+ var server = createServer(t, dataLength);\n+ server = makeIntoCloseAllServer(server);\n+ serverToBeClosed = server;\n+\n+ function onConnectSuccess(err, connection) {\n+ var nativePort = connection.listeningPort;\n+ Promise.all([\n+ connect(net, { port: nativePort }),\n+ connect(net, { port: nativePort }),\n+ connect(net, { port: nativePort }),\n+ ]).then(function (sockets) {\n+ return Promise.all(sockets.map(function (socket) {\n+ var string = randomString.generate(dataLength);\n+ t.equal(string.length, dataLength, 'correct string length');\n+ return shiftData(t, socket, string);\n+ }));\n+ })\n+ .catch(t.fail)\n+ .then(function () {\n+ t.end();\n+ });\n+ }\n+\n+ thaliMobileNativeTestUtils.startAndListen(t, server, function (peers) {\n+ peers.forEach(function (peer) {\n+ if (peer.peerAvailable && !connecting) {\n+ connecting = true;\n+ thaliMobileNativeTestUtils.connectToPeer(peer)\n+ .then(function (connection) {\n+ onConnectSuccess(null, connection, peer);\n+ })\n+ .catch(function (error) {\n+ onConnectFailure(t, error, null, peer);\n+ });\n+ }\n+ });\n+ });\n+});\n+\n+test('Can shift data securely', function (t) {\n+ var connecting = false;\n+ var exchangeData = 'small amount of data';\n+\n+ var uuids = t.participants.map(function (p) { return p.uuid; });\n+ assert(uuids.length === 2, 'This test requires exactly 2 devices');\n+ uuids.sort();\n+ var iAmFirst = (tape.uuid === uuids[0]);\n+\n+ var pskKey = new Buffer('psk-key');\n+ var pskId = 'psk-id';\n+\n+ var options = {\n+ ciphers: thaliConfig.SUPPORTED_PSK_CIPHERS,\n+ pskCallback: function (id) {\n+ console.log('Server received psk id: %s', pskId);\n+ return id === pskId ? pskKey : null;\n+ }\n+ };\n+\n+ var server = tls.createServer(options, function (socket) {\n+ var ended = false;\n+ var buffer = '';\n+ socket.on('data', function (chunk) {\n+ buffer += chunk.toString();\n+ logger.debug('Server received (%d bytes):',\n+ chunk.length);\n+\n+ // when received all data, send it back\n+ if (buffer.length === exchangeData.length) {\n+ logger.debug('Server received all data: %s', buffer);\n+ var rawData = new Buffer(buffer);\n+ logger.debug('Server sends data back to client (%d bytes): ',\n+ rawData.length);\n+ socket.write(rawData, function () {\n+ logger.debug('Server data flushed');\n+ });\n+ ended = true;\n+ socket.end(function () {\n+ logger.debug('Server\\'s socket stream finished');\n+ });\n+ }\n+ });\n+ socket.on('end', function () {\n+ // server ends connection, not client\n+ if (!ended) {\n+ t.fail(new Error('Unexpected end event'));\n+ return;\n+ }\n+ server.emit('CLIENT_DONE');\n+ });\n+ socket.on('error', function (error) {\n+ t.fail(error.message);\n+ });\n+ });\n+ server = makeIntoCloseAllServer(server);\n+ serverToBeClosed = server;\n+\n+ var waitForServerEnd = wairForEvent(server, 'CLIENT_DONE');\n+\n+ function shiftData(sock) {\n+ sock.on('error', function (error) {\n+ console.log('Client socket error:', error.message, error.stack);\n+ t.fail(error.message);\n+ });\n+\n+ var receivedData = '';\n+ sock.on('data', function (chunk) {\n+ receivedData += chunk.toString();\n+ });\n+ sock.on('end', function () {\n+ t.equal(receivedData, exchangeData, 'got the same data back');\n+ });\n+\n+ var rawData = new Buffer(exchangeData);\n+ logger.debug('Client sends data (%d bytes):',\n+ rawData.length);\n+ sock.write(rawData, function () {\n+ logger.debug('Client data flushed');\n+ });\n+ return wairForEvent(sock, 'end');\n+ }\n+\n+ function startShiftData(port) {\n+ return connect(tls, {\n+ port: port,\n+ ciphers: thaliConfig.SUPPORTED_PSK_CIPHERS,\n+ pskIdentity: pskId,\n+ pskKey: pskKey,\n+ })\n+ .then(function (socket) {\n+ return shiftData(socket);\n+ });\n+ }\n+\n+ function onConnectSuccess(err, connection) {\n+ var nativePort = connection.listeningPort;\n+ var result = (iAmFirst) ?\n+ startShiftData(nativePort) :\n+ waitForServerEnd.then(function () {\n+ return startShiftData(nativePort);\n+ });\n+\n+ result\n+ .catch(t.fail)\n+ .then(function () {\n+ t.end();\n+ });\n+ }\n+\n+ thaliMobileNativeTestUtils.startAndListen(t, server, function (peers) {\n+ peers.forEach(function (peer) {\n+ if (peer.peerAvailable && !connecting) {\n+ connecting = true;\n+ thaliMobileNativeTestUtils.connectToPeer(peer)\n+ .then(function (connection) {\n+ onConnectSuccess(null, connection, peer);\n+ })\n+ .catch(function (error) {\n+ onConnectFailure(t, error, null, peer);\n+ });\n+ }\n+ });\n+ });\n+});\n+\ntest('Can shift large amounts of data', function (t) {\nvar connecting = false;\n" } ]
JavaScript
MIT License
thaliproject/thali_cordovaplugin
Update and added tests for issue iOS can't handle parallel connection from Node Update and added tests for issue iOS can't handle parallel connection from Node
675,378
18.04.2017 17:51:38
-10,800
46edbca684589a852ff34e4996aab77cd5ffec4d
Update test "Multiple coordinated request ios native" with different sizes of data for different requests.
[ { "change_type": "MODIFY", "old_path": "test/www/jxcore/bv_tests/testHttp.js", "new_path": "test/www/jxcore/bv_tests/testHttp.js", "diff": "@@ -8,6 +8,7 @@ var ThaliMobileNativeWrapper =\nrequire('thali/NextGeneration/thaliMobileNativeWrapper');\nvar ThaliMobile = require('thali/NextGeneration/thaliMobile');\nvar platform = require('thali/NextGeneration/utils/platform');\n+var randomString = require('randomstring');\nvar router = function () {};\n@@ -206,11 +207,27 @@ test('Multiple coordinated request ios native',\nglobal.NETWORK_TYPE === ThaliMobile.networkTypes.WIFI;\n},\nfunction (t) {\n+ var firstReply = randomString.generate(2000);\n+ var secondReply = randomString.generate(30);\n+ var thirdReply = randomString.generate(3000);\n+ var reply;\nvar total = t.participants.length - 1;\nvar find = peerFinder();\nvar server = http.createServer(function (request, response) {\n- var reply = request.method + ' ' + request.url;\n+ switch (request.url) {\n+ case '/path0':\n+ reply = firstReply;\n+ break;\n+ case '/path1':\n+ reply = secondReply;\n+ break;\n+ case '/path2':\n+ reply = thirdReply;\n+ break;\n+ default:\n+ t.end;\n+ }\nresponse.end(reply);\n});\n@@ -248,9 +265,9 @@ test('Multiple coordinated request ios native',\n})\n.then(function (responses) {\nresponses.forEach(function (r) {\n- t.equal(r[0].toString(), 'GET /path0');\n- t.equal(r[1].toString(), 'GET /path1');\n- t.equal(r[2].toString(), 'GET /path2');\n+ t.equal(r[0].toString(), firstReply);\n+ t.equal(r[1].toString(), secondReply);\n+ t.equal(r[2].toString(), thirdReply);\n});\n})\n.catch(t.fail)\n" } ]
JavaScript
MIT License
thaliproject/thali_cordovaplugin
Update test "Multiple coordinated request ios native" with different sizes of data for different requests.
675,378
19.04.2017 11:07:38
-10,800
d1d7212ff07faf8467426cd8e7103dcaaea49c12
Create PeerFinder class, update http tests
[ { "change_type": "MODIFY", "old_path": "test/www/jxcore/bv_tests/testHttp.js", "new_path": "test/www/jxcore/bv_tests/testHttp.js", "diff": "@@ -102,51 +102,59 @@ test('Multiple local http requests', function (t) {\n}).catch(t.fail).then(t.end);\n});\n-var peerFinder = function () {\n- var peers = {};\n- var eventEmitter = new EventEmitter();\n- var handler = function (peer) {\n+function PeerFinder () {\n+ this.peers = {};\n+ this.eventEmitter = new EventEmitter();\n+ this._setUpEvent();\n+}\n+\n+PeerFinder.prototype._nonTCPPeerAvailabilityHandler = function(peer) {\n+ var self = this;\nif (peer.peerAvailable) {\n- peers[peer.peerIdentifier] = peer;\n+ self.peers[peer.peerIdentifier] = peer;\n} else {\n- delete peers[peer.peerIdentifier];\n+ delete self.peers[peer.peerIdentifier];\n}\n- eventEmitter.emit('peerschanged');\n+ self.eventEmitter.emit('peerschanged');\n+};\n+\n+PeerFinder.prototype._setUpEvent = function() {\n+ var self = this;\n+ ThaliMobileNativeWrapper.emitter.on(\n+ 'nonTCPPeerAvailabilityChangedEvent',\n+ self._nonTCPPeerAvailabilityHandler\n+ );\n};\n- function values(obj) {\n+PeerFinder.prototype._getValues = function(obj) {\nreturn Object.keys(obj).map(function (k) { return obj[k]; });\n- }\n+};\n- function find(numberOfPeers) {\n- var keys = Object.keys(peers);\n+PeerFinder.prototype.find = function(numberOfPeers) {\n+ var self = this;\n+ var keys = Object.keys(self.peers);\nif (keys.length >= numberOfPeers) {\n- return Promise.resolve(values(peers));\n+ return Promise.resolve(self._getValues(self.peers));\n}\nreturn new Promise(function (resolve) {\n- eventEmitter.on('peerschanged', function fn () {\n- var keys = Object.keys(peers);\n+ self.eventEmitter.on('peerschanged', function fn () {\n+ var keys = Object.keys(self.peers);\nif (keys.length >= numberOfPeers) {\n- eventEmitter.removeListener('peerschanged', fn);\n- resolve(values(peers));\n+ self.eventEmitter.removeListener('peerschanged', fn);\n+ resolve(self._getValues(self.peers));\n}\n});\n});\n- }\n+};\n- ThaliMobileNativeWrapper.emitter.on(\n- 'nonTCPPeerAvailabilityChangedEvent', handler\n- );\n- find.cleanup = function () {\n- eventEmitter.removeAllListeners('peerschanged');\n+PeerFinder.prototype.cleanup = function() {\n+ var self = this;\n+ self.eventEmitter.removeAllListeners('peerschanged');\nThaliMobileNativeWrapper.emitter.removeListener(\n- 'nonTCPPeerAvailabilityChangedEvent', handler\n+ 'nonTCPPeerAvailabilityChangedEvent', self._nonTCPPeerAvailabilityHandler\n);\n};\n- return find;\n-};\n-\ntest('Single coordinated request ios native',\nfunction () {\nreturn platform.isAndroid ||\n@@ -154,7 +162,7 @@ test('Single coordinated request ios native',\n},\nfunction (t) {\nvar total = t.participants.length - 1;\n- var find = peerFinder();\n+ var peerFinder = new PeerFinder();\nvar server = http.createServer(function (request, response) {\nvar reply = request.method + ' ' + request.url;\n@@ -166,7 +174,7 @@ test('Single coordinated request ios native',\n});\nvar listenServer = serverIsListening(server, 0);\n- var findPeers = find(total);\n+ var findPeers = peerFinder.find(total);\nPromise.all([ listenNative, listenServer ])\n.then(function (allResponses) {\n@@ -196,7 +204,7 @@ test('Single coordinated request ios native',\n})\n.catch(t.fail)\n.then(function () {\n- find.cleanup();\n+ peerFinder.cleanup();\nt.end();\n});\n});\n@@ -212,7 +220,7 @@ test('Multiple coordinated request ios native',\nvar thirdReply = randomString.generate(3000);\nvar reply;\nvar total = t.participants.length - 1;\n- var find = peerFinder();\n+ var peerFinder = new PeerFinder();\nvar server = http.createServer(function (request, response) {\nswitch (request.url) {\n@@ -226,7 +234,7 @@ test('Multiple coordinated request ios native',\nreply = thirdReply;\nbreak;\ndefault:\n- t.end;\n+ t.end();\n}\nresponse.end(reply);\n});\n@@ -236,7 +244,7 @@ test('Multiple coordinated request ios native',\n});\nvar listenServer = serverIsListening(server, 0);\n- var findPeers = find(total);\n+ var findPeers = peerFinder.find(total);\nPromise.all([ listenNative, listenServer ])\n.then(function (allResponses) {\n@@ -272,7 +280,7 @@ test('Multiple coordinated request ios native',\n})\n.catch(t.fail)\n.then(function () {\n- find.cleanup();\n+ peerFinder.cleanup();\nt.end();\n});\n});\n" } ]
JavaScript
MIT License
thaliproject/thali_cordovaplugin
Create PeerFinder class, update http tests
675,378
19.04.2017 17:59:14
-10,800
ececf88c96c56b0586750ba910438bc8bc6c50ef
Update test with running on multiple devices
[ { "change_type": "MODIFY", "old_path": "test/www/jxcore/bv_tests/testThaliMobileNative.js", "new_path": "test/www/jxcore/bv_tests/testThaliMobileNative.js", "diff": "@@ -321,7 +321,7 @@ function connect(module, options) {\n});\n}\n-function wairForEvent(emitter, event) {\n+function waitForEvent(emitter, event) {\nreturn new Promise(function (resolve) {\nemitter.once(event, resolve);\n});\n@@ -470,11 +470,6 @@ test('Can shift data securely', function (t) {\nvar connecting = false;\nvar exchangeData = 'small amount of data';\n- var uuids = t.participants.map(function (p) { return p.uuid; });\n- assert(uuids.length === 2, 'This test requires exactly 2 devices');\n- uuids.sort();\n- var iAmFirst = (tape.uuid === uuids[0]);\n-\nvar pskKey = new Buffer('psk-key');\nvar pskId = 'psk-id';\n@@ -524,8 +519,6 @@ test('Can shift data securely', function (t) {\nserver = makeIntoCloseAllServer(server);\nserverToBeClosed = server;\n- var waitForServerEnd = wairForEvent(server, 'CLIENT_DONE');\n-\nfunction shiftData(sock) {\nsock.on('error', function (error) {\nconsole.log('Client socket error:', error.message, error.stack);\n@@ -546,7 +539,7 @@ test('Can shift data securely', function (t) {\nsock.write(rawData, function () {\nlogger.debug('Client data flushed');\n});\n- return wairForEvent(sock, 'end');\n+ return waitForEvent(sock, 'end');\n}\nfunction startShiftData(port) {\n@@ -563,13 +556,8 @@ test('Can shift data securely', function (t) {\nfunction onConnectSuccess(err, connection) {\nvar nativePort = connection.listeningPort;\n- var result = (iAmFirst) ?\n- startShiftData(nativePort) :\n- waitForServerEnd.then(function () {\n- return startShiftData(nativePort);\n- });\n- result\n+ startShiftData(nativePort)\n.catch(t.fail)\n.then(function () {\nt.end();\n" } ]
JavaScript
MIT License
thaliproject/thali_cordovaplugin
Update test with running on multiple devices
675,378
20.04.2017 10:21:48
-10,800
928b324335695da7b7c742834ce2d81a8d4ab941
Clean up code, update JSDoc, run eslint
[ { "change_type": "MODIFY", "old_path": "test/www/jxcore/bv_tests/testHttp.js", "new_path": "test/www/jxcore/bv_tests/testHttp.js", "diff": "@@ -105,7 +105,7 @@ test('Multiple local http requests', function (t) {\nfunction PeerFinder () {\nthis.peers = {};\nthis.eventEmitter = new EventEmitter();\n- this._setUpEvent();\n+ this._setUpEvents();\n}\nPeerFinder.prototype._nonTCPPeerAvailabilityHandler = function(peer) {\n@@ -118,8 +118,12 @@ PeerFinder.prototype._nonTCPPeerAvailabilityHandler = function(peer) {\nself.eventEmitter.emit('peerschanged');\n};\n-PeerFinder.prototype._setUpEvent = function() {\n+PeerFinder.prototype._setUpEvents = function() {\nvar self = this;\n+ self._nonTCPPeerAvailabilityHandler = function (peerChangeValue) {\n+ self._nonTCPPeerAvailabilityHandler(peerChangeValue);\n+ }.bind(self);\n+\nThaliMobileNativeWrapper.emitter.on(\n'nonTCPPeerAvailabilityChangedEvent',\nself._nonTCPPeerAvailabilityHandler\n" }, { "change_type": "MODIFY", "old_path": "thali/NextGeneration/thaliMobileNativeWrapper.js", "new_path": "thali/NextGeneration/thaliMobileNativeWrapper.js", "diff": "@@ -559,6 +559,7 @@ module.exports.stopListeningForAdvertisements = function () {\n* | Call Start! | The object is not in start state. |\n*\n* @public\n+ * @param {integer} port Note that it is only intended for testing.\n* @returns {Promise<?Error>}\n*/\nmodule.exports.startUpdateAdvertisingAndListening = function (port) {\n" } ]
JavaScript
MIT License
thaliproject/thali_cordovaplugin
Clean up code, update JSDoc, run eslint
675,378
20.04.2017 16:59:29
-10,800
3fe8f92aa216d12e1dfd97a8441ab35e5ad5c3e3
update shift data method
[ { "change_type": "MODIFY", "old_path": "test/www/jxcore/bv_tests/testThaliMobileNative.js", "new_path": "test/www/jxcore/bv_tests/testThaliMobileNative.js", "diff": "@@ -342,7 +342,6 @@ function shiftData (t, sock, exchangeData) {\n}\n});\nsock.on('end', function () {\n- t.equal(receivedData, exchangeData, 'got the same data back');\nresolve();\n});\n" } ]
JavaScript
MIT License
thaliproject/thali_cordovaplugin
update shift data method
675,372
21.04.2017 17:55:36
-10,800
aeda9bc19fbb3db1b55c78d84aa07db8f56023d2
Update _setUpEvents method at PeerFinder class
[ { "change_type": "MODIFY", "old_path": "test/www/jxcore/bv_tests/testHttp.js", "new_path": "test/www/jxcore/bv_tests/testHttp.js", "diff": "@@ -120,9 +120,8 @@ PeerFinder.prototype._nonTCPPeerAvailabilityHandler = function(peer) {\nPeerFinder.prototype._setUpEvents = function() {\nvar self = this;\n- self._nonTCPPeerAvailabilityHandler = function (peerChangeValue) {\n- self._nonTCPPeerAvailabilityHandler(peerChangeValue);\n- }.bind(self);\n+ self._nonTCPPeerAvailabilityHandler = self._nonTCPPeerAvailabilityHandler\n+ .bind(self);\nThaliMobileNativeWrapper.emitter.on(\n'nonTCPPeerAvailabilityChangedEvent',\n" } ]
JavaScript
MIT License
thaliproject/thali_cordovaplugin
Update _setUpEvents method at PeerFinder class
675,378
21.04.2017 18:03:58
-10,800
6d9437e7cacf3bc69b598727510594f13a2895db
Update tests failing on desktop in both mode Update tests failing on desktop in both mode
[ { "change_type": "MODIFY", "old_path": "test/www/jxcore/bv_tests/testThaliMobile.js", "new_path": "test/www/jxcore/bv_tests/testThaliMobile.js", "diff": "@@ -985,7 +985,7 @@ test('networkChanged - fires peerAvailabilityChanged event for native peers ' +\ntest('networkChanged - fires peerAvailabilityChanged event for native peers ' +\n'(MPCF)',\nfunction () {\n- return !platform.isIOS;\n+ return !platform._isRealIOS;\n},\nfunction (t) {\n// Scenario:\n" }, { "change_type": "MODIFY", "old_path": "test/www/jxcore/bv_tests/testThaliMobileNative.js", "new_path": "test/www/jxcore/bv_tests/testThaliMobileNative.js", "diff": "@@ -20,6 +20,7 @@ var thaliMobileNativeWrapper =\nrequire('thali/NextGeneration/thaliMobileNativeWrapper');\nvar logger = require('../lib/testLogger')('testThaliMobileNative');\n+var platform = require('thali/NextGeneration/utils/platform');\n// jshint -W064\n@@ -422,7 +423,11 @@ test('Can shift data', function (t) {\n});\n});\n-test('Can shift data via parallel connections', function (t) {\n+test('Can shift data via parallel connections',\n+ function () {\n+ return platform.isAndroid;\n+ },\n+ function (t) {\nvar connecting = false;\nvar dataLength = 10000;\n@@ -977,7 +982,7 @@ function clientRound(t, roundNumber, boundListener, quitSignal) {\npeerPromises.push(\nthaliMobileNativeTestUtils.connectToPeer(peer, quitSignal)\n.catch(function (err) {\n- error.fatal = false;\n+ err.fatal = false;\nreturn Promise.reject(err);\n})\n.then(function (connection) {\n" }, { "change_type": "MODIFY", "old_path": "test/www/jxcore/bv_tests/testThaliMobileNativeWrapper.js", "new_path": "test/www/jxcore/bv_tests/testThaliMobileNativeWrapper.js", "diff": "@@ -918,13 +918,12 @@ test('test to coordinate connection cut',\nreturn platform._isRealAndroid;\n},\nfunction (t) {\n- // This cuts connections on Android.\n- testUtils.toggleBluetooth(false)\n- .then(function () {\n- // This cuts connections on iOS.\n- return thaliMobileNativeWrapper.killConnections();\n- })\n- .then(function () {\n+ // This cuts connections on Android or iOS\n+ var result = platform.isAndroid ?\n+ testUtils.toggleBluetooth(false):\n+ thaliMobileNativeWrapper.killConnections();\n+\n+ result.then(function () {\nt.end();\n})\n.catch(function () {\n" } ]
JavaScript
MIT License
thaliproject/thali_cordovaplugin
Update tests failing on desktop in both mode Update tests failing on desktop in both mode
675,372
28.04.2017 13:56:10
-10,800
54538f7a21d365242e2d7953377d2128d8d9e68d
Change order of http tests, remove randomstring, destroy all connections in teardown, update _setUpEvents method
[ { "change_type": "MODIFY", "old_path": "test/www/jxcore/bv_tests/testHttp.js", "new_path": "test/www/jxcore/bv_tests/testHttp.js", "diff": "@@ -8,18 +8,34 @@ var ThaliMobileNativeWrapper =\nrequire('thali/NextGeneration/thaliMobileNativeWrapper');\nvar ThaliMobile = require('thali/NextGeneration/thaliMobile');\nvar platform = require('thali/NextGeneration/utils/platform');\n-var randomString = require('randomstring');\n+var makeIntoCloseAllServer = require('thali/NextGeneration/makeIntoCloseAllServer');\nvar router = function () {};\n+var httpServer = null;\nvar test = tape({\nsetup: function (t) {\n+ httpServer = makeIntoCloseAllServer(http.createServer());\nt.end();\n},\nteardown: function (t) {\n- ThaliMobileNativeWrapper.stop().then(function () {\n- t.end();\n- }).catch(t.end);\n+ (httpServer !== null ? httpServer.closeAllPromise() :\n+ Promise.resolve())\n+ .catch(function (err) {\n+ t.fail('httpServer had stop err ' + err);\n+ })\n+ .then(function () {\n+ return ThaliMobileNativeWrapper.stop();\n+ })\n+ .then(function() {\n+ return new Promise(function(res) {\n+ setTimeout(function() {\n+ res();\n+ }, 15000);\n+ });\n+ })\n+ .catch(t.end)\n+ .then(t.end);\n}\n});\n@@ -64,44 +80,6 @@ function makeRequest(hostname, port, method, path, requestData) {\n});\n}\n-test('Single local http request', function (t) {\n- var server = http.createServer(function (request, response) {\n- var reply = request.method + ' ' + request.url;\n- response.end(reply);\n- });\n-\n- serverIsListening(server, 0).then(function () {\n- var port = server.address().port;\n- console.log('listening on %d', port);\n- return makeRequest('127.0.0.1', port, 'GET', '/path');\n- }).then(function (data) {\n- t.equal(data.toString(), 'GET /path');\n- return null;\n- }).catch(t.fail).then(t.end);\n-});\n-\n-test('Multiple local http requests', function (t) {\n- var server = http.createServer(function (request, response) {\n- var reply = request.method + ' ' + request.url;\n- response.end(reply);\n- });\n-\n- serverIsListening(server, 0).then( function () {\n- var port = server.address().port;\n- console.log('listening on %d', port);\n- return Promise.all([\n- makeRequest('127.0.0.1', port, 'GET', '/path0'),\n- makeRequest('127.0.0.1', port, 'GET', '/path1'),\n- makeRequest('127.0.0.1', port, 'GET', '/path2'),\n- ]);\n- }).then(function (data) {\n- t.equal(data[0].toString(), 'GET /path0');\n- t.equal(data[1].toString(), 'GET /path1');\n- t.equal(data[2].toString(), 'GET /path2');\n- return null;\n- }).catch(t.fail).then(t.end);\n-});\n-\nfunction PeerFinder () {\nthis.peers = {};\nthis.eventEmitter = new EventEmitter();\n@@ -120,12 +98,10 @@ PeerFinder.prototype._nonTCPPeerAvailabilityHandler = function(peer) {\nPeerFinder.prototype._setUpEvents = function () {\nvar self = this;\n- self._nonTCPPeerAvailabilityHandler = self._nonTCPPeerAvailabilityHandler\n- .bind(self);\nThaliMobileNativeWrapper.emitter.on(\n'nonTCPPeerAvailabilityChangedEvent',\n- self._nonTCPPeerAvailabilityHandler\n+ self._nonTCPPeerAvailabilityHandler.bind(self)\n);\n};\n@@ -158,6 +134,22 @@ PeerFinder.prototype.cleanup = function() {\n);\n};\n+test('Single local http request', function (t) {\n+ httpServer.on('request', function (req, res) {\n+ var reply = req.method + ' ' + req.url;\n+ res.end(reply);\n+ });\n+\n+ serverIsListening(httpServer, 0).then(function () {\n+ var port = httpServer.address().port;\n+ console.log('listening on %d', port);\n+ return makeRequest('127.0.0.1', port, 'GET', '/path');\n+ }).then(function (data) {\n+ t.equal(data.toString(), 'GET /path');\n+ return null;\n+ }).catch(t.fail).then(t.end);\n+});\n+\ntest('Single coordinated request ios native',\nfunction () {\nreturn platform.isAndroid ||\n@@ -167,22 +159,21 @@ test('Single coordinated request ios native',\nvar total = t.participants.length - 1;\nvar peerFinder = new PeerFinder();\n- var server = http.createServer(function (request, response) {\n- var reply = request.method + ' ' + request.url;\n- response.end(reply);\n+ httpServer.on('request', function (req, res) {\n+ var reply = req.method + ' ' + req.url;\n+ res.end(reply);\n});\nvar listenNative = ThaliMobileNativeWrapper.start(router).then(function () {\nreturn ThaliMobileNativeWrapper.startListeningForAdvertisements();\n});\n- var listenServer = serverIsListening(server, 0);\n+ var listenServer = serverIsListening(httpServer, 0);\nvar findPeers = peerFinder.find(total);\nPromise.all([ listenNative, listenServer ])\n- .then(function (allResponses) {\n- var server = allResponses[1];\n- var port = server.address().port;\n+ .then(function () {\n+ var port = httpServer.address().port;\nconsole.log('listening on %d', port);\nreturn ThaliMobileNativeWrapper\n.startUpdateAdvertisingAndListening(port);\n@@ -212,21 +203,44 @@ test('Single coordinated request ios native',\n});\n});\n+test('Multiple local http requests', function (t) {\n+ httpServer.on('request', function (req, res) {\n+ var reply = req.method + ' ' + req.url;\n+ res.end(reply);\n+ });\n+\n+ serverIsListening(httpServer, 0).then(function () {\n+ var port = httpServer.address().port;\n+ console.log('listening on %d', port);\n+ return Promise.all([\n+ makeRequest('127.0.0.1', port, 'GET', '/path0'),\n+ makeRequest('127.0.0.1', port, 'GET', '/path1'),\n+ makeRequest('127.0.0.1', port, 'GET', '/path2'),\n+ ]);\n+ }).then(function (data) {\n+ t.equal(data[0].toString(), 'GET /path0');\n+ t.equal(data[1].toString(), 'GET /path1');\n+ t.equal(data[2].toString(), 'GET /path2');\n+ return null;\n+ }).catch(t.fail).then(t.end);\n+});\n+\ntest('Multiple coordinated request ios native',\nfunction () {\nreturn platform.isAndroid ||\nglobal.NETWORK_TYPE === ThaliMobile.networkTypes.WIFI;\n},\nfunction (t) {\n- var firstReply = randomString.generate(2000);\n- var secondReply = randomString.generate(30);\n- var thirdReply = randomString.generate(3000);\n+ var str = 'dummy str';\n+ var firstReply = str.repeat(2000);\n+ var secondReply = str.repeat(30);\n+ var thirdReply = str.repeat(3000);\nvar reply;\nvar total = t.participants.length - 1;\nvar peerFinder = new PeerFinder();\n- var server = http.createServer(function (request, response) {\n- switch (request.url) {\n+ httpServer.on('request', function (req, res) {\n+ switch (req.url) {\ncase '/path0':\nreply = firstReply;\nbreak;\n@@ -239,20 +253,19 @@ test('Multiple coordinated request ios native',\ndefault:\nt.end();\n}\n- response.end(reply);\n+ res.end(reply);\n});\nvar listenNative = ThaliMobileNativeWrapper.start(router).then(function () {\nreturn ThaliMobileNativeWrapper.startListeningForAdvertisements();\n});\n- var listenServer = serverIsListening(server, 0);\n+ var listenServer = serverIsListening(httpServer, 0);\nvar findPeers = peerFinder.find(total);\nPromise.all([ listenNative, listenServer ])\n- .then(function (allResponses) {\n- var server = allResponses[1];\n- var port = server.address().port;\n+ .then(function () {\n+ var port = httpServer.address().port;\nconsole.log('listening on %d', port);\nreturn ThaliMobileNativeWrapper\n.startUpdateAdvertisingAndListening(port);\n" } ]
JavaScript
MIT License
thaliproject/thali_cordovaplugin
Change order of http tests, remove randomstring, destroy all connections in teardown, update _setUpEvents method
675,379
03.05.2017 18:38:52
-10,800
c89ea9a7620775243e914937e77566f96d620702
Fix typo in code. Rename wairForEvent to waitForEvent.
[ { "change_type": "MODIFY", "old_path": "test/www/jxcore/bv_tests/testThaliMobileNative.js", "new_path": "test/www/jxcore/bv_tests/testThaliMobileNative.js", "diff": "@@ -358,7 +358,7 @@ function connect(module, options) {\n});\n}\n-function wairForEvent(emitter, event) {\n+function waitForEvent(emitter, event) {\nreturn new Promise(function (resolve) {\nemitter.once(event, resolve);\n});\n@@ -608,7 +608,7 @@ test('Can shift data securely', function (t) {\n});\n});\n- var waitForServerEnd = wairForEvent(server, 'CLIENT_DONE');\n+ var waitForServerEnd = waitForEvent(server, 'CLIENT_DONE');\nfunction shiftData(sock) {\nsock.on('error', function (error) {\n@@ -631,7 +631,7 @@ test('Can shift data securely', function (t) {\nsock.write(rawData, function () {\nconsole.log('Client data flushed');\n});\n- return wairForEvent(sock, 'end');\n+ return waitForEvent(sock, 'end');\n}\nfunction startShiftData(port) {\n" } ]
JavaScript
MIT License
thaliproject/thali_cordovaplugin
Fix typo in code. Rename wairForEvent to waitForEvent.
675,379
03.05.2017 19:48:58
-10,800
ef35344d37880ca058135f3428281e960dee889b
Replace multibyte string with only one character.
[ { "change_type": "MODIFY", "old_path": "test/www/jxcore/bv_tests/testHttp.js", "new_path": "test/www/jxcore/bv_tests/testHttp.js", "diff": "@@ -231,10 +231,10 @@ test('Multiple coordinated request ios native',\nglobal.NETWORK_TYPE === ThaliMobile.networkTypes.WIFI;\n},\nfunction (t) {\n- var str = 'dummy str';\n- var firstReply = str.repeat(2000);\n- var secondReply = str.repeat(30);\n- var thirdReply = str.repeat(3000);\n+ var char = 'a';\n+ var firstReply = char.repeat(2000);\n+ var secondReply = char.repeat(30);\n+ var thirdReply = char.repeat(3000);\nvar reply;\nvar total = t.participants.length - 1;\nvar peerFinder = new PeerFinder();\n" } ]
JavaScript
MIT License
thaliproject/thali_cordovaplugin
Replace multibyte string with only one character.
675,379
04.05.2017 15:19:21
-10,800
446c204a2c90c6c6571a2304a467bbc99ab87fe4
Update jxcore-cordova to 0.1.11 version
[ { "change_type": "MODIFY", "old_path": "thali/package.json", "new_path": "thali/package.json", "diff": "\"compileSdkVersion\": \"android-25\"\n},\n\"btconnectorlib2\": \"0.3.9\",\n- \"jxcore-cordova\": \"0.1.10\",\n- \"jxcore-cordova-url\": \"http://jxcore.azureedge.net/jxcore-cordova/0.1.10/release/io.jxcore.node.jx\"\n+ \"jxcore-cordova\": \"0.1.11\",\n+ \"jxcore-cordova-url\": \"http://jxcore.azureedge.net/jxcore-cordova/0.1.11/release/io.jxcore.node.jx\"\n},\n\"scripts\": {\n\"prepublish\": \"node install/prePublishThaliCordovaPlugin.js\",\n" } ]
JavaScript
MIT License
thaliproject/thali_cordovaplugin
Update jxcore-cordova to 0.1.11 version
675,379
05.05.2017 11:53:54
-10,800
c39a396a30002cb3b8bf4b071c3728b42cc78e55
Temporarily disable validateBuildEnvironment.js script.
[ { "change_type": "MODIFY", "old_path": "thali/install/setUpDesktop.sh", "new_path": "thali/install/setUpDesktop.sh", "diff": "@@ -38,7 +38,7 @@ echo \"\"\necho \"start installing Thali install\"\ncd install\nnpm install --no-optional\n-node validateBuildEnvironment.js\n+#node validateBuildEnvironment.js\necho \"end installing Thali install\"\necho \"\"\n" }, { "change_type": "MODIFY", "old_path": "thali/install/setUpTests.sh", "new_path": "thali/install/setUpTests.sh", "diff": "@@ -31,7 +31,7 @@ prepare_project()\nIPADDRESS=${1:-}\nnpm install --no-optional --production --prefix $REPO_ROOT_DIR/thali/install\n- node $REPO_ROOT_DIR/thali/install/validateBuildEnvironment.js\n+ #node $REPO_ROOT_DIR/thali/install/validateBuildEnvironment.js\ncd $REPO_ROOT_DIR/test/TestServer\nnpm install --no-optional\n" } ]
JavaScript
MIT License
thaliproject/thali_cordovaplugin
Temporarily disable validateBuildEnvironment.js script.
675,379
05.05.2017 11:55:16
-10,800
b755e558ee6b0313a2baf38346bb6dc2ea13b2d7
Temprorarily disable Andoid build.
[ { "change_type": "MODIFY", "old_path": "thali/install/setUpTests.sh", "new_path": "thali/install/setUpTests.sh", "diff": "@@ -199,10 +199,10 @@ build_ios_if_possible()\n# Please note that functions order is important\nIPADDRESS=${2:-}\nprepare_project ${IPADDRESS}\n-add_android_platform\n+#add_android_platform\nadd_ios_platform_if_possible\ninstall_thali $1 ${IPADDRESS}\n-build_android\n+#build_android\nbuild_ios_if_possible\necho \"Remember to start the test coordination server by running jx index.js\"\n" } ]
JavaScript
MIT License
thaliproject/thali_cordovaplugin
Temprorarily disable Andoid build.
675,379
05.05.2017 11:56:08
-10,800
39b409631aeb0f16bcd96f019a5e98380607e0b8
Temporarily change teamID for building.
[ { "change_type": "MODIFY", "old_path": "thali/install/setUpTests.sh", "new_path": "thali/install/setUpTests.sh", "diff": "@@ -188,7 +188,7 @@ build_ios_if_possible()\nbuild \\\nCONFIGURATION_BUILD_DIR=\"${IOS_PROJECT_DIR}/build/device\" \\\nSHARED_PRECOMPS_DIR=\"${IOS_PROJECT_DIR}/build/sharedpch\" \\\n- DEVELOPMENT_TEAM=\"${THALI_TEST_DEVELOPMENT_TEAM:-3648SALNRR}\" \\\n+ DEVELOPMENT_TEAM=\"${THALI_TEST_DEVELOPMENT_TEAM:-65Y83XEN2Z}\" \\\n)\necho \"end building ${PROJECT_NAME} iOS app\"\n" } ]
JavaScript
MIT License
thaliproject/thali_cordovaplugin
Temporarily change teamID for building.
675,379
05.05.2017 11:58:23
-10,800
90e5494b3212350d7cb7ef946c5b9d8fa62189d5
Reduce the min number of devices to test.
[ { "change_type": "MODIFY", "old_path": "test/TestServer/config/UnitTest.js", "new_path": "test/TestServer/config/UnitTest.js", "diff": "@@ -13,9 +13,9 @@ module.exports = {\n},\nminDevices: {\n// This is a list of desired platforms.\n- ios: 3,\n- android: 3,\n- desktop: 3\n+ ios: 2,\n+ android: 0,\n+ desktop: 0\n},\n// if 'devices[platform]' is -1 we wont limit the amount of devices.\n// We will wait some amount of time before tests.\n" } ]
JavaScript
MIT License
thaliproject/thali_cordovaplugin
Reduce the min number of devices to test.
675,379
05.05.2017 12:20:10
-10,800
f7b999fae9acb49cd20c4acd8b5bfb439ebb3dde
Temporarily disable running desktop tests.
[ { "change_type": "MODIFY", "old_path": "build.sh", "new_path": "build.sh", "diff": "@@ -57,17 +57,17 @@ then\nnode CITestMode.js\nfi\n-echo \"\"\n-echo \"run desktop tests\"\n-jx runTests.js --networkType WIFI\n-jx runTests.js --networkType NATIVE\n-jx runTests.js --networkType BOTH\n-jx npm run test-meta\n-jx runCoordinatedTests.js --networkType NATIVE\n-jx runCoordinatedTests.js --networkType WIFI\n-jx runCoordinatedTests.js --networkType BOTH\n-echo \"end desktop tests\"\n-echo \"\"\n+#echo \"\"\n+#echo \"run desktop tests\"\n+#jx runTests.js --networkType WIFI\n+#jx runTests.js --networkType NATIVE\n+#jx runTests.js --networkType BOTH\n+#jx npm run test-meta\n+#jx runCoordinatedTests.js --networkType NATIVE\n+#jx runCoordinatedTests.js --networkType WIFI\n+#jx runCoordinatedTests.js --networkType BOTH\n+#echo \"end desktop tests\"\n+#echo \"\"\n# Verify that docs can be generated\n#cd $WORKING_DIR/thali/\n" } ]
JavaScript
MIT License
thaliproject/thali_cordovaplugin
Temporarily disable running desktop tests.
675,379
08.05.2017 12:21:50
-10,800
9c298a93140a3b0527b41c81db5fa2333ca73b8e
Update framework output dir paths in nativeInstaller.js.
[ { "change_type": "MODIFY", "old_path": "thali/install/ios/nativeInstaller.js", "new_path": "thali/install/ios/nativeInstaller.js", "diff": "@@ -324,7 +324,8 @@ function buildFramework(projectDir, outputDir, buildWithTests) {\n})\n.then(function () {\nvar cocoaAsyncSocketFrameworkBuildDir = path.join(\n- projectDir, 'Carthage', 'Build', 'iOS', cocoaAsyncSocketFrameworkName + '.framework');\n+ projectDir, 'build', projectConfiguration + '-' + sdk,\n+ cocoaAsyncSocketFrameworkName + '.framework');\nvar frameworkOutputDir = path.join(\noutputDir, cocoaAsyncSocketFrameworkName + '.framework');\n@@ -336,7 +337,8 @@ function buildFramework(projectDir, outputDir, buildWithTests) {\n})\n.then(function () {\nvar swiftXCTestFrameworkBuildDir = path.join(\n- projectDir, 'Carthage', 'Build', 'iOS', XCTestFrameworkName + '.framework');\n+ projectDir, 'build', projectConfiguration + '-' + sdk,\n+ XCTestFrameworkName + '.framework');\nvar frameworkOutputDir = path.join(\noutputDir, XCTestFrameworkName + '.framework');\n" } ]
JavaScript
MIT License
thaliproject/thali_cordovaplugin
Update framework output dir paths in nativeInstaller.js.
675,379
08.05.2017 12:24:46
-10,800
b8625ca5093be7cb79ed8e536ab1d431a912af37
Disable embedding/copying of SwiftXCTest framework in Release mode.
[ { "change_type": "MODIFY", "old_path": "thali/install/ios/nativeInstaller.js", "new_path": "thali/install/ios/nativeInstaller.js", "diff": "@@ -163,16 +163,18 @@ function updateProjectFrameworks(\npath.join(frameworkOutputDir, 'ThaliCore.framework'),\n{customFramework: true, embed: true, link: true, sign: true});\n- console.log('Adding SwiftXCTest.framework');\n+ console.log('Adding CocoaAsyncSocket.framework');\nxcodeProject.addFramework(\n- path.join(frameworkOutputDir, 'SwiftXCTest.framework'),\n+ path.join(frameworkOutputDir, 'CocoaAsyncSocket.framework'),\n{customFramework: true, embed: true, link: true, sign: true});\n- console.log('Adding CocoaAsyncSocket.framework');\n+ if (buildWithTests) {\n+ console.log('Adding SwiftXCTest.framework');\nxcodeProject.addFramework(\n- path.join(frameworkOutputDir, 'CocoaAsyncSocket.framework'),\n+ path.join(frameworkOutputDir, 'SwiftXCTest.framework'),\n{customFramework: true, embed: true, link: true, sign: true});\n}\n+}\nfunction updateProjectTestingInfrastructure(\nxcodeProject, testingInfrastructureDir, buildWithTests) {\n@@ -336,6 +338,14 @@ function buildFramework(projectDir, outputDir, buildWithTests) {\nreturn fs.copy(cocoaAsyncSocketFrameworkBuildDir, frameworkOutputDir, { clobber: false });\n})\n.then(function () {\n+ if (!buildWithTests) {\n+ // Don't cope SwiftXCTest framework\n+ // if the plugin was built without tests (release mode).\n+ return new Promise(function (resolve) {\n+ resolve();\n+ })\n+ }\n+\nvar swiftXCTestFrameworkBuildDir = path.join(\nprojectDir, 'build', projectConfiguration + '-' + sdk,\nXCTestFrameworkName + '.framework');\n" } ]
JavaScript
MIT License
thaliproject/thali_cordovaplugin
Disable embedding/copying of SwiftXCTest framework in Release mode.
675,379
08.05.2017 12:26:40
-10,800
ed5c4d7d7683f9cf0dcde5a9c8097ad39d4ef2a4
Improve carthage usage.
[ { "change_type": "MODIFY", "old_path": "thali/install/ios/nativeInstaller.js", "new_path": "thali/install/ios/nativeInstaller.js", "diff": "@@ -251,8 +251,11 @@ function addFramework(\nfunction checkoutThaliCoreViaCarthage(cartfileDir, outputDir, buildWithTests) {\nvar cdToCartfileDirCmd = 'cd ' + cartfileDir;\n+ var removeCarthageDirCmd = 'rm -rf Carthage/';\nvar carthageCmd = 'carthage update --no-build';\n- var checkoutCmd = cdToCartfileDirCmd + ' && ' + carthageCmd;\n+ var checkoutCmd = cdToCartfileDirCmd + ' && ' +\n+ removeCarthageDirCmd + ' && ' +\n+ carthageCmd;\nconsole.log('Checkouting ThaliCore and its dependencies via carthage.\\n' +\n'Cartfile in: ' + cartfileDir + '\\n' +\n" } ]
JavaScript
MIT License
thaliproject/thali_cordovaplugin
Improve carthage usage.
675,379
08.05.2017 12:44:38
-10,800
aa8aed25761b1fc5a17d277cdc33f8fe08fccb06
Add xcconfig to be able use correct compiler options. Update setUpTests.sh script.
[ { "change_type": "ADD", "old_path": null, "new_path": "thali/install/ios/build-ci-no-tests.xcconfig", "diff": "+//\n+// Licensed to the Apache Software Foundation (ASF) under one\n+// or more contributor license agreements. See the NOTICE file\n+// distributed with this work for additional information\n+// regarding copyright ownership. The ASF licenses this file\n+// to you under the Apache License, Version 2.0 (the\n+// \"License\"); you may not use this file except in compliance\n+// with the License. You may obtain a copy of the License at\n+//\n+// http://www.apache.org/licenses/LICENSE-2.0\n+//\n+// Unless required by applicable law or agreed to in writing,\n+// software distributed under the License is distributed on an\n+// \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\n+// KIND, either express or implied. See the License for the\n+// specific language governing permissions and limitations\n+// under the License.\n+//\n+\n+//\n+// XCode Build settings for \"Release\" Build Configuration.\n+//\n+\n+HEADER_SEARCH_PATHS = \"$(TARGET_BUILD_DIR)/usr/local/lib/include\" \"$(OBJROOT)/UninstalledProducts/include\" \"$(OBJROOT)/UninstalledProducts/$(PLATFORM_NAME)/include\" \"$(BUILT_PRODUCTS_DIR)\"\n+IPHONEOS_DEPLOYMENT_TARGET = 10.0\n+OTHER_LDFLAGS = -ObjC\n+TARGETED_DEVICE_FAMILY = 1,2\n+SWIFT_VERSION = 3.0\n+\n+// Type of signing identity used for codesigning, resolves to first match of given type.\n+// \"iPhone Developer\": Development builds (default, local only; iOS Development certificate) or \"iPhone Distribution\": Distribution builds (Adhoc/In-House/AppStore; iOS Distribution certificate)\n+CODE_SIGN_IDENTITY = iPhone Developer\n+CODE_SIGN_IDENTITY[sdk=iphoneos*] = iPhone Developer\n+\n+// (CB-9721) Set ENABLE_BITCODE to NO in build.xcconfig\n+ENABLE_BITCODE = NO\n+\n+// (CB-9719) Set CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES to YES in build.xcconfig\n+CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES = YES\n+\n+// (CB-10072)\n+SWIFT_OBJC_BRIDGING_HEADER = $(PROJECT_DIR)/$(PROJECT_NAME)/Bridging-Header.h\n+\n+// CI Required\n+\n+// BluetoothManager private API requires build with embedded arm64 architecture\n+ONLY_ACTIVE_ARCH = NO\n+\n+EMBEDDED_CONTENT_CONTAINS_SWIFT = YES\n+GCC_PREPROCESSOR_DEFINITIONS = $(inherited) DEBUG=1\n+LD_RUNPATH_SEARCH_PATHS = $(inherited) @executable_path/Frameworks\n+OTHER_SWIFT_FLAGS = $(inherited)\n" }, { "change_type": "MODIFY", "old_path": "thali/install/setUpTests.sh", "new_path": "thali/install/setUpTests.sh", "diff": "@@ -177,10 +177,17 @@ build_ios_if_possible()\ncordova prepare ios --device\n+ CI_CONFIG=\"build-ci-no-tests\"\n+ if [ -f \"platforms/ios/unittests\" ]\n+ then\n+ CI_CONFIG=\"build-ci.xcconfig\"\n+ fi\n+\n+\n(\\\ncd $IOS_PROJECT_DIR && \\\nxcodebuild \\\n- -xcconfig $REPO_ROOT_DIR/thali/install/ios/build-ci.xcconfig \\\n+ -xcconfig $REPO_ROOT_DIR/thali/install/ios/\"${CI_CONFIG}\" \\\n-workspace $PROJECT_NAME.xcworkspace \\\n-scheme $PROJECT_NAME \\\n-configuration Debug \\\n" } ]
JavaScript
MIT License
thaliproject/thali_cordovaplugin
Add xcconfig to be able use correct compiler options. Update setUpTests.sh script.
675,379
08.05.2017 16:14:19
-10,800
283176903b6a380447583f56dbdfc3a4bba8f259
Replace socket.end() call with socket.destroy() in order to completely close connection on the server side.
[ { "change_type": "MODIFY", "old_path": "test/www/jxcore/bv_tests/testThaliMobileNative.js", "new_path": "test/www/jxcore/bv_tests/testThaliMobileNative.js", "diff": "@@ -339,10 +339,10 @@ function shiftData (t, sock, exchangeData) {\nsock.on('data', function (chunk) {\nreceivedData += chunk.toString();\nif (receivedData === exchangeData) {\n- sock.end();\n+ sock.destroy();\n}\n});\n- sock.on('end', function () {\n+ sock.on('close', function () {\nresolve();\n});\n" } ]
JavaScript
MIT License
thaliproject/thali_cordovaplugin
Replace socket.end() call with socket.destroy() in order to completely close connection on the server side.
675,379
08.05.2017 16:14:52
-10,800
e2c290094b2796dca4ef508d3b28296ac7254968
Increase data length to transfer.
[ { "change_type": "MODIFY", "old_path": "test/www/jxcore/bv_tests/testThaliMobileNative.js", "new_path": "test/www/jxcore/bv_tests/testThaliMobileNative.js", "diff": "@@ -429,7 +429,7 @@ test('Can shift data via parallel connections',\n},\nfunction (t) {\nvar connecting = false;\n- var dataLength = 10000;\n+ var dataLength = 16 * 1024;\nvar server = createServer(t, dataLength);\nserver = makeIntoCloseAllServer(server);\n@@ -472,7 +472,8 @@ test('Can shift data via parallel connections',\ntest('Can shift data securely', function (t) {\nvar connecting = false;\n- var exchangeData = 'small amount of data';\n+ var dataSize = 16 * 1024;\n+ var exchangeData = randomString.generate(dataSize);\nvar pskKey = new Buffer('psk-key');\nvar pskId = 'psk-id';\n@@ -602,7 +603,7 @@ test('Can shift large amounts of data', function (t) {\nechoServer = makeIntoCloseAllServer(echoServer);\nserverToBeClosed = echoServer;\n- var dataSize = 4096;\n+ var dataSize = 64 * 1024;\nvar toSend = randomString.generate(dataSize);\nfunction shiftData(sock) {\n" } ]
JavaScript
MIT License
thaliproject/thali_cordovaplugin
Increase data length to transfer.
675,379
08.05.2017 16:29:23
-10,800
dac6cb45d1157493dd9652f58ac7275ccbc86945
Add another check to be able to catch an error when we received more data than other side sent to us.
[ { "change_type": "MODIFY", "old_path": "test/www/jxcore/bv_tests/testThaliMobileNative.js", "new_path": "test/www/jxcore/bv_tests/testThaliMobileNative.js", "diff": "@@ -343,6 +343,7 @@ function shiftData (t, sock, exchangeData) {\n}\n});\nsock.on('close', function () {\n+ t.equal(receivedData, exchangeData, 'got the same data back');\nresolve();\n});\n" } ]
JavaScript
MIT License
thaliproject/thali_cordovaplugin
Add another check to be able to catch an error when we received more data than other side sent to us.
675,379
08.05.2017 20:04:05
-10,800
56b2e742aaaf3d3ec2fc93615969ecc6a6a21d30
Fix issue with environment variable.
[ { "change_type": "MODIFY", "old_path": "thali/install/setUpTests.sh", "new_path": "thali/install/setUpTests.sh", "diff": "@@ -177,7 +177,7 @@ build_ios_if_possible()\ncordova prepare ios --device\n- CI_CONFIG=\"build-ci-no-tests\"\n+ CI_CONFIG=\"build-ci-no-tests.xcconfig\"\nif [ -f \"platforms/ios/unittests\" ]\nthen\nCI_CONFIG=\"build-ci.xcconfig\"\n" } ]
JavaScript
MIT License
thaliproject/thali_cordovaplugin
Fix issue with environment variable.
675,379
15.05.2017 10:43:33
-10,800
000941d6cbadcd242c1636e69fa3d4ae4396cd17
Fixed missing closing parenthesis.
[ { "change_type": "MODIFY", "old_path": "test/www/jxcore/bv_tests/testThaliMobileNative.js", "new_path": "test/www/jxcore/bv_tests/testThaliMobileNative.js", "diff": "@@ -489,7 +489,7 @@ test('Can shift data via parallel connections', function (t) {\nt.fail(error.message);\n});\n});\n-}\n+});\nfunction onConnectFailure(t, error) {\nlogger.debug(error);\n" } ]
JavaScript
MIT License
thaliproject/thali_cordovaplugin
Fixed missing closing parenthesis.
675,375
17.05.2017 14:32:31
-7,200
0442466f28706bf7cb1d4bad135dac9fc8567fa6
Remove duplicated tests, restore correct implementation of 'Can shift data' after merge. 'Can shift data via parallel connection' to be tested
[ { "change_type": "MODIFY", "old_path": "test/www/jxcore/bv_tests/testThaliMobileNative.js", "new_path": "test/www/jxcore/bv_tests/testThaliMobileNative.js", "diff": "@@ -364,7 +364,14 @@ function waitForEvent(emitter, event) {\n});\n}\n+function onConnectFailure(t, error) {\n+ logger.debug(error);\n+ t.fail('Connect failed!');\n+ t.end();\n+}\n+\ntest('Can shift data', function (t) {\n+ var connecting = false;\nvar exchangeData = 'small amount of data';\nvar formatPrintableData = function (data) {\n@@ -410,12 +417,12 @@ test('Can shift data', function (t) {\nserverToBeClosed = server;\nfunction shiftData(sock) {\n+ return new Promise(function (resolve, reject) {\nsock.on('error', function (error) {\nconsole.log('Client socket error:', error.message, error.stack);\n- t.fail(error.message);\n+ reject(error);\n});\n-\nvar receivedData = '';\nsock.on('data', function (chunk) {\nreceivedData += chunk.toString();\n@@ -423,33 +430,56 @@ test('Can shift data', function (t) {\nsock.destroy();\n}\n});\n+\nsock.on('close', function () {\n- t.equal(receivedData, exchangeData, 'got the same data back');\n- t.end();\n+ resolve();\n});\nvar rawData = new Buffer(exchangeData);\n- console.log('Client sends data (%d bytes): %s',\n- rawData.length, formatPrintableData(exchangeData));\n+ logger.debug('Client sends data (%d bytes):',\n+ rawData.length);\nsock.write(rawData, function () {\n- console.log('Client data flushed');\n+ logger.debug('Client data flushed');\n+ });\n});\n}\n- server.listen(0, function () {\n- var port = server.address().port;\n- findPeerAndConnect(port).then(function (info) {\n- console.log('Native connection established. Peer:', info.peer);\n- var nativePort = info.connection.listeningPort;\n- return connect(net, { port: nativePort });\n- }).then(function (socket) {\n- shiftData(socket);\n+ function onConnectSuccess(err, connection) {\n+ var nativePort = connection.listeningPort;\n+\n+ connect(net, { port: nativePort })\n+ .then(function (socket) {\n+ return shiftData(socket);\n+ })\n+ .catch(t.fail)\n+ .then(function () {\n+ t.end();\n+ });\n+ }\n+\n+ thaliMobileNativeTestUtils.startAndListen(t, server, function (peers) {\n+ peers.forEach(function (peer) {\n+ if (peer.peerAvailable && !connecting) {\n+ connecting = true;\n+ thaliMobileNativeTestUtils.connectToPeer(peer)\n+ .then(function (connection) {\n+ onConnectSuccess(null, connection, peer);\n+ })\n+ .catch(function (error) {\n+ onConnectFailure(t, error, null, peer);\n+ });\n+ }\n});\n});\n});\n-test('Can shift data via parallel connections', function (t) {\n- var dataLength = 22;\n+test('Can shift data via parallel connections',\n+ function () {\n+ return platform.isAndroid;\n+ },\n+ function (t) {\n+ var connecting = false;\n+ var dataLength = 16 * 1024;\nvar formatPrintableData = function (data) {\nreturn data;\n@@ -489,62 +519,36 @@ test('Can shift data via parallel connections', function (t) {\nt.fail(error.message);\n});\n});\n-});\n-\n-function onConnectFailure(t, error) {\n- logger.debug(error);\n- t.fail('Connect failed!');\n- t.end();\n-}\n-\n-test('Can shift data', function (t) {\n- var connecting = false;\n- var exchangeData = 'small amount of data';\n-\n- var server = createServer(t, exchangeData.length);\nserver = makeIntoCloseAllServer(server);\nserverToBeClosed = server;\n- function onConnectSuccess(err, connection) {\n- var nativePort = connection.listeningPort;\n-\n- connect(net, { port: nativePort })\n- .then(function (socket) {\n- return shiftData(t, socket, exchangeData);\n- })\n- .catch(t.fail)\n- .then(function () {\n- t.end();\n+ function shiftData(sock, exchangeData) {\n+ return new Promise(function (resolve, reject) {\n+ sock.on('error', function (error) {\n+ console.log('Client socket error:', error.message, error.stack);\n+ reject(error);\n});\n- }\n- thaliMobileNativeTestUtils.startAndListen(t, server, function (peers) {\n- peers.forEach(function (peer) {\n- if (peer.peerAvailable && !connecting) {\n- connecting = true;\n- thaliMobileNativeTestUtils.connectToPeer(peer)\n- .then(function (connection) {\n- onConnectSuccess(null, connection, peer);\n- })\n- .catch(function (error) {\n- onConnectFailure(t, error, null, peer);\n- });\n+ var receivedData = '';\n+ sock.on('data', function (chunk) {\n+ receivedData += chunk.toString();\n+ if (receivedData === exchangeData) {\n+ sock.destroy();\n}\n});\n- });\n-});\n-test('Can shift data via parallel connections',\n- function () {\n- return platform.isAndroid;\n- },\n- function (t) {\n- var connecting = false;\n- var dataLength = 16 * 1024;\n+ sock.on('close', function () {\n+ resolve();\n+ });\n- var server = createServer(t, dataLength);\n- server = makeIntoCloseAllServer(server);\n- serverToBeClosed = server;\n+ var rawData = new Buffer(exchangeData);\n+ logger.debug('Client sends data (%d bytes):',\n+ rawData.length);\n+ sock.write(rawData, function () {\n+ logger.debug('Client data flushed');\n+ });\n+ });\n+ }\nfunction onConnectSuccess(err, connection) {\nvar nativePort = connection.listeningPort;\n@@ -556,7 +560,7 @@ test('Can shift data via parallel connections',\nreturn Promise.all(sockets.map(function (socket) {\nvar string = randomString.generate(dataLength);\nt.equal(string.length, dataLength, 'correct string length');\n- return shiftData(t, socket, string);\n+ return shiftData(socket, string);\n}));\n})\n.catch(t.fail)\n" } ]
JavaScript
MIT License
thaliproject/thali_cordovaplugin
Remove duplicated tests, restore correct implementation of 'Can shift data' after merge. 'Can shift data via parallel connection' to be tested
675,375
17.05.2017 15:12:39
-7,200
8383290aaa0f3c6c83e28d5537e2878d650f5084
Restore working 'Can shift data securely' test, move functions shiftData and createServer outside of 'Can shift data' and 'Can shift data parallel' tests
[ { "change_type": "MODIFY", "old_path": "test/www/jxcore/bv_tests/testThaliMobileNative.js", "new_path": "test/www/jxcore/bv_tests/testThaliMobileNative.js", "diff": "@@ -370,16 +370,36 @@ function onConnectFailure(t, error) {\nt.end();\n}\n-test('Can shift data', function (t) {\n- var connecting = false;\n- var exchangeData = 'small amount of data';\n+function shiftData(sock, exchangeData) {\n+ return new Promise(function (resolve, reject) {\n+ sock.on('error', function (error) {\n+ console.log('Client socket error:', error.message, error.stack);\n+ reject(error);\n+ });\n- var formatPrintableData = function (data) {\n- var ellipsis = data.length > 40 ? '...' : '';\n- return '<' + data.slice(0, 40) + ellipsis + '>';\n- };\n+ var receivedData = '';\n+ sock.on('data', function (chunk) {\n+ receivedData += chunk.toString();\n+ if (receivedData === exchangeData) {\n+ sock.destroy();\n+ }\n+ });\n+\n+ sock.on('close', function () {\n+ resolve();\n+ });\n+\n+ var rawData = new Buffer(exchangeData);\n+ logger.debug('Client sends data (%d bytes):',\n+ rawData.length);\n+ sock.write(rawData, function () {\n+ logger.debug('Client data flushed');\n+ });\n+ });\n+}\n- var server = net.createServer(function (socket) {\n+function createServer(dataLength, formatPrintableData) {\n+ return net.createServer(function (socket) {\nvar ended = false;\nvar buffer = '';\nsocket.on('data', function (chunk) {\n@@ -388,7 +408,7 @@ test('Can shift data', function (t) {\nchunk.length, formatPrintableData(chunk.toString()));\n// when received all data, send it back\n- if (buffer.length === exchangeData.length) {\n+ if (buffer.length === dataLength) {\nconsole.log('Server received all data: %s',\nformatPrintableData(buffer.toString()));\nvar rawData = new Buffer(buffer);\n@@ -413,43 +433,27 @@ test('Can shift data', function (t) {\nt.fail(error.message);\n});\n});\n- server = makeIntoCloseAllServer(server);\n- serverToBeClosed = server;\n-\n- function shiftData(sock) {\n- return new Promise(function (resolve, reject) {\n- sock.on('error', function (error) {\n- console.log('Client socket error:', error.message, error.stack);\n- reject(error);\n- });\n-\n- var receivedData = '';\n- sock.on('data', function (chunk) {\n- receivedData += chunk.toString();\n- if (receivedData === exchangeData) {\n- sock.destroy();\n}\n- });\n- sock.on('close', function () {\n- resolve();\n- });\n+test('Can shift data', function (t) {\n+ var connecting = false;\n+ var exchangeData = 'small amount of data';\n- var rawData = new Buffer(exchangeData);\n- logger.debug('Client sends data (%d bytes):',\n- rawData.length);\n- sock.write(rawData, function () {\n- logger.debug('Client data flushed');\n- });\n- });\n- }\n+ var formatPrintableData = function (data) {\n+ var ellipsis = data.length > 40 ? '...' : '';\n+ return '<' + data.slice(0, 40) + ellipsis + '>';\n+ };\n+\n+ var server = createServer(exchangeData.length, formatPrintableData);\n+ server = makeIntoCloseAllServer(server);\n+ serverToBeClosed = server;\nfunction onConnectSuccess(err, connection) {\nvar nativePort = connection.listeningPort;\nconnect(net, { port: nativePort })\n.then(function (socket) {\n- return shiftData(socket);\n+ return shiftData(socket, exchangeData);\n})\n.catch(t.fail)\n.then(function () {\n@@ -485,71 +489,10 @@ test('Can shift data via parallel connections',\nreturn data;\n};\n- var server = net.createServer(function (socket) {\n- var ended = false;\n- var buffer = '';\n- socket.on('data', function (chunk) {\n- buffer += chunk.toString();\n- console.log('Server received (%d bytes): %s',\n- chunk.length, formatPrintableData(chunk.toString()));\n-\n- // when received all data, send it back\n- if (buffer.length === dataLength) {\n- console.log('Server received all data: %s',\n- formatPrintableData(buffer.toString()));\n- var rawData = new Buffer(buffer);\n- console.log('Server sends data back to client (%d bytes): %s',\n- rawData.length, formatPrintableData(buffer));\n- socket.write(rawData, function () {\n- console.log('Server data flushed');\n- });\n- ended = true;\n- socket.end(function () {\n- console.log('Server\\'s socket stream finished');\n- });\n- }\n- });\n- socket.on('end', function () {\n- // server ends connection, not client\n- if (!ended) {\n- t.fail(new Error('Unexpected end event'));\n- }\n- });\n- socket.on('error', function (error) {\n- t.fail(error.message);\n- });\n- });\n+ var server = createServer(dataLength, formatPrintableData);\nserver = makeIntoCloseAllServer(server);\nserverToBeClosed = server;\n- function shiftData(sock, exchangeData) {\n- return new Promise(function (resolve, reject) {\n- sock.on('error', function (error) {\n- console.log('Client socket error:', error.message, error.stack);\n- reject(error);\n- });\n-\n- var receivedData = '';\n- sock.on('data', function (chunk) {\n- receivedData += chunk.toString();\n- if (receivedData === exchangeData) {\n- sock.destroy();\n- }\n- });\n-\n- sock.on('close', function () {\n- resolve();\n- });\n-\n- var rawData = new Buffer(exchangeData);\n- logger.debug('Client sends data (%d bytes):',\n- rawData.length);\n- sock.write(rawData, function () {\n- logger.debug('Client data flushed');\n- });\n- });\n- }\n-\nfunction onConnectSuccess(err, connection) {\nvar nativePort = connection.listeningPort;\nPromise.all([\n@@ -587,17 +530,7 @@ test('Can shift data via parallel connections',\ntest('Can shift data securely', function (t) {\nvar connecting = false;\n- var dataSize = 16 * 1024;\n- var exchangeData = randomString.generate(dataSize);\n-\n- var uuids = t.participants.map(function (p) { return p.uuid; });\n- assert(uuids.length === 2, 'This test requires exactly 2 devices');\n- uuids.sort();\n- var iAmFirst = (tape.uuid === uuids[0]);\n-\n- var formatPrintableData = function (data) {\n- return data;\n- };\n+ var exchangeData = 'small amount of data';\nvar pskKey = new Buffer('psk-key');\nvar pskId = 'psk-id';\n@@ -615,22 +548,21 @@ test('Can shift data securely', function (t) {\nvar buffer = '';\nsocket.on('data', function (chunk) {\nbuffer += chunk.toString();\n- console.log('Server received (%d bytes): %s',\n- chunk.length, formatPrintableData(chunk.toString()));\n+ logger.debug('Server received (%d bytes):',\n+ chunk.length);\n// when received all data, send it back\nif (buffer.length === exchangeData.length) {\n- console.log('Server received all data: %s',\n- formatPrintableData(buffer.toString()));\n+ logger.debug('Server received all data: %s', buffer);\nvar rawData = new Buffer(buffer);\n- console.log('Server sends data back to client (%d bytes): %s',\n- rawData.length, formatPrintableData(buffer));\n+ logger.debug('Server sends data back to client (%d bytes): ',\n+ rawData.length);\nsocket.write(rawData, function () {\n- console.log('Server data flushed');\n+ logger.debug('Server data flushed');\n});\nended = true;\nsocket.end(function () {\n- console.log('Server\\'s socket stream finished');\n+ logger.debug('Server\\'s socket stream finished');\n});\n}\n});\n@@ -649,16 +581,6 @@ test('Can shift data securely', function (t) {\nserver = makeIntoCloseAllServer(server);\nserverToBeClosed = server;\n- var serverStarted = new Promise(function (resolve, reject) {\n- server.once('error', reject);\n- server.listen(0, function () {\n- server.removeListener('error', reject);\n- resolve(server);\n- });\n- });\n-\n- var waitForServerEnd = waitForEvent(server, 'CLIENT_DONE');\n-\nfunction shiftData(sock) {\nsock.on('error', function (error) {\nconsole.log('Client socket error:', error.message, error.stack);\n@@ -668,18 +590,21 @@ test('Can shift data securely', function (t) {\nvar receivedData = '';\nsock.on('data', function (chunk) {\nreceivedData += chunk.toString();\n+ if (receivedData === exchangeData) {\n+ sock.destroy();\n+ }\n});\n- sock.on('end', function () {\n+ sock.on('close', function () {\nt.equal(receivedData, exchangeData, 'got the same data back');\n});\nvar rawData = new Buffer(exchangeData);\n- console.log('Client sends data (%d bytes): %s',\n- rawData.length, formatPrintableData(exchangeData));\n+ logger.debug('Client sends data (%d bytes):',\n+ rawData.length);\nsock.write(rawData, function () {\n- console.log('Client data flushed');\n+ logger.debug('Client data flushed');\n});\n- return waitForEvent(sock, 'end');\n+ return waitForEvent(sock, 'close');\n}\nfunction startShiftData(port) {\n@@ -687,36 +612,36 @@ test('Can shift data securely', function (t) {\nport: port,\nciphers: thaliConfig.SUPPORTED_PSK_CIPHERS,\npskIdentity: pskId,\n- pskKey: pskKey,\n+ pskKey: pskKey\n})\n.then(function (socket) {\nreturn shiftData(socket);\n});\n}\n+ function onConnectSuccess(err, connection) {\n+ var nativePort = connection.listeningPort;\n+\n+ startShiftData(nativePort)\n+ .catch(t.fail)\n+ .then(function () {\n+ t.end();\n+ });\n+ }\n- serverStarted\n- .then(function (server) {\n- var port = server.address().port;\n- console.log('Test server is listening on the %d port', port);\n- return findPeerAndConnect(port);\n+ thaliMobileNativeTestUtils.startAndListen(t, server, function (peers) {\n+ peers.forEach(function (peer) {\n+ if (peer.peerAvailable && !connecting) {\n+ connecting = true;\n+ thaliMobileNativeTestUtils.connectToPeer(peer)\n+ .then(function (connection) {\n+ onConnectSuccess(null, connection, peer);\n})\n- .then(function (info) {\n- console.log('Native connection established. Info: %s',\n- JSON.stringify(info, null, 2));\n- var nativePort = info.connection.listeningPort;\n- if (iAmFirst) {\n- return startShiftData(nativePort);\n+ .catch(function (error) {\n+ onConnectFailure(t, error, null, peer);\n+ });\n}\n- return waitForServerEnd.then(function () {\n- return startShiftData(nativePort);\n});\n- })\n- .catch(function (err) {\n- t.fail(err.message + '\\n' + err.stack);\n- })\n- .then(function () {\n- t.end();\n});\n});\n@@ -810,7 +735,6 @@ test('Can shift large amounts of data', function (t) {\n});\nechoServer.listen(0, function () {\n-\nvar applicationPort = echoServer.address().port;\nMobile('startUpdateAdvertisingAndListening').callNative(applicationPort,\n" } ]
JavaScript
MIT License
thaliproject/thali_cordovaplugin
Restore working 'Can shift data securely' test, move functions shiftData and createServer outside of 'Can shift data' and 'Can shift data parallel' tests
675,371
19.05.2017 10:16:50
-7,200
f9539cc6404067ee40155c8d0cc07ef6a43dd74f
Update jxcore-cordova to 0.1.12 version
[ { "change_type": "MODIFY", "old_path": "thali/install/validateBuildEnvironment.js", "new_path": "thali/install/validateBuildEnvironment.js", "diff": "@@ -21,7 +21,7 @@ const versions =\nbrew: '1.1.',\nruby: '2.3.0p0',\nwget: '1.18',\n- jxcore: '0.3.1.10',\n+ jxcore: '0.3.1.12',\nandroidHome: ' ',\nandroidBuildTools: thaliConfig.thaliInstall.androidConfig.buildToolsVersion,\nandroidPlatform: thaliConfig.thaliInstall.androidConfig.compileSdkVersion,\n" }, { "change_type": "MODIFY", "old_path": "thali/package.json", "new_path": "thali/package.json", "diff": "\"compileSdkVersion\": \"android-25\"\n},\n\"btconnectorlib2\": \"0.3.9\",\n- \"jxcore-cordova\": \"0.1.11\",\n- \"jxcore-cordova-url\": \"http://jxcore.azureedge.net/jxcore-cordova/0.1.11/release/io.jxcore.node.jx\"\n+ \"jxcore-cordova\": \"0.1.12\",\n+ \"jxcore-cordova-url\": \"http://jxcore.azureedge.net/jxcore-cordova/0.1.12/release/io.jxcore.node.jx\"\n},\n\"scripts\": {\n\"prepublish\": \"node install/prePublishThaliCordovaPlugin.js\",\n" } ]
JavaScript
MIT License
thaliproject/thali_cordovaplugin
Update jxcore-cordova to 0.1.12 version
675,375
23.05.2017 11:56:57
-7,200
677ded75cb1aa62448ddd032c285346ec530ab5a
Fix failing test on iOS devices
[ { "change_type": "MODIFY", "old_path": "test/www/jxcore/bv_tests/testThaliMobile.js", "new_path": "test/www/jxcore/bv_tests/testThaliMobile.js", "diff": "@@ -1019,7 +1019,7 @@ test('networkChanged - fires peerAvailabilityChanged event for native peers ' +\nfunction disableBluetooth() {\nThaliMobileNativeWrapper.emitter.emit('networkChangedNonTCP', {\nwifi: radioState.ON,\n- bssidName: null,\n+ bssidName: '00:00:00:00:00:00',\nbluetoothLowEnergy: radioState.ON,\nbluetooth: radioState.OFF,\ncellular: radioState.ON\n@@ -1062,6 +1062,9 @@ test('networkChanged - fires peerAvailabilityChanged event for native peers ' +\nif (!disableWifiCalled) {\nt.fail('Got peerAvailabilityChanged before wifi was disabled');\n}\n+ t.equals(peerStatus.peerAvailable, false, 'peer became unavailable');\n+ break;\n+ case 4:\nt.equals(peerStatus.peerAvailable, false, 'peer became unavailable');\nsetImmediate(end);\nbreak;\n@@ -1079,8 +1082,12 @@ test('networkChanged - fires peerAvailabilityChanged event for native peers ' +\nt.end();\n}\n+ // Make sure ThaliMobile is started before we begin this test, otherwise emitted event `networkChangedNonTCP`\n+ // will be filtered out.\n+ ThaliMobile.start(express.Router()).then(function () {\n// Add initial peers\nemitNativePeerAvailability(testPeers.nativePeer);\n+ });\n}\n);\n" } ]
JavaScript
MIT License
thaliproject/thali_cordovaplugin
Fix failing test on iOS devices
675,375
23.05.2017 12:51:46
-7,200
817111916cff9e087794027b090caf21cf3eef0f
Add catch clause to ThaliMobile.start function
[ { "change_type": "MODIFY", "old_path": "test/www/jxcore/bv_tests/testThaliMobile.js", "new_path": "test/www/jxcore/bv_tests/testThaliMobile.js", "diff": "@@ -1087,6 +1087,9 @@ test('networkChanged - fires peerAvailabilityChanged event for native peers ' +\nThaliMobile.start(express.Router()).then(function () {\n// Add initial peers\nemitNativePeerAvailability(testPeers.nativePeer);\n+ }).catch(function (err) {\n+ t.fail('ThaliMobile couldn\\'t be started!');\n+ end();\n});\n}\n);\n" } ]
JavaScript
MIT License
thaliproject/thali_cordovaplugin
Add catch clause to ThaliMobile.start function
675,375
25.05.2017 14:36:36
-7,200
e1dea66aa05838211a531dfad9c2747d33aa7d33
Add possibility to pass remote db name that we are trying to replicate with during runtime when starting ThaliReplicationPeerAction
[ { "change_type": "MODIFY", "old_path": "test/www/jxcore/bv_tests/testThaliReplicationPeerAction.js", "new_path": "test/www/jxcore/bv_tests/testThaliReplicationPeerAction.js", "diff": "@@ -466,8 +466,8 @@ test('Make sure clone works', function (t) {\n'same getPeerAdvertisesDataForUs');\nt.equal(clonedAction._PouchDB, originalThaliReplicationAction._PouchDB,\n'Same pouchdB');\n- t.equal(clonedAction._dbName, originalThaliReplicationAction._dbName,\n- 'same dbName');\n+ t.equal(clonedAction._localDbName, originalThaliReplicationAction._localDbName,\n+ 'same localDbName');\nt.equal(clonedAction._ourPublicKey,\noriginalThaliReplicationAction._ourPublicKey, 'Same public key');\nt.end();\n" }, { "change_type": "MODIFY", "old_path": "thali/NextGeneration/replication/thaliPullReplicationFromNotification.js", "new_path": "thali/NextGeneration/replication/thaliPullReplicationFromNotification.js", "diff": "@@ -39,30 +39,26 @@ var ThaliReplicationPeerAction = require('./thaliReplicationPeerAction');\n* the same peer over two different transports and to then pick which one it\n* prefers (if any, maybe it wants both).\n*\n- * BUGBUG: In the interests of time we currently will only support replicating\n- * data from a single remote database for all users. This is clearly silly and\n- * we should move to a model where each user can have multiple databases\n- * specified for them.\n- *\n* @public\n* @param {PouchDB} PouchDB The factory we will use to create the database we\n* will replicate all changes to.\n- * @param {string} dbName The name of the DB. The name of the remote DB MUST be\n+ * @param {string} localDbName The name of the local DB. The name of the remote DB could be either\n* http://[host from discovery]:[port from discovery]/[BASE_DB_PATH]/[name] where name is\n- * taken from pouchDB.info's db_name field.\n+ * taken from pouchDB.info's db_name field or where name is provided during runtime to\n+ * ThaliReplicationPeerAction when it is being started.\n* @param {module:thaliPeerPoolInterface~ThaliPeerPoolInterface} thaliPeerPoolInterface\n* @param {Crypto.ECDH} ecdhForLocalDevice A Crypto.ECDH object initialized\n* with the local device's public and private keys.\n* @constructor\n*/\nfunction ThaliPullReplicationFromNotification(PouchDB,\n- dbName,\n+ localDbName,\nthaliPeerPoolInterface,\necdhForLocalDevice) {\nEventEmitter.call(this);\nassert(PouchDB, 'Must have PouchDB');\n- assert(dbName, 'Must have dbName');\n+ assert(localDbName, 'Must have localDbName');\nassert(thaliPeerPoolInterface, 'Must have thaliPeerPoolInterface');\nassert(ecdhForLocalDevice, 'Must have ecdhForLocalDeivce');\n@@ -71,7 +67,7 @@ function ThaliPullReplicationFromNotification(PouchDB,\nthis._thaliPeerPoolInterface = thaliPeerPoolInterface;\nthis._publicKey = ecdhForLocalDevice.getPublicKey();\nthis._PouchDB = PouchDB;\n- this._dbName = dbName;\n+ this._localDbName = localDbName;\nthis._boundAdvertiser = this._peerAdvertisesDataForUsHandler.bind(this);\nthis._peerDictionary = {};\n@@ -135,7 +131,7 @@ ThaliPullReplicationFromNotification.prototype._peerAdvertisesDataForUsHandler =\n}\nvar newAction = new ThaliReplicationPeerAction(\n- peerAdvertisesData, this._PouchDB, this._dbName, this._publicKey\n+ peerAdvertisesData, this._PouchDB, this._localDbName, this._publicKey\n);\nassert(\n!this._peerDictionary[key],\n" }, { "change_type": "MODIFY", "old_path": "thali/NextGeneration/replication/thaliReplicationPeerAction.js", "new_path": "thali/NextGeneration/replication/thaliReplicationPeerAction.js", "diff": "@@ -24,17 +24,17 @@ var Utils = require('../utils/common.js');\n* need for the base class's constructor.\n* @param {PouchDB} PouchDB The PouchDB class constructor we are supposed to\n* use.\n- * @param {string} dbName The name of the DB we will use both for local use as\n- * well as remote use. Note that we will get the name for the remote database by\n- * taking dbName and appending it to http://[hostAddress]:[portNumber]/[BASE_DB_PATH]/\n- * [name] where hostAddress and portNumber are from the peerAdvertisesDataForUs\n- * argument.\n+ * @param {string} localDbName The name of the DB which is dedicated for local usage.\n+ * Remote DB url will be created either using localDbName parameter or remoteDbName\n+ * parameter, which is provided to ThaliReplicationPeerAction.start method during runtime,\n+ * and appending it to http://[hostAddress]:[portNumber]/[BASE_DB_PATH]/[name] where hostAddress\n+ * and portNumber are from the peerAdvertisesDataForUs argument.\n* @param {Buffer} ourPublicKey The buffer containing our ECDH public key\n* @constructor\n*/\nfunction ThaliReplicationPeerAction(peerAdvertisesDataForUs,\nPouchDB,\n- dbName,\n+ localDbName,\nourPublicKey) {\nassert(ThaliReplicationPeerAction.MAX_IDLE_PERIOD_SECONDS * 1000 -\nThaliReplicationPeerAction.PUSH_LAST_SYNC_UPDATE_MILLISECONDS >\n@@ -42,7 +42,7 @@ function ThaliReplicationPeerAction(peerAdvertisesDataForUs,\n'that at least one sync update will have gone out before we time out.');\nassert(peerAdvertisesDataForUs, 'there must be peerAdvertisesDataForUs');\nassert(PouchDB, 'there must be PouchDB');\n- assert(dbName, 'there must be dbName');\n+ assert(localDbName, 'there must be localDbName');\nassert(ourPublicKey, 'there must be an ourPublicKey');\nThaliReplicationPeerAction.super_.call(this, peerAdvertisesDataForUs.keyId,\n@@ -53,7 +53,7 @@ function ThaliReplicationPeerAction(peerAdvertisesDataForUs,\nthis._peerAdvertisesDataForUs = peerAdvertisesDataForUs;\nthis._PouchDB = PouchDB;\n- this._dbName = dbName;\n+ this._localDbName = localDbName;\nthis._ourPublicKey = ourPublicKey;\nthis._localSeqManager = null;\nthis._cancelReplication = null;\n@@ -107,7 +107,7 @@ ThaliReplicationPeerAction.prototype.getPeerAdvertisesDataForUs = function () {\n*/\nThaliReplicationPeerAction.prototype.clone = function () {\nreturn new ThaliReplicationPeerAction(this._peerAdvertisesDataForUs,\n- this._PouchDB, this._dbName, this._ourPublicKey);\n+ this._PouchDB, this._localDbName, this._ourPublicKey);\n};\n/**\n@@ -190,9 +190,15 @@ ThaliReplicationPeerAction.prototype._replicationTimer = function () {\n* @param {http.Agent} httpAgentPool This is the HTTP connection pool to use\n* when creating HTTP requests related to this action. Note that this is where\n* the PSK related settings are specified.\n+ * @param {string} remoteDbName The name of remote DB that we will try to replicate\n+ * with. This parameter is used to create a proper url to remote database. If it is\n+ * not provided, for example by ThaliPeerPoolInterface custom implementation,\n+ * we assume that the remote DB name is the same as our local one.\n+ * The reason why it is not provided in constructor is that at the time of creating\n+ * instance of this object, we simply don't know such information.\n* @returns {Promise<?Error>}\n*/\n-ThaliReplicationPeerAction.prototype.start = function (httpAgentPool) {\n+ThaliReplicationPeerAction.prototype.start = function (httpAgentPool, remoteDbName) {\nvar self = this;\nthis._completed = false;\n@@ -201,7 +207,7 @@ ThaliReplicationPeerAction.prototype.start = function (httpAgentPool) {\n.then(function () {\nvar remoteUrl = 'https://' + self._peerAdvertisesDataForUs.hostAddress +\n':' + self._peerAdvertisesDataForUs.portNumber +\n- path.join(thaliConfig.BASE_DB_PATH, self._dbName);\n+ path.join(thaliConfig.BASE_DB_PATH, !!remoteDbName ? remoteDbName : self._localDbName);\nvar ajaxOptions = {\najax : {\nagent: httpAgentPool\n@@ -217,7 +223,7 @@ ThaliReplicationPeerAction.prototype.start = function (httpAgentPool) {\nself._resolve = resolve;\nself._reject = reject;\nself._replicationTimer();\n- self._cancelReplication = remoteDB.replicate.to(self._dbName, {\n+ self._cancelReplication = remoteDB.replicate.to(self._localDbName, {\nlive: true\n})\n.on('paused', function (err) {\n" }, { "change_type": "MODIFY", "old_path": "thali/NextGeneration/thaliManager.js", "new_path": "thali/NextGeneration/thaliManager.js", "diff": "@@ -27,7 +27,7 @@ var assert = require('assert');\n* dbs. Typically this should have PouchDB.defaults set with db to\n* require('leveldown-mobile') and prefix to the path where the application\n* wishes to store the DB.\n- * @param {string} dbName Name of the db, both locally and remotely that we are\n+ * @param {string} localDbName Name of the db that we , both locally and remotely that we are\n* interacting with.\n* @param {Crypto.ECDH} ecdhForLocalDevice A Crypto.ECDH object initialized with\n* the local device's public and private keys.\n@@ -42,7 +42,7 @@ var assert = require('assert');\nfunction ThaliManager(\nexpressPouchDB,\nPouchDB,\n- dbName,\n+ localDbName,\necdhForLocalDevice,\nthaliPeerPoolInterface,\nnetworkType\n@@ -53,7 +53,7 @@ function ThaliManager(\nthis._router.all('*', this._connectionFilter.bind(this));\nthis._router.all('*', salti(\n- dbName,\n+ localDbName,\nThaliManager._acl,\nthis._resolveThaliId.bind(this),\n{ dbPrefix: thaliConfig.BASE_DB_PATH }\n@@ -66,7 +66,7 @@ function ThaliManager(\nthis._router,\necdhForLocalDevice,\nthaliConfig.BEACON_MILLISECONDS_TO_EXPIRE,\n- new PouchDB(dbName));\n+ new PouchDB(localDbName));\nthis._getPskIdToSecret =\nself._thaliSendNotificationBasedOnReplication.getPskIdToSecret();\nthis._getPskIdToPublicKey =\n@@ -77,7 +77,7 @@ function ThaliManager(\nthis._thaliPullReplicationFromNotification =\nnew ThaliPullReplicationFromNotification(\nPouchDB,\n- dbName,\n+ localDbName,\nthaliPeerPoolInterface,\necdhForLocalDevice);\nthis._thaliPeerPoolInterface = thaliPeerPoolInterface;\n" } ]
JavaScript
MIT License
thaliproject/thali_cordovaplugin
Add possibility to pass remote db name that we are trying to replicate with during runtime when starting ThaliReplicationPeerAction
675,375
26.05.2017 16:02:28
-7,200
31d3bc8f937ec37239d3e500943325b79f9dbd28
Add tests, make remoteDbName param as optional, enable tests in testThaliReplicationPeerAction that were disabled due to
[ { "change_type": "MODIFY", "old_path": "test/www/jxcore/bv_tests/testThaliManagerCoordinated.js", "new_path": "test/www/jxcore/bv_tests/testThaliManagerCoordinated.js", "diff": "@@ -26,7 +26,8 @@ var ecdhForLocalDevice = crypto.createECDH(thaliConfig.BEACON_CURVE);\nvar publicKeyForLocalDevice = ecdhForLocalDevice.generateKeys();\nvar publicBase64KeyForLocalDevice = ecdhForLocalDevice.getPublicKey('base64');\n-// PouchDB name should be the same between peers.\n+// PouchDB name can be the same between peers or can be provided directly to\n+// ThaliReplicationPeerAction.start.\nvar DB_NAME = 'ThaliManagerCoordinated';\nPouchDB = testUtils.getLevelDownPouchDb();\n" }, { "change_type": "MODIFY", "old_path": "test/www/jxcore/bv_tests/testThaliReplicationPeerAction.js", "new_path": "test/www/jxcore/bv_tests/testThaliReplicationPeerAction.js", "diff": "@@ -221,11 +221,7 @@ function matchDocsInChanges(pouchDB, docs, thaliPeerReplicationAction) {\n});\n}\n-test('Make sure docs replicate',\n- function () {\n- // FIXME: iOS is too slow for this test (#1618)\n- return platform._isRealIOS;\n- },\n+test('Make sure docs replicate with remote db with same name as local db',\nfunction (t) {\ntestCloseAllServer = testUtils.setUpServer(function (serverPort,\nrandomDBName,\n@@ -275,11 +271,58 @@ test('Make sure docs replicate',\n});\n});\n+test('Make sure docs replicate with remote db with different name than local db',\n+ function (t) {\n+ testCloseAllServer = testUtils.setUpServer(function (serverPort,\n+ randomRemoteDBName,\n+ remotePouchDB) {\n+ var thaliReplicationPeerAction = null;\n+ var DifferentDirectoryPouch = testUtils.getLevelDownPouchDb();\n+ var localDBName = testUtils.getRandomPouchDBName();\n+ var localPouchDB = new DifferentDirectoryPouch(localDBName);\n+ createDocs(remotePouchDB, 10)\n+ .then(function (docs) {\n+ var notificationForUs = {\n+ keyId: new Buffer('abcdefg'),\n+ portNumber: serverPort,\n+ hostAddress: '127.0.0.1',\n+ pskIdentifyField: pskId,\n+ psk: pskKey,\n+ suggestedTCPTimeout: 10000,\n+ connectionType: thaliMobileNativeWrapper.connectionTypes.TCP_NATIVE\n+ };\n+ var promises = [];\n+ thaliReplicationPeerAction =\n+ new ThaliReplicationPeerAction(notificationForUs,\n+ DifferentDirectoryPouch, localDBName,\n+ devicePublicKey);\n+ promises.push(thaliReplicationPeerAction.start(httpAgentPool, randomRemoteDBName));\n+ promises.push(matchDocsInChanges(localPouchDB, docs,\n+ thaliReplicationPeerAction));\n+ return Promise.all(promises);\n+ })\n+ .then(function () {\n+ return remotePouchDB.info();\n+ })\n+ .then(function (info) {\n+ return httpTester.validateSeqNumber(t, randomRemoteDBName, serverPort,\n+ // jscs:disable requireCamelCaseOrUpperCaseIdentifiers\n+ info.update_seq, pskId, pskKey, devicePublicKey, null, 10);\n+ // jscs:enable requireCamelCaseOrUpperCaseIdentifiers\n+ })\n+ .then(function () {\n+ t.pass('All tests passed!');\n+ })\n+ .catch(function (err) {\n+ t.fail('failed with ' + err);\n+ })\n+ .then(function () {\n+ t.end();\n+ });\n+ });\n+ });\n+\ntest('Do nothing and make sure we time out',\n- function () {\n- // FIXME: iOS is too slow for this test (#1618)\n- return platform._isRealIOS;\n- },\nfunction (t) {\nfunction onServerSetUp (serverPort, randomDBName) {\nvar thaliReplicationPeerAction = null;\n@@ -330,10 +373,6 @@ test('Do nothing and make sure we time out',\n);\ntest('Do something and make sure we time out',\n- function () {\n- // FIXME: iOS is too slow for this test (#1618)\n- return platform._isRealIOS;\n- },\nfunction (t) {\nfunction onServerSetUp (serverPort, randomDBName, remotePouchDB) {\nvar thaliReplicationPeerAction = null;\n" }, { "change_type": "MODIFY", "old_path": "test/www/jxcore/bv_tests/testThaliReplicationPeerActionCoordinated.js", "new_path": "test/www/jxcore/bv_tests/testThaliReplicationPeerActionCoordinated.js", "diff": "@@ -20,7 +20,12 @@ var devicePublicPrivateKey = crypto.createECDH(thaliConfig.BEACON_CURVE);\nvar devicePublicKey = devicePublicPrivateKey.generateKeys();\nvar TestPouchDB = testUtils.getLevelDownPouchDb();\n-var DB_NAME = 'repActionTest';\n+// Use peer's public key to determine local db name. This variable is used in scenario when\n+// we want to replicate with remote db which name is different than our local db.\n+// In that case, we are able to determine peer's remote db name based on it's public key.\n+// Use hex encoding to generate string without any special characters.\n+var LOCAL_DB_NAME_BASED_ON_PUBLIC_KEY = devicePublicKey.toString('hex').slice(0, 10);\n+var LOCAL_DB_NAME = 'repActionTest';\nvar EXPIRATION_TIMEOUT = 60 * 60 * 1000;\nif (!tape.coordinated) {\n@@ -37,7 +42,7 @@ var test = tape({\n}\n});\n-test('Coordinated replication action test', function (t) {\n+test('Coordinated replication action test - each device has the same local db name', function (t) {\nvar router = express.Router();\nrouter.use(\n'/db',\n@@ -53,7 +58,7 @@ test('Coordinated replication action test', function (t) {\nvar thaliNotificationClient = new ThaliNotificationClient(\npeerPool, devicePublicPrivateKey\n);\n- var localPouchDB = new TestPouchDB(DB_NAME);\n+ var localPouchDB = new TestPouchDB(LOCAL_DB_NAME);\nvar peerActions = [];\n@@ -69,7 +74,7 @@ test('Coordinated replication action test', function (t) {\ndevicePublicKey,\nfunction (notificationForUs) {\nvar thaliReplicationPeerAction = new ThaliReplicationPeerAction(\n- notificationForUs, TestPouchDB, DB_NAME, devicePublicKey\n+ notificationForUs, TestPouchDB, LOCAL_DB_NAME, devicePublicKey\n);\npeerActions.push(thaliReplicationPeerAction);\n@@ -182,3 +187,153 @@ test('Coordinated replication action test', function (t) {\nt.end();\n});\n});\n+\n+test('Coordinated replication action test - each device has different local db name', function (t) {\n+ var router = express.Router();\n+ router.use(\n+ '/db',\n+ expressPouchDB(TestPouchDB, {\n+ mode: 'minimumForPouchDB'\n+ })\n+ );\n+ var thaliNotificationServer = new ThaliNotificationServer(\n+ router, devicePublicPrivateKey, EXPIRATION_TIMEOUT\n+ );\n+ var peerPool = new ThaliPeerPoolDefault();\n+ peerPool.start();\n+ var thaliNotificationClient = new ThaliNotificationClient(\n+ peerPool, devicePublicPrivateKey\n+ );\n+ var localPouchDB = new TestPouchDB(LOCAL_DB_NAME_BASED_ON_PUBLIC_KEY);\n+\n+ var peerActions = [];\n+\n+ localPouchDB.put({\n+ _id: JSON.stringify(devicePublicKey.toJSON())\n+ })\n+ .then(function () {\n+ return testUtils.runTestOnAllParticipants(\n+ t, router,\n+ thaliNotificationClient,\n+ thaliNotificationServer,\n+ ThaliMobile,\n+ devicePublicKey,\n+ function (notificationForUs) {\n+ var thaliReplicationPeerAction = new ThaliReplicationPeerAction(\n+ notificationForUs, TestPouchDB, LOCAL_DB_NAME_BASED_ON_PUBLIC_KEY, devicePublicKey\n+ );\n+ peerActions.push(thaliReplicationPeerAction);\n+\n+ return new Promise(function (resolve, reject) {\n+ var changes = localPouchDB.changes({\n+ since: 0,\n+ live: true\n+ });\n+\n+ var exited = false;\n+ var resultError = null;\n+ function exit(error) {\n+ if (exited) {\n+ return;\n+ }\n+ exited = true;\n+\n+ resultError = error;\n+ changes.cancel();\n+ }\n+\n+ changes.on('change', function (change) {\n+ var bufferRemoteId = new Buffer(JSON.parse(change.id));\n+ // note that the test might pass before we even start replicating\n+ // because we already have the record from someone else, that's\n+ // fine. We still guarantee at least one replication ran on each\n+ // device.\n+ if (Buffer.compare(notificationForUs.keyId, bufferRemoteId) === 0) {\n+ exit();\n+ }\n+ })\n+ .on('error', function (error) {\n+ reject(error);\n+ })\n+ .on('complete', function () {\n+ if (resultError) {\n+ reject(resultError);\n+ } else {\n+ resolve();\n+ }\n+ });\n+\n+ var httpAgentPool = new ForeverAgent.SSL({\n+ rejectUnauthorized: false,\n+ maxSockets: 8,\n+ ciphers: thaliConfig.SUPPORTED_PSK_CIPHERS,\n+ pskIdentity: thaliReplicationPeerAction.getPskIdentity(),\n+ pskKey: thaliReplicationPeerAction.getPskKey()\n+ });\n+\n+ // Use peer's public key to determine it's individual local db name\n+ var remoteDbName =\n+ thaliReplicationPeerAction.getPeerIdentifier().toString('hex').slice(0, 10);\n+\n+ thaliReplicationPeerAction.start(httpAgentPool, remoteDbName)\n+ .catch(function (error) {\n+ exit(error);\n+ });\n+ });\n+ }\n+ )\n+ })\n+\n+ .then(function () {\n+ return t.sync();\n+ })\n+\n+ .then(function () {\n+ // We are simulating thaliPullReplicationFromNotification.stop() and\n+ // thaliPeerPoolDefault.stop()\n+ thaliNotificationClient.stop();\n+ var promises = peerActions.map(function (peerAction) {\n+ peerAction.kill();\n+ return peerAction.waitUntilKilled();\n+ });\n+ return Promise.all(promises);\n+ })\n+ .then(function () {\n+ // https://github.com/thaliproject/Thali_CordovaPlugin/issues/1138\n+ // workaround for ECONNREFUSED and ECONNRESET from 'request.js' in\n+ // 'pouchdb'.\n+ return t.sync();\n+ })\n+ .then(function () {\n+ return thaliNotificationServer.stop();\n+ })\n+ .then(function () {\n+ return ThaliMobile.stop();\n+ })\n+ .then(function (combinedResult) {\n+ if (\n+ combinedResult.wifiResult !== null ||\n+ combinedResult.nativeResult !== null\n+ ) {\n+ return Promise.reject(\n+ new Error(\n+ 'Had a failure in ThaliMobile.start - ',\n+ JSON.stringify(combinedResult)\n+ )\n+ );\n+ }\n+ })\n+\n+ .then(function () {\n+ return Promise.resolve();\n+ })\n+ .then(function () {\n+ t.pass('passed');\n+ })\n+ .catch(function (error) {\n+ t.fail('failed with ' + error.toString());\n+ })\n+ .then(function () {\n+ t.end();\n+ });\n+});\n" }, { "change_type": "MODIFY", "old_path": "thali/NextGeneration/replication/thaliReplicationPeerAction.js", "new_path": "thali/NextGeneration/replication/thaliReplicationPeerAction.js", "diff": "@@ -190,12 +190,13 @@ ThaliReplicationPeerAction.prototype._replicationTimer = function () {\n* @param {http.Agent} httpAgentPool This is the HTTP connection pool to use\n* when creating HTTP requests related to this action. Note that this is where\n* the PSK related settings are specified.\n- * @param {string} remoteDbName The name of remote DB that we will try to replicate\n- * with. This parameter is used to create a proper url to remote database. If it is\n- * not provided, for example by {@link module:thaliPeerPoolInterface~ThaliPeerPoolInterface}\n- * custom implementation, we assume that the remote DB name is the same as our local one.\n- * The reason why it is not provided in constructor is that at the time of creating\n- * instance of this object, we simply don't know such information.\n+ * @param {string} [remoteDbName] Optional parameter that specifies name of remote\n+ * DB that we will try to replicate with. This parameter is used to create a proper\n+ * url to remote database. If it is not provided, for example by\n+ * {@link module:thaliPeerPoolInterface~ThaliPeerPoolInterface} custom implementation,\n+ * we assume that the remote DB name is the same as our local one. The reason why it is\n+ * not provided in constructor is that at the time of creating instance of this object,\n+ * we simply don't know such information.\n* @returns {Promise<?Error>}\n*/\nThaliReplicationPeerAction.prototype.start = function (httpAgentPool, remoteDbName) {\n" } ]
JavaScript
MIT License
thaliproject/thali_cordovaplugin
Add tests, make remoteDbName param as optional, enable tests in testThaliReplicationPeerAction that were disabled due to #1618
675,371
29.05.2017 11:57:08
-7,200
d9019468e580689767228a8616ec96ae683f3567
call 'disconnect' in teardown
[ { "change_type": "MODIFY", "old_path": "test/www/jxcore/bv_tests/testThaliMobileNative.js", "new_path": "test/www/jxcore/bv_tests/testThaliMobileNative.js", "diff": "@@ -27,6 +27,7 @@ var platform = require('thali/NextGeneration/utils/platform');\n// A variable that can be used to store a server\n// that will get closed in teardown.\nvar serverToBeClosed = null;\n+var peerIdToBeClosed = \"\";\nvar test = tape({\nsetup: function (t) {\n@@ -51,10 +52,16 @@ var test = tape({\n'Should be able to call stopAdvertisingAndListening in teardown'\n);\nthaliMobileNativeWrapper._registerToNative();\n+ Mobile('disconnect').callNative(peerIdToBeClosed, \"0\", function (err) {\n+ t.notOk(\n+ err,\n+ 'Should be able to call disconnect in teardown'\n+ );\nt.end();\n});\n});\n});\n+ });\n}\n});\n@@ -252,9 +259,10 @@ test('Can connect to a remote peer', function (t) {\nechoServer = makeIntoCloseAllServer(echoServer);\nserverToBeClosed = echoServer;\n- function onConnectSuccess(err, connection) {\n+ function onConnectSuccess(err, connection, peer) {\n// Called if we successfully connect to to a peer\nlogger.info(connection);\n+ peerIdToBeClosed = peer.peerIdentifier;\nt.ok(connection.hasOwnProperty('listeningPort'),\n'Must have listeningPort');\n@@ -432,8 +440,9 @@ test('Can shift data', function (t) {\nserver = makeIntoCloseAllServer(server);\nserverToBeClosed = server;\n- function onConnectSuccess(err, connection) {\n+ function onConnectSuccess(err, connection, peer) {\nvar nativePort = connection.listeningPort;\n+ peerIdToBeClosed = peer.peerIdentifier;\nconnect(net, { port: nativePort })\n.then(function (socket) {\n@@ -473,12 +482,13 @@ test('Can shift data via parallel connections',\nserver = makeIntoCloseAllServer(server);\nserverToBeClosed = server;\n- function onConnectSuccess(err, connection) {\n+ function onConnectSuccess(err, connection, peer) {\nvar nativePort = connection.listeningPort;\n+ peerIdToBeClosed = peer.peerIdentifier;\nPromise.all([\nconnect(net, { port: nativePort }),\nconnect(net, { port: nativePort }),\n- connect(net, { port: nativePort }),\n+ connect(net, { port: nativePort })\n]).then(function (sockets) {\nreturn Promise.all(sockets.map(function (socket) {\nvar string = randomString.generate(dataLength);\n@@ -599,8 +609,9 @@ test('Can shift data securely', function (t) {\n});\n}\n- function onConnectSuccess(err, connection) {\n+ function onConnectSuccess(err, connection, peer) {\nvar nativePort = connection.listeningPort;\n+ peerIdToBeClosed = peer.peerIdentifier;\nstartShiftData(nativePort)\n.catch(t.fail)\n@@ -683,8 +694,9 @@ test('Can shift large amounts of data', function (t) {\nsock.write(toSend);\n}\n- function onConnectSuccess(err, connection) {\n+ function onConnectSuccess(err, connection, peer) {\nvar client = null;\n+ peerIdToBeClosed = peer.peerIdentifier;\n// We're happy here if we make a connection to anyone\nlogger.info('Connection info: ' + JSON.stringify(connection));\n" } ]
JavaScript
MIT License
thaliproject/thali_cordovaplugin
call 'disconnect' in teardown
675,371
29.05.2017 12:20:25
-7,200
c5c209eebe4c5424fbfe8927c1f2a749cc3d24c4
Return a fatal error when a connection to a peer fails
[ { "change_type": "MODIFY", "old_path": "test/www/jxcore/lib/thaliMobileNativeTestUtils.js", "new_path": "test/www/jxcore/lib/thaliMobileNativeTestUtils.js", "diff": "@@ -168,7 +168,11 @@ function iOSConnectToPeer(peer, quitSignal) {\n}\nif (error) {\n- return reject(new Error(error));\n+ // Connection to a peer failed.\n+ // Return a fatal error to avoid retrying connecting to a peer that is not available anymore\n+ error = new Error(error);\n+ error.isFatal = true;\n+ return reject(error);\n}\nif (syncValue !== originalSyncValue) {\nlogger.warn(\n" } ]
JavaScript
MIT License
thaliproject/thali_cordovaplugin
Return a fatal error when a connection to a peer fails
675,375
30.05.2017 11:20:18
-7,200
a2b2d8cfb8dea87003c2c8553e0bb8c9d2705841
Enable tests that were blocked due to for iOS. Enable test on Android that was blocked due to
[ { "change_type": "MODIFY", "old_path": "test/www/jxcore/bv_tests/testLocalSeqManager.js", "new_path": "test/www/jxcore/bv_tests/testLocalSeqManager.js", "diff": "@@ -119,8 +119,7 @@ test('#_doImmediateSeqUpdate - server always returns 500', function (t) {\n});\n});\n-function validateRev(t, rev, lastSyncedSequenceNumber, randomDBName, serverPort)\n-{\n+function validateRev(t, rev, lastSyncedSequenceNumber, randomDBName, serverPort) {\nreturn httpTester.validateSeqNumber(t, randomDBName, serverPort,\nlastSyncedSequenceNumber, pskId, pskKey, devicePublicKey)\n.then(function (pouchResponse) {\n@@ -388,10 +387,8 @@ test('#update - Fail on bad seq value', function (t) {\ntest('#update - do we cancel timer properly on an immediate?', function (t) {\ntestCloseAllServer = testUtils.setUpServer(function (serverPort, randomDBName,\nremotePouchDB) {\n- // TODO: timeout should be around 1000ms but we set it much larger in order\n- // to make test pass on iOS (#1618).\nlocalSeqManager =\n- new LocalSeqManager(8000, remotePouchDB, devicePublicKey);\n+ new LocalSeqManager(1000, remotePouchDB, devicePublicKey);\nvar timerPromise = null;\nvar immediatePromise = null;\nvar lastSyncedSequenceNumber = 12;\n@@ -463,10 +460,8 @@ test('#update - do we wait for blocked update', function (t) {\nfunction testTimer(t, updateFn) {\ntestCloseAllServer = testUtils.setUpServer(function (serverPort, randomDBName,\nremotePouchDB) {\n- // TODO: timeout should be around 1000ms but we set it much larger in order\n- // to make test pass on iOS (#1618).\nlocalSeqManager =\n- new LocalSeqManager(8000, remotePouchDB, devicePublicKey);\n+ new LocalSeqManager(1000, remotePouchDB, devicePublicKey);\nvar lastSyncedSequenceNumber = 0;\nvar firstUpdateTime = Date.now();\nvar startTimeForSecondUpdate = null;\n" }, { "change_type": "MODIFY", "old_path": "test/www/jxcore/bv_tests/testThaliManagerCoordinated.js", "new_path": "test/www/jxcore/bv_tests/testThaliManagerCoordinated.js", "diff": "@@ -17,8 +17,6 @@ var thaliConfig = require('thali/NextGeneration/thaliConfig');\nvar ThaliManager = require('thali/NextGeneration/thaliManager');\nvar ThaliPeerPoolDefault =\nrequire('thali/NextGeneration/thaliPeerPool/thaliPeerPoolDefault');\n-var ThaliReplicationPeerAction =\n- require('thali/NextGeneration/replication/thaliReplicationPeerAction');\n// Public key for local device should be passed\n// to the tape 'setup' as 'tape.data'.\n@@ -26,19 +24,16 @@ var ecdhForLocalDevice = crypto.createECDH(thaliConfig.BEACON_CURVE);\nvar publicKeyForLocalDevice = ecdhForLocalDevice.generateKeys();\nvar publicBase64KeyForLocalDevice = ecdhForLocalDevice.getPublicKey('base64');\n-// PouchDB name should be the same between peers.\n+// PouchDB name could be the same between peers or could be provided to\n+// ThaliReplicationPeerAction.start during runtime.\nvar DB_NAME = 'ThaliManagerCoordinated';\nPouchDB = testUtils.getLevelDownPouchDb();\nvar thaliManager;\n-var originalReplicationIdle =\n- ThaliReplicationPeerAction.MAX_IDLE_PERIOD_SECONDS;\nvar test = tape({\nsetup: function (t) {\n- // TODO: some requests take up to 15 seconds on iOS devices (see #1618).\n- ThaliReplicationPeerAction.MAX_IDLE_PERIOD_SECONDS = 30;\nt.data = publicKeyForLocalDevice.toJSON();\nt.end();\n},\n@@ -50,8 +45,6 @@ var test = tape({\n}\n})\n.then(function () {\n- ThaliReplicationPeerAction.MAX_IDLE_PERIOD_SECONDS =\n- originalReplicationIdle;\nt.end();\n});\n},\n" }, { "change_type": "MODIFY", "old_path": "test/www/jxcore/bv_tests/testThaliMobileNativeWrapper.js", "new_path": "test/www/jxcore/bv_tests/testThaliMobileNativeWrapper.js", "diff": "@@ -912,12 +912,7 @@ test('calls correct starts when network changes',\n// The connection cut is implemented as a separate test instead\n// of doing it in the middle of the actual test so that the\n// step gets coordinated between peers.\n-test('test to coordinate connection cut',\n- function () {\n- // This should be running on Android too but see #1600\n- return platform._isRealAndroid;\n- },\n- function (t) {\n+test('test to coordinate connection cut', function (t) {\n// This cuts connections on Android or iOS\nvar result = platform.isAndroid ?\ntestUtils.toggleBluetooth(false):\n" }, { "change_type": "MODIFY", "old_path": "test/www/jxcore/bv_tests/testThaliReplicationPeerAction.js", "new_path": "test/www/jxcore/bv_tests/testThaliReplicationPeerAction.js", "diff": "@@ -221,12 +221,7 @@ function matchDocsInChanges(pouchDB, docs, thaliPeerReplicationAction) {\n});\n}\n-test('Make sure docs replicate',\n- function () {\n- // FIXME: iOS is too slow for this test (#1618)\n- return platform._isRealIOS;\n- },\n- function (t) {\n+test('Make sure docs replicate', function (t) {\ntestCloseAllServer = testUtils.setUpServer(function (serverPort,\nrandomDBName,\nremotePouchDB) {\n@@ -275,12 +270,7 @@ test('Make sure docs replicate',\n});\n});\n-test('Do nothing and make sure we time out',\n- function () {\n- // FIXME: iOS is too slow for this test (#1618)\n- return platform._isRealIOS;\n- },\n- function (t) {\n+test('Do nothing and make sure we time out', function (t) {\nfunction onServerSetUp (serverPort, randomDBName) {\nvar thaliReplicationPeerAction = null;\nvar notificationForUs = {\n@@ -329,12 +319,7 @@ test('Do nothing and make sure we time out',\n}\n);\n-test('Do something and make sure we time out',\n- function () {\n- // FIXME: iOS is too slow for this test (#1618)\n- return platform._isRealIOS;\n- },\n- function (t) {\n+test('Do something and make sure we time out', function (t) {\nfunction onServerSetUp (serverPort, randomDBName, remotePouchDB) {\nvar thaliReplicationPeerAction = null;\nvar DifferentDirectoryPouch = testUtils.getLevelDownPouchDb();\n" } ]
JavaScript
MIT License
thaliproject/thali_cordovaplugin
Enable tests that were blocked due to #1618 for iOS. Enable test on Android that was blocked due to #1600
675,375
30.05.2017 13:08:01
-7,200
16c8951a930ba904b99342e40f0ceecccc35d022
Enable tests blocked due to and
[ { "change_type": "MODIFY", "old_path": "test/www/jxcore/bv_tests/testThaliMobileNativeWrapper.js", "new_path": "test/www/jxcore/bv_tests/testThaliMobileNativeWrapper.js", "diff": "@@ -864,9 +864,8 @@ test('calls correct starts when network changes',\nt.fail('Should fail');\n})\n.catch(function (error) { // eslint-disable-line\n- // TODO: enable when (if) #1767 is fixed\n- // t.equals(error.message, 'Radio Turned Off',\n- // 'specific error expected');\n+ t.equals(error.message, 'Radio Turned Off',\n+ 'specific error expected');\n});\n};\nvar listen = validateStartResult(\n@@ -926,12 +925,7 @@ test('test to coordinate connection cut', function (t) {\n});\n});\n-test('can do HTTP requests after connections are cut',\n- function () {\n- // This should be running on Android too but see #1600\n- return platform._isRealAndroid;\n- },\n- function (t) {\n+test('can do HTTP requests after connections are cut', function (t) {\n// Turn Bluetooth back on so that Android can operate\n// (iOS does not require separate call to operate since\n// killConnections is more like a single-shot thing).\n" } ]
JavaScript
MIT License
thaliproject/thali_cordovaplugin
Enable tests blocked due to #1767 and #1600
675,376
30.05.2017 16:01:23
-7,200
876dedb0460d3031d1a79a926aafe10b5504eee5
'disconnect' implementation bug Details here
[ { "change_type": "MODIFY", "old_path": "src/ios/AppContext.swift", "new_path": "src/ios/AppContext.swift", "diff": "@@ -401,8 +401,10 @@ extension PeerAvailability {\nguard let identifierString = parameters.first as? String else {\nthrow AppContextError.badParameters\n}\n- if let _ = try? Peer(stringValue: identifierString) {\n+ if let _ = try? Peer(uuidIdentifier: identifierString, generation: 0) {\nbrowserManager.disconnect(identifierString)\n+ } else {\n+ throw AppContextError.badParameters\n}\n}\n" } ]
JavaScript
MIT License
thaliproject/thali_cordovaplugin
'disconnect' implementation bug Details here https://github.com/thaliproject/Thali_CordovaPlugin/issues/1875
675,375
01.06.2017 15:14:30
-7,200
60d457da168cc00447780ce2969a3706067af94e
Add test to check case when remote db name is wrong
[ { "change_type": "MODIFY", "old_path": "test/www/jxcore/bv_tests/testThaliReplicationPeerActionCoordinated.js", "new_path": "test/www/jxcore/bv_tests/testThaliReplicationPeerActionCoordinated.js", "diff": "@@ -19,6 +19,7 @@ var ThaliReplicationPeerAction = require('thali/NextGeneration/replication/thali\nvar devicePublicPrivateKey = crypto.createECDH(thaliConfig.BEACON_CURVE);\nvar devicePublicKey = devicePublicPrivateKey.generateKeys();\nvar TestPouchDB = testUtils.getLevelDownPouchDb();\n+var localPouchDB;\n// Use peer's public key to determine local db name. This variable is used in scenario when\n// we want to replicate with remote db which name is different than our local db.\n@@ -27,6 +28,7 @@ var TestPouchDB = testUtils.getLevelDownPouchDb();\nvar LOCAL_DB_NAME_BASED_ON_PUBLIC_KEY = devicePublicKey.toString('hex').slice(0, 10);\nvar LOCAL_DB_NAME = 'repActionTest';\nvar EXPIRATION_TIMEOUT = 60 * 60 * 1000;\n+var ERROR_NO_DB_FILE = 'no_db_file';\nif (!tape.coordinated) {\nreturn;\n@@ -38,6 +40,10 @@ var test = tape({\nt.end();\n},\nteardown: function (t) {\n+ // Make sure we won't get any document conflicts during tests.\n+ if (localPouchDB) {\n+ localPouchDB.destroy();\n+ }\nt.end();\n}\n});\n@@ -58,10 +64,10 @@ test('Coordinated replication action test - each device has the same local db na\nvar thaliNotificationClient = new ThaliNotificationClient(\npeerPool, devicePublicPrivateKey\n);\n- var localPouchDB = new TestPouchDB(LOCAL_DB_NAME);\n-\nvar peerActions = [];\n+ localPouchDB = new TestPouchDB(LOCAL_DB_NAME);\n+\nlocalPouchDB.put({\n_id: JSON.stringify(devicePublicKey.toJSON())\n})\n@@ -204,10 +210,10 @@ test('Coordinated replication action test - each device has different local db n\nvar thaliNotificationClient = new ThaliNotificationClient(\npeerPool, devicePublicPrivateKey\n);\n- var localPouchDB = new TestPouchDB(LOCAL_DB_NAME_BASED_ON_PUBLIC_KEY);\n-\nvar peerActions = [];\n+ localPouchDB = new TestPouchDB(LOCAL_DB_NAME_BASED_ON_PUBLIC_KEY);\n+\nlocalPouchDB.put({\n_id: JSON.stringify(devicePublicKey.toJSON())\n})\n@@ -337,3 +343,120 @@ test('Coordinated replication action test - each device has different local db n\nt.end();\n});\n});\n+\n+test('Coordinated replication action test - should throw error when wrong dbRemoteName is provided', function (t) {\n+ var wrongRemoteDbName = 'testDb';\n+ var router = express.Router();\n+ router.use(\n+ '/db',\n+ expressPouchDB(TestPouchDB, {\n+ mode: 'minimumForPouchDB'\n+ })\n+ );\n+ var thaliNotificationServer = new ThaliNotificationServer(\n+ router, devicePublicPrivateKey, EXPIRATION_TIMEOUT\n+ );\n+ var peerPool = new ThaliPeerPoolDefault();\n+ peerPool.start();\n+ var thaliNotificationClient = new ThaliNotificationClient(\n+ peerPool, devicePublicPrivateKey\n+ );\n+ var peerActions = [];\n+\n+ localPouchDB = new TestPouchDB(LOCAL_DB_NAME);\n+\n+ localPouchDB.put({\n+ _id: JSON.stringify(devicePublicKey.toJSON())\n+ })\n+ .then(function () {\n+ return testUtils.runTestOnAllParticipants(\n+ t, router,\n+ thaliNotificationClient,\n+ thaliNotificationServer,\n+ ThaliMobile,\n+ devicePublicKey,\n+ function (notificationForUs) {\n+ var thaliReplicationPeerAction = new ThaliReplicationPeerAction(\n+ notificationForUs, TestPouchDB, LOCAL_DB_NAME, devicePublicKey\n+ );\n+ peerActions.push(thaliReplicationPeerAction);\n+\n+ return new Promise(function (resolve, reject) {\n+\n+ var httpAgentPool = new ForeverAgent.SSL({\n+ rejectUnauthorized: false,\n+ maxSockets: 8,\n+ ciphers: thaliConfig.SUPPORTED_PSK_CIPHERS,\n+ pskIdentity: thaliReplicationPeerAction.getPskIdentity(),\n+ pskKey: thaliReplicationPeerAction.getPskKey()\n+ });\n+\n+ // This should be rejected since we provided non existing remote db\n+ thaliReplicationPeerAction.start(httpAgentPool, wrongRemoteDbName)\n+ .then(function() {\n+ var error = 'we should not be able to replicate with db that doesn\\'t exist';\n+ t.fail(error);\n+ reject(new Error(error));\n+ })\n+ .catch(function (error) {\n+ t.equals(error.reason, ERROR_NO_DB_FILE, 'error should be \\'no_db_file\\'');\n+ resolve(true);\n+ });\n+ });\n+ }\n+ )\n+ })\n+\n+ .then(function () {\n+ return t.sync();\n+ })\n+\n+ .then(function () {\n+ // We are simulating thaliPullReplicationFromNotification.stop() and\n+ // thaliPeerPoolDefault.stop()\n+ thaliNotificationClient.stop();\n+ var promises = peerActions.map(function (peerAction) {\n+ peerAction.kill();\n+ return peerAction.waitUntilKilled();\n+ });\n+ return Promise.all(promises);\n+ })\n+ .then(function () {\n+ // https://github.com/thaliproject/Thali_CordovaPlugin/issues/1138\n+ // workaround for ECONNREFUSED and ECONNRESET from 'request.js' in\n+ // 'pouchdb'.\n+ return t.sync();\n+ })\n+ .then(function () {\n+ return thaliNotificationServer.stop();\n+ })\n+ .then(function () {\n+ return ThaliMobile.stop();\n+ })\n+ .then(function (combinedResult) {\n+ if (\n+ combinedResult.wifiResult !== null ||\n+ combinedResult.nativeResult !== null\n+ ) {\n+ return Promise.reject(\n+ new Error(\n+ 'Had a failure in ThaliMobile.start - ',\n+ JSON.stringify(combinedResult)\n+ )\n+ );\n+ }\n+ })\n+\n+ .then(function () {\n+ return Promise.resolve();\n+ })\n+ .then(function () {\n+ t.pass('passed');\n+ })\n+ .catch(function (error) {\n+ t.fail('failed with ' + error.toString());\n+ })\n+ .then(function () {\n+ t.end();\n+ });\n+});\n" } ]
JavaScript
MIT License
thaliproject/thali_cordovaplugin
Add test to check case when remote db name is wrong
675,375
01.06.2017 15:15:27
-7,200
f36eb0f4a1a8bba8d091d801540b14533609cace
Minor test description change
[ { "change_type": "MODIFY", "old_path": "test/www/jxcore/bv_tests/testThaliReplicationPeerActionCoordinated.js", "new_path": "test/www/jxcore/bv_tests/testThaliReplicationPeerActionCoordinated.js", "diff": "@@ -344,7 +344,7 @@ test('Coordinated replication action test - each device has different local db n\n});\n});\n-test('Coordinated replication action test - should throw error when wrong dbRemoteName is provided', function (t) {\n+test('Coordinated replication action test - should throw error when wrong remote db name is provided', function (t) {\nvar wrongRemoteDbName = 'testDb';\nvar router = express.Router();\nrouter.use(\n" } ]
JavaScript
MIT License
thaliproject/thali_cordovaplugin
Minor test description change
675,375
02.06.2017 17:01:00
-7,200
bc32962a7e5099fbe34074a3d862555f94632e1f
Fix tests in testThaliMobileNativeWrapper, so it use zombie proof execution function, do not call disconnect in teardown when on Android
[ { "change_type": "MODIFY", "old_path": "test/www/jxcore/bv_tests/testThaliMobileNative.js", "new_path": "test/www/jxcore/bv_tests/testThaliMobileNative.js", "diff": "@@ -62,8 +62,7 @@ var test = tape({\nerr,\n'Should be able to call stopAdvertisingAndListening in teardown'\n);\n- // There should be also additional parameter with generation number,\n- // see #1892\n+ if (!platform.isAndroid) {\nMobile('disconnect').callNative(peerIdToBeClosed, function (err) {\nt.notOk(\nerr,\n@@ -71,6 +70,9 @@ var test = tape({\n);\nt.end();\n});\n+ } else {\n+ t.end();\n+ }\n});\n});\n});\n@@ -261,12 +263,12 @@ function connectToListenerSendMessageGetResponseLength(t, port, request,\n}\nfunction executeZombieProofTest (t, server, testFunction) {\n- console.log(\"TEST: execute ZombieProof test\");\n+ logger.debug(\"TEST: execute ZombieProof test\");\nvar status = connectStatus.NOT_CONNECTED;\nvar availablePeers = [];\nvar onConnectSuccess = function (err, connection, peer) {\n- console.log(\"TEST: onConnectSuccess\");\n+ logger.debug(\"TEST: onConnectSuccess\");\ntestFunction(err, connection, peer);\n};\n@@ -274,7 +276,7 @@ function executeZombieProofTest (t, server, testFunction) {\navailablePeers.forEach(function (peer) {\nif (peer.peerAvailable && status === connectStatus.NOT_CONNECTED) {\nstatus = connectStatus.CONNECTING;\n- console.log(\"TEST: connecting to peer:\", peer.peerIdentifier);\n+ logger.debug(\"TEST: connecting to peer:\", peer.peerIdentifier);\nthaliMobileNativeTestUtils.connectToPeer(peer)\n.then(function (connection) {\nstatus = connectStatus.CONNECTED;\n@@ -282,12 +284,12 @@ function executeZombieProofTest (t, server, testFunction) {\n})\n.catch(function (error) {\nstatus = connectStatus.NOT_CONNECTED;\n- console.log(\"TEST: failed to connect to peer:\", peer.peerIdentifier);\n+ logger.debug(\"TEST: failed to connect to peer:\", peer.peerIdentifier);\n// Remove the peer from the availablePeers list in case it is still there\nfor (var i = availablePeers.length - 1; i >= 0; i--) {\nif (availablePeers[i].peerIdentifier === peer.peerIdentifier) {\navailablePeers.splice(i, 1);\n- console.log(\"TEST: peer removed:\", peer.peerIdentifier);\n+ logger.debug(\"TEST: peer removed:\", peer.peerIdentifier);\n}\n}\ntryToConnect();\n@@ -297,18 +299,18 @@ function executeZombieProofTest (t, server, testFunction) {\n};\nfunction peerAvailabilityChanged(peers) {\n- console.log(\"TEST: peerAvailabilityChangedHandler invoked\");\n+ logger.debug(\"TEST: peerAvailabilityChangedHandler invoked\");\npeers.forEach(function (peer) {\nif (peer.peerAvailable == true) {\n// Add the peer to the availablePeers list\navailablePeers.push(peer);\n- console.log(\"TEST: peer added:\", peer);\n+ logger.debug(\"TEST: peer added:\", peer);\n} else {\n// Remove the peer from the availablePeers list\nfor (var i = availablePeers.length - 1; i >= 0; i--) {\nif (availablePeers[i].peerIdentifier === peer.peerIdentifier) {\navailablePeers.splice(i, 1);\n- console.log(\"TEST: peer removed:\", peer);\n+ logger.debug(\"TEST: peer removed:\", peer);\n}\n}\n}\n@@ -329,9 +331,10 @@ test('Can connect to a remote peer', function (t) {\nserver = makeIntoCloseAllServer(server);\nserverToBeClosed = server;\n- executeZombieProofTest(t, server, function (err, connection) {\n+ executeZombieProofTest(t, server, function (err, connection, peer) {\n// Called if we successfully connect to to a peer\nlogger.info(connection);\n+ peerIdToBeClosed = peer.peerIdentifier;\nt.ok(connection.hasOwnProperty('listeningPort'),\n'Must have listeningPort');\n@@ -445,41 +448,6 @@ test('Can shift data', function (t) {\n});\n});\n-function runRepeats(n) {\n- function testCanShiftData(n) {\n- var name = 'Can shift data ' + n;\n-\n- test(name, function (t) {\n- var exchangeData = 'small amount of data';\n-\n- var server = createServer(t, exchangeData.length);\n- server = makeIntoCloseAllServer(server);\n- serverToBeClosed = server;\n-\n- executeZombieProofTest(t, server, function (err, connection, peer) {\n- peerIdToBeClosed = peer.peerIdentifier;\n- var nativePort = connection.listeningPort;\n-\n- connect(net, { port: nativePort })\n- .then(function (socket) {\n- return shiftData(t, socket, exchangeData);\n- })\n- .catch(t.fail)\n- .then(function () {\n- t.end();\n- });\n- });\n-\n- });\n- }\n-\n- for (var i = 1; i <= n; i++) {\n- testCanShiftData(i);\n- }\n-}\n-\n-runRepeats(20);\n-\ntest('Can shift data via parallel connections', function (t) {\nvar dataLength = 16 * 1024;\n" }, { "change_type": "MODIFY", "old_path": "test/www/jxcore/bv_tests/testThaliMobileNativeWrapper.js", "new_path": "test/www/jxcore/bv_tests/testThaliMobileNativeWrapper.js", "diff": "@@ -17,8 +17,23 @@ if (typeof Mobile === 'undefined') {\nvar platform = require('thali/NextGeneration/utils/platform');\nvar thaliMobileNativeWrapper =\nrequire('thali/NextGeneration/thaliMobileNativeWrapper');\n+var thaliMobileNativeTestUtils = require('../lib/thaliMobileNativeTestUtils');\nvar validations = require('thali/validations');\nvar tape = require('../lib/thaliTape');\n+var uuid = require('node-uuid');\n+\n+var peerIdToBeClosed = uuid.v4();\n+\n+/**\n+ * @readonly\n+ * @type {{NOT_CONNECTED: string, CONNECTING: string, CONNECTED: string}}\n+ */\n+var connectStatus = {\n+ NOT_CONNECTED : 'notConnected',\n+ CONNECTING : 'connecting',\n+ CONNECTED : 'connected'\n+};\n+\nvar test = tape({\nsetup: function (t) {\n@@ -32,8 +47,17 @@ var test = tape({\n.then(function () {\nt.equals(thaliMobileNativeWrapper._isStarted(), false,\n'must be stopped');\n- thaliMobileNativeWrapper._registerToNative();\n+ if (!platform.isAndroid) {\n+ Mobile('disconnect').callNative(peerIdToBeClosed, function (err) {\n+ t.notOk(\n+ err,\n+ 'Should be able to call disconnect in teardown'\n+ );\n+ t.end();\n+ });\n+ } else {\nt.end();\n+ }\n})\n.catch(function (err) {\nt.fail('teardown failed with ' + JSON.stringify(err));\n@@ -141,6 +165,70 @@ test('error returned with bad router', function (t) {\n});\n});\n+function executeZombieProofTest (t, testFunction) {\n+ console.log(\"TEST: execute ZombieProof test\");\n+ var status = connectStatus.NOT_CONNECTED;\n+ var availablePeers = [];\n+\n+ var onConnectSuccess = function (err, connection, peer) {\n+ console.log(\"TEST: onConnectSuccess\");\n+ testFunction(err, connection, peer);\n+ };\n+\n+ var tryToConnect = function () {\n+ availablePeers.forEach(function (peer) {\n+ if (peer.peerAvailable && status === connectStatus.NOT_CONNECTED) {\n+ status = connectStatus.CONNECTING;\n+ console.log(\"TEST: connecting to peer:\", peer.peerIdentifier);\n+ thaliMobileNativeTestUtils.connectToPeer(peer)\n+ .then(function (connection) {\n+ status = connectStatus.CONNECTED;\n+ onConnectSuccess(null, connection, peer);\n+ })\n+ .catch(function (error) {\n+ status = connectStatus.NOT_CONNECTED;\n+ console.log(\"TEST: failed to connect to peer:\", peer.peerIdentifier);\n+ // Remove the peer from the availablePeers list in case it is still there\n+ for (var i = availablePeers.length - 1; i >= 0; i--) {\n+ if (availablePeers[i].peerIdentifier === peer.peerIdentifier) {\n+ availablePeers.splice(i, 1);\n+ console.log(\"TEST: peer removed:\", peer.peerIdentifier);\n+ }\n+ }\n+ tryToConnect();\n+ });\n+ }\n+ });\n+ };\n+\n+ function peerAvailabilityChanged(peers) {\n+ console.log(\"TEST: peerAvailabilityChangedHandler invoked\");\n+ peers.forEach(function (peer) {\n+ if (peer.peerAvailable == true) {\n+ // Add the peer to the availablePeers list\n+ availablePeers.push(peer);\n+ console.log(\"TEST: peer added:\", peer);\n+ } else {\n+ // Remove the peer from the availablePeers list\n+ for (var i = availablePeers.length - 1; i >= 0; i--) {\n+ if (availablePeers[i].peerIdentifier === peer.peerIdentifier) {\n+ availablePeers.splice(i, 1);\n+ console.log(\"TEST: peer removed:\", peer);\n+ }\n+ }\n+ }\n+ });\n+\n+ if (status === connectStatus.NOT_CONNECTED && availablePeers.length > 0) {\n+ tryToConnect();\n+ }\n+ }\n+\n+ thaliMobileNativeWrapper.emitter.on('nonTCPPeerAvailabilityChangedEvent', function(peers) {\n+ peerAvailabilityChanged([peers]);\n+ });\n+}\n+\nvar testPath = '/test';\nfunction trivialEndToEndTestScaffold(t, pskIdtoSecret, pskIdentity, pskKey,\ntestData, callback) {\n@@ -149,27 +237,31 @@ function trivialEndToEndTestScaffold(t, pskIdtoSecret, pskIdentity, pskKey,\nres.send(testData);\n});\n+ thaliMobileNativeWrapper.start(router, pskIdtoSecret)\n+ .then(function () {\n+ return thaliMobileNativeWrapper.startListeningForAdvertisements();\n+ })\n+ .then(function () {\n+ return thaliMobileNativeWrapper.startUpdateAdvertisingAndListening();\n+ })\n+ .then(function () {\n+ executeZombieProofTest(t, function (err, connection, peer) {\nvar end = function (peerId, fail) {\nreturn callback ? callback(peerId, fail) : t.end();\n};\n- testUtils.getSamePeerWithRetry(testPath, pskIdentity, pskKey)\n+ testUtils.get('127.0.0.1', connection.listeningPort, testPath, pskIdentity, pskKey)\n.then(function (response) {\n- t.equal(response.httpResponseBody, testData,\n+ t.equal(response, testData,\n'response body should match testData');\n+ peerIdToBeClosed = peer.peerIdentifier;\nend(response.peerId);\n})\n.catch(function (error) {\nt.fail('fail in trivialEndtoEndTestScaffold - ' + error);\nend(null, error);\n});\n-\n- thaliMobileNativeWrapper.start(router, pskIdtoSecret)\n- .then(function () {\n- return thaliMobileNativeWrapper.startListeningForAdvertisements();\n- })\n- .then(function () {\n- return thaliMobileNativeWrapper.startUpdateAdvertisingAndListening();\n+ });\n});\n}\n" } ]
JavaScript
MIT License
thaliproject/thali_cordovaplugin
Fix tests in testThaliMobileNativeWrapper, so it use zombie proof execution function, do not call disconnect in teardown when on Android
675,371
06.06.2017 10:45:57
-7,200
4bcd7a6e28b85df91ac9d210bfbaea9ee02ff05f
Updated UT, changed behaviour of test disconnect with invalid peer id
[ { "change_type": "MODIFY", "old_path": "test/www/jxcore/bv_tests/testThaliMobileNativeiOS.js", "new_path": "test/www/jxcore/bv_tests/testThaliMobileNativeiOS.js", "diff": "@@ -145,7 +145,6 @@ test('multiConnect properly fails on legal but non-existent peerID',\ntest('cannot call multiConnect with invalid syncValue',\nfunction (t) {\n- var connectReturned = false;\nvar invalidSyncValue = /I am not a string/;\nMobile('startListeningForAdvertisements').callNative(function (err) {\nt.notOk(err, 'No error on starting');\n@@ -157,21 +156,13 @@ test('cannot call multiConnect with invalid syncValue',\n});\n});\n});\n-//TODO - fix failing test. The disconnect method should not throw badParameters exception\n-test('disconnect doesn\\'t fail on bad peer id', function () { return true }, function (t) {\n- Mobile('disconnect').callNative('foo', function(err) {\n- t.notOk(err, 'No error');\n- // Giving failure callback a chance to mess things up\n- setImmediate(function () {\n+\n+test('cannot call disconnect with invalid peer id', function (t) {\n+ Mobile('disconnect').callNative('foo', function (error) {\n+ t.equal(error, 'Bad parameters', 'Got right error');\nt.end();\n});\n});\n- thaliMobileNativeTestUtils.multiConnectEmitter\n- .on('multiConnectConnectionFailure', function (peerIdentifier, error) {\n- t.fail('We shouldn\\'t get a failure callback - peerID: ' +\n- peerIdentifier + ', error: ' + error);\n- });\n-});\ntest('disconnect doesn\\'t fail on plausible but bogus peer ID', function (t) {\nvar peerId = nodeUuid.v4();\n" } ]
JavaScript
MIT License
thaliproject/thali_cordovaplugin
Updated UT, changed behaviour of test disconnect with invalid peer id
675,375
07.06.2017 15:57:15
-7,200
591b1ca96894285af651219ddc00584b7e9ffca3
WIP: Revert changes in testThaliReplicationPeerActionCoordinated, collect all peerIds and kill connections between them after each test
[ { "change_type": "MODIFY", "old_path": "test/www/jxcore/bv_tests/testThaliMobileNative.js", "new_path": "test/www/jxcore/bv_tests/testThaliMobileNative.js", "diff": "@@ -28,7 +28,7 @@ var platform = require('thali/NextGeneration/utils/platform');\n// A variable that can be used to store a server\n// that will get closed in teardown.\nvar serverToBeClosed = null;\n-var peerIdToBeClosed = uuid.v4();\n+var peerIdsToBeClosed = [];\n/**\n* @readonly\n@@ -64,16 +64,17 @@ var test = tape({\n'Should be able to call stopAdvertisingAndListening in teardown'\n);\nif (!platform.isAndroid) {\n+ peerIdsToBeClosed.forEach(function (peerIdToBeClosed) {\nMobile('disconnect').callNative(peerIdToBeClosed, function (err) {\nt.notOk(\nerr,\n'Should be able to call disconnect in teardown'\n);\n- t.end();\n});\n- } else {\n- t.end();\n+ });\n}\n+ peerIdsToBeClosed = [];\n+ t.end();\n});\n});\n});\n@@ -335,7 +336,7 @@ test('Can connect to a remote peer', function (t) {\nexecuteZombieProofTest(t, server, function (err, connection, peer) {\n// Called if we successfully connect to to a peer\nlogger.info(connection);\n- peerIdToBeClosed = peer.peerIdentifier;\n+ peerIdsToBeClosed.push(peer.peerIdentifier);\nt.ok(connection.hasOwnProperty('listeningPort'),\n'Must have listeningPort');\n@@ -435,7 +436,7 @@ test('Can shift data', function (t) {\nserverToBeClosed = server;\nexecuteZombieProofTest(t, server, function (err, connection, peer) {\n- peerIdToBeClosed = peer.peerIdentifier;\n+ peerIdsToBeClosed.push(peer.peerIdentifier);\nvar nativePort = connection.listeningPort;\nconnect(net, { port: nativePort })\n@@ -461,7 +462,7 @@ test('Can shift data via parallel connections',\nserverToBeClosed = server;\nexecuteZombieProofTest(t, server, function (err, connection, peer) {\n- peerIdToBeClosed = peer.peerIdentifier;\n+ peerIdsToBeClosed.push(peer.peerIdentifier);\nvar nativePort = connection.listeningPort;\nPromise.all([\nconnect(net, {port: nativePort}),\n@@ -560,7 +561,7 @@ test('Can shift data securely', function (t) {\n}\nexecuteZombieProofTest(t, server, function(err, connection, peer) {\n- peerIdToBeClosed = peer.peerIdentifier;\n+ peerIdsToBeClosed.push(peer.peerIdentifier);\nreturn connect(tls, {\nport: connection.listeningPort,\n@@ -636,7 +637,7 @@ test('Can shift large amounts of data', function (t) {\nexecuteZombieProofTest(t, server, function (err, connection, peer) {\nvar client = null;\n- peerIdToBeClosed = peer.peerIdentifier;\n+ peerIdsToBeClosed.push(peer.peerIdentifier);\n// We're happy here if we make a connection to anyone\nlogger.info('Connection info: ' + JSON.stringify(connection));\n" }, { "change_type": "MODIFY", "old_path": "test/www/jxcore/bv_tests/testThaliMobileNativeWrapper.js", "new_path": "test/www/jxcore/bv_tests/testThaliMobileNativeWrapper.js", "diff": "@@ -22,7 +22,7 @@ var validations = require('thali/validations');\nvar tape = require('../lib/thaliTape');\nvar uuid = require('node-uuid');\n-var peerIdToBeClosed = uuid.v4();\n+var peerIdsToBeClosed = [];\n/**\n* @readonly\n@@ -42,22 +42,22 @@ var test = tape({\nt.end();\n},\nteardown: function (t) {\n- thaliMobileNativeWrapper.emitter.removeAllListeners();\nthaliMobileNativeWrapper.stop()\n.then(function () {\nt.equals(thaliMobileNativeWrapper._isStarted(), false,\n'must be stopped');\nif (!platform.isAndroid) {\n+ peerIdsToBeClosed.forEach(function (peerIdToBeClosed) {\nMobile('disconnect').callNative(peerIdToBeClosed, function (err) {\nt.notOk(\nerr,\n'Should be able to call disconnect in teardown'\n);\n- t.end();\n});\n- } else {\n- t.end();\n+ });\n}\n+ peerIdsToBeClosed = [];\n+ t.end();\n})\n.catch(function (err) {\nt.fail('teardown failed with ' + JSON.stringify(err));\n@@ -247,6 +247,8 @@ function trivialEndToEndTestScaffold(t, pskIdtoSecret, pskIdentity, pskKey,\n.then(function () {\nexecuteZombieProofTest(t, function (err, connection, peer) {\nvar end = function (peerId, fail) {\n+ peerIdsToBeClosed.push(peer.peerIdentifier);\n+\nreturn callback ? callback(peerId, fail) : t.end();\n};\n@@ -254,7 +256,6 @@ function trivialEndToEndTestScaffold(t, pskIdtoSecret, pskIdentity, pskKey,\n.then(function (response) {\nt.equal(response, testData,\n'response body should match testData');\n- peerIdToBeClosed = peer.peerIdentifier;\nend(response.peerId);\n})\n.catch(function (error) {\n" }, { "change_type": "MODIFY", "old_path": "test/www/jxcore/bv_tests/testThaliMobileNativeiOS.js", "new_path": "test/www/jxcore/bv_tests/testThaliMobileNativeiOS.js", "diff": "// Issue #419\nvar ThaliMobile = require('thali/NextGeneration/thaliMobile');\n-var Platform = require('thali/NextGeneration/utils/platform');\n+var platform = require('thali/NextGeneration/utils/platform');\nvar nodeUuid = require('node-uuid');\nvar net = require('net');\nvar thaliMobileNativeTestUtils = require('../lib/thaliMobileNativeTestUtils');\n@@ -12,7 +12,7 @@ var thaliMobileNativeWrapper =\nvar logger = require('../lib/testLogger')('testThaliMobileNativeiOS');\nvar Promise = require('lie');\nif (global.NETWORK_TYPE === ThaliMobile.networkTypes.WIFI ||\n- !Platform.isIOS) {\n+ !platform.isIOS) {\nreturn;\n}\n@@ -21,7 +21,7 @@ var tape = require('../lib/thaliTape');\nvar uuid = require('node-uuid');\n-var peerIdToBeClosed = uuid.v4();\n+var peerIdsToBeClosed = [];\n/**\n* @readonly\n@@ -41,6 +41,7 @@ var serverToBeClosed = null;\nvar test = tape({\nsetup: function (t) {\n+ thaliMobileNativeWrapper._registerToNative();\nserverToBeClosed = {\ncloseAll: function (callback) {\ncallback();\n@@ -61,15 +62,19 @@ var test = tape({\nerr,\n'Should be able to call stopAdvertisingAndListening in teardown'\n);\n+ if (!platform.isAndroid) {\n+ peerIdsToBeClosed.forEach(function (peerIdToBeClosed) {\nMobile('disconnect').callNative(peerIdToBeClosed, function (err) {\nt.notOk(\nerr,\n'Should be able to call disconnect in teardown'\n);\n- thaliMobileNativeWrapper._registerToNative();\n- t.end();\n});\n});\n+ }\n+ peerIdsToBeClosed = [];\n+ t.end();\n+ });\n});\n});\n}\n@@ -212,7 +217,6 @@ function executeZombieProofTest (t, server, testFunction) {\nvar onConnectSuccess = function (err, connection, peer) {\nlogger.debug(\"TEST: onConnectSuccess\");\ntestFunction(err, connection, peer);\n- connectTest(connectionCallback.listeningPort, currentTestPeer);\n};\nvar tryToConnect = function () {\n@@ -276,7 +280,7 @@ test('Get same port when trying to connect multiple times on iOS',\nserverToBeClosed = server;\nexecuteZombieProofTest(t, server, function (err, currentConnection, currentTestPeer) {\n- peerIdToBeClosed = currentTestPeer.peerIdentifier;\n+ peerIdsToBeClosed.push(currentTestPeer.peerIdentifier);\nvar listeningPort = currentConnection.listeningPort;\nvar connection = net.connect(listeningPort,\nfunction () {\n" }, { "change_type": "MODIFY", "old_path": "test/www/jxcore/bv_tests/testThaliReplicationPeerActionCoordinated.js", "new_path": "test/www/jxcore/bv_tests/testThaliReplicationPeerActionCoordinated.js", "diff": "@@ -5,16 +5,18 @@ var express = require('express');\nvar expressPouchDB = require('express-pouchdb');\nvar ForeverAgent = require('forever-agent');\nvar Promise = require('bluebird');\n-var uuid = require('node-uuid');\nvar tape = require('../lib/thaliTape');\nvar testUtils = require('../lib/testUtils');\nvar thaliConfig = require('thali/NextGeneration/thaliConfig');\n+var ThaliMobile = require('thali/NextGeneration/thaliMobile');\n+var ThaliNotificationServer = require('thali/NextGeneration/notification/thaliNotificationServer');\n+var ThaliNotificationClient = require('thali/NextGeneration/notification/thaliNotificationClient');\n+var ThaliPeerPoolDefault = require('thali/NextGeneration/thaliPeerPool/thaliPeerPoolDefault');\nvar ThaliReplicationPeerAction = require('thali/NextGeneration/replication/thaliReplicationPeerAction');\n-var platform = require('thali/NextGeneration/utils/platform');\n-var thaliMobileNativeWrapper = require('thali/NextGeneration/thaliMobileNativeWrapper');\n+var platform = require('thali/NextGeneration/utils/platform');\nvar devicePublicPrivateKey = crypto.createECDH(thaliConfig.BEACON_CURVE);\nvar devicePublicKey = devicePublicPrivateKey.generateKeys();\nvar TestPouchDB = testUtils.getLevelDownPouchDb();\n@@ -29,7 +31,7 @@ var LOCAL_DB_NAME = 'repActionTest';\nvar EXPIRATION_TIMEOUT = 60 * 60 * 1000;\nvar ERROR_NO_DB_FILE = 'no_db_file';\n-var peerIdToBeClosed = uuid.v4();\n+var peerIdsToBeClosed = [];\nif (!tape.coordinated) {\nreturn;\n@@ -41,25 +43,23 @@ var test = tape({\nt.end();\n},\nteardown: function (t) {\n- // Make sure we won't get any conflicts\n- if (!localPouchDB) {\n+ // Make sure we won't get any document conflicts during tests.\n+ if (localPouchDB) {\nlocalPouchDB.destroy();\n}\n- thaliMobileNativeWrapper.stop()\n- .then(function () {\nif (!platform.isAndroid) {\n+ peerIdsToBeClosed.forEach(function (peerIdToBeClosed) {\nMobile('disconnect').callNative(peerIdToBeClosed, function (err) {\nt.notOk(\nerr,\n'Should be able to call disconnect in teardown'\n);\n- t.end();\n});\n- } else {\n- t.end();\n- }\n});\n}\n+ peerIdsToBeClosed = [];\n+ t.end();\n+ }\n});\ntest('Coordinated replication action test - each device has the same local db name', function (t) {\n@@ -70,65 +70,67 @@ test('Coordinated replication action test - each device has the same local db na\nmode: 'minimumForPouchDB'\n})\n);\n-\n- var pskIdentity = 'I am me!';\n- var pskKey = new Buffer('I am a reasonable long string');\n+ var thaliNotificationServer = new ThaliNotificationServer(\n+ router, devicePublicPrivateKey, EXPIRATION_TIMEOUT\n+ );\n+ var peerPool = new ThaliPeerPoolDefault();\n+ peerPool.start();\n+ var thaliNotificationClient = new ThaliNotificationClient(\n+ peerPool, devicePublicPrivateKey\n+ );\nvar peerActions = [];\n- function localPouchDBPromise(docId) {\n- return new Promise(function (resolve, reject) {\nlocalPouchDB = new TestPouchDB(LOCAL_DB_NAME);\n- localPouchDB.put({\n- _id: docId\n- }).then(function () {\n- resolve();\n- }).catch(function (error) {\n- reject(error);\n- });\n- });\n- }\n- thaliMobileNativeWrapper.start(router, pskKey)\n- .then(function () {\n- return thaliMobileNativeWrapper.startListeningForAdvertisements();\n- })\n- .then(function () {\n- return thaliMobileNativeWrapper.startUpdateAdvertisingAndListening();\n+ localPouchDB.put({\n+ _id: JSON.stringify(devicePublicKey.toJSON())\n})\n.then(function () {\n- return testUtils.runZombieProofTest(\n- t, function (err, connection, peer) {\n- return new Promise(function (resolve, reject) {\n- localPouchDBPromise(peer.peerIdentifier)\n- .then(function () {\n- peer.pskKey = pskKey;\n- peer.pskIdentity = pskIdentity;\n- peer.hostAddress = '127.0.0.1';\n- peer.portNumber = connection.listeningPort;\n-\n+ return testUtils.runTestOnAllParticipants(\n+ t, router,\n+ thaliNotificationClient,\n+ thaliNotificationServer,\n+ ThaliMobile,\n+ devicePublicKey,\n+ function (notificationForUs) {\nvar thaliReplicationPeerAction = new ThaliReplicationPeerAction(\n- peer, TestPouchDB, LOCAL_DB_NAME, devicePublicKey\n+ notificationForUs, TestPouchDB, LOCAL_DB_NAME, devicePublicKey\n);\npeerActions.push(thaliReplicationPeerAction);\n- var exited = false;\n- var resultError = null;\n+ return new Promise(function (resolve, reject) {\nvar changes = localPouchDB.changes({\nsince: 0,\nlive: true\n- }).on('change', function (change) {\n+ });\n+\n+ var exited = false;\n+ var resultError = null;\n+ function exit(error) {\n+ if (exited) {\n+ return;\n+ }\n+ exited = true;\n+\n+ peerIdsToBeClosed.push(thaliReplicationPeerAction.getPeerIdentifier());\n+ resultError = error;\n+ changes.cancel();\n+ }\n+\n+ changes.on('change', function (change) {\n+ var bufferRemoteId = new Buffer(JSON.parse(change.id));\n// note that the test might pass before we even start replicating\n// because we already have the record from someone else, that's\n// fine. We still guarantee at least one replication ran on each\n// device.\n- if (peer.peerIdentifier === change.id) {\n+ if (Buffer.compare(notificationForUs.keyId, bufferRemoteId) === 0) {\nexit();\n}\n- }).on('error', function (error) {\n+ })\n+ .on('error', function (error) {\nreject(error);\n- }).on('complete', function () {\n- peerIdToBeClosed = peer.peerIdentifier;\n-\n+ })\n+ .on('complete', function () {\nif (resultError) {\nreject(resultError);\n} else {\n@@ -136,34 +138,31 @@ test('Coordinated replication action test - each device has the same local db na\n}\n});\n- function exit(error) {\n- if (exited) {\n- return;\n- }\n- exited = true;\n-\n- resultError = error;\n- changes.cancel();\n- }\n-\nvar httpAgentPool = new ForeverAgent.SSL({\nrejectUnauthorized: false,\nmaxSockets: 8,\nciphers: thaliConfig.SUPPORTED_PSK_CIPHERS,\n- pskIdentity: peer.pskIdentity,\n- pskKey: peer.pskKey\n+ pskIdentity: thaliReplicationPeerAction.getPskIdentity(),\n+ pskKey: thaliReplicationPeerAction.getPskKey()\n});\nthaliReplicationPeerAction.start(httpAgentPool)\n.catch(function (error) {\n- peerIdToBeClosed = peer.peerIdentifier;\nexit(error);\n});\n});\n- });\n- });\n+ }\n+ )\n})\n+\n.then(function () {\n+ return t.sync();\n+ })\n+\n+ .then(function () {\n+ // We are simulating thaliPullReplicationFromNotification.stop() and\n+ // thaliPeerPoolDefault.stop()\n+ thaliNotificationClient.stop();\nvar promises = peerActions.map(function (peerAction) {\npeerAction.kill();\nreturn peerAction.waitUntilKilled();\n@@ -171,8 +170,34 @@ test('Coordinated replication action test - each device has the same local db na\nreturn Promise.all(promises);\n})\n.then(function () {\n+ // https://github.com/thaliproject/Thali_CordovaPlugin/issues/1138\n+ // workaround for ECONNREFUSED and ECONNRESET from 'request.js' in\n+ // 'pouchdb'.\nreturn t.sync();\n})\n+ .then(function () {\n+ return thaliNotificationServer.stop();\n+ })\n+ .then(function () {\n+ return ThaliMobile.stop();\n+ })\n+ .then(function (combinedResult) {\n+ if (\n+ combinedResult.wifiResult !== null ||\n+ combinedResult.nativeResult !== null\n+ ) {\n+ return Promise.reject(\n+ new Error(\n+ 'Had a failure in ThaliMobile.start - ',\n+ JSON.stringify(combinedResult)\n+ )\n+ );\n+ }\n+ })\n+\n+ .then(function () {\n+ return Promise.resolve();\n+ })\n.then(function () {\nt.pass('passed');\n})\n@@ -234,6 +259,7 @@ test('Coordinated replication action test - each device has different local db n\n}\nexited = true;\n+ peerIdsToBeClosed.push(thaliReplicationPeerAction.getPeerIdentifier());\nresultError = error;\nchanges.cancel();\n}\n@@ -280,9 +306,7 @@ test('Coordinated replication action test - each device has different local db n\n)\n})\n- .then(function (notificationForUs) {\n- peerIdToBeClosed = notificationForUs.peerId;\n- console.log('PeerIdToBeClosed: ', peerIdToBeClosed);\n+ .then(function () {\nreturn t.sync();\n})\n@@ -386,22 +410,24 @@ test('Coordinated replication action test - should throw error when wrong remote\n// This should be rejected since we provided non existing remote db\nthaliReplicationPeerAction.start(httpAgentPool, wrongRemoteDbName)\n.then(function() {\n+ peerIdsToBeClosed.push(thaliReplicationPeerAction.getPeerIdentifier());\n+\nvar error = 'we should not be able to replicate with db that doesn\\'t exist';\nt.fail(error);\nreject(new Error(error));\n})\n.catch(function (error) {\n+ peerIdsToBeClosed.push(thaliReplicationPeerAction.getPeerIdentifier());\n+\nt.equals(error.reason, ERROR_NO_DB_FILE, 'error should be \\'no_db_file\\'');\n- resolve(thaliReplicationPeerAction);\n+ resolve(true);\n});\n});\n}\n)\n})\n- .then(function (notificationForUs) {\n- peerIdToBeClosed = notificationForUs.peerId;\n- console.log('PeerIdToBeClosed: ', peerIdToBeClosed);\n+ .then(function () {\nreturn t.sync();\n})\n" }, { "change_type": "MODIFY", "old_path": "test/www/jxcore/lib/testUtils.js", "new_path": "test/www/jxcore/lib/testUtils.js", "diff": "@@ -19,24 +19,10 @@ var notificationBeacons =\nrequire('thali/NextGeneration/notification/thaliNotificationBeacons');\nvar express = require('express');\nvar fs = require('fs-extra-promise');\n-var thaliMobileNativeTestUtils = require('./thaliMobileNativeTestUtils');\n-var thaliMobileNativeWrapper =\n- require('thali/NextGeneration/thaliMobileNativeWrapper');\nvar pskId = 'yo ho ho';\nvar pskKey = new Buffer('Nothing going on here');\n-/**\n- * @readonly\n- * @type {{NOT_CONNECTED: string, CONNECTING: string, CONNECTED: string}}\n- */\n-var connectStatus = {\n- NOT_CONNECTED : 'notConnected',\n- CONNECTING : 'connecting',\n- CONNECTED : 'connected'\n-};\n-\n-\nfunction toggleBluetooth (value) {\nif (typeof Mobile === 'undefined') {\nreturn Promise.reject(new Error(\n@@ -653,77 +639,6 @@ module.exports.startServerInfrastructure =\n});\n};\n-module.exports.runZombieProofTest = function executeZombieProofTest (t, testFunction) {\n- return new Promise(function (resolve, reject) {\n- console.log(\"TEST: execute ZombieProof test\");\n- var status = connectStatus.NOT_CONNECTED;\n- var availablePeers = [];\n-\n- var onConnectSuccess = function (err, connection, peer) {\n- console.log(\"TEST: onConnectSuccess\");\n-\n- testFunction(err, connection, peer)\n- .then(function() {\n- resolve();\n- }).catch(function (err) {\n- reject(err);\n- });\n- };\n-\n- var tryToConnect = function () {\n- availablePeers.forEach(function (peer) {\n- if (peer.peerAvailable && status === connectStatus.NOT_CONNECTED) {\n- status = connectStatus.CONNECTING;\n- console.log(\"TEST: connecting to peer:\", peer.peerIdentifier);\n- thaliMobileNativeTestUtils.connectToPeer(peer)\n- .then(function (connection) {\n- status = connectStatus.CONNECTED;\n- onConnectSuccess(null, connection, peer);\n- })\n- .catch(function (error) {\n- status = connectStatus.NOT_CONNECTED;\n- console.log(\"TEST: failed to connect to peer:\", peer.peerIdentifier);\n- // Remove the peer from the availablePeers list in case it is still there\n- for (var i = availablePeers.length - 1; i >= 0; i--) {\n- if (availablePeers[i].peerIdentifier === peer.peerIdentifier) {\n- availablePeers.splice(i, 1);\n- console.log(\"TEST: peer removed:\", peer.peerIdentifier);\n- }\n- }\n- tryToConnect();\n- });\n- }\n- });\n- };\n-\n- function peerAvailabilityChangedHandler(peers) {\n- console.log(\"TEST: peerAvailabilityChanged invoked\");\n- peers.forEach(function (peer) {\n- if (peer.peerAvailable == true) {\n- // Add the peer to the availablePeers list\n- availablePeers.push(peer);\n- console.log(\"TEST: peer added:\", peer);\n- } else {\n- // Remove the peer from the availablePeers list\n- for (var i = availablePeers.length - 1; i >= 0; i--) {\n- if (availablePeers[i].peerIdentifier === peer.peerIdentifier) {\n- availablePeers.splice(i, 1);\n- console.log(\"TEST: peer removed:\", peer);\n- }\n- }\n- }\n- });\n-\n- if (status === connectStatus.NOT_CONNECTED && availablePeers.length > 0) {\n- tryToConnect();\n- }\n- }\n-\n- Mobile('peerAvailabilityChanged')\n- .registerToNative(peerAvailabilityChangedHandler);\n- });\n-};\n-\nmodule.exports.runTestOnAllParticipants = function (\nt, router,\nthaliNotificationClient,\n" } ]
JavaScript
MIT License
thaliproject/thali_cordovaplugin
WIP: Revert changes in testThaliReplicationPeerActionCoordinated, collect all peerIds and kill connections between them after each test
675,375
08.06.2017 13:11:27
-7,200
f4947bdbfb418cc5d736e835c4b19fc566e83a78
Fix thaliMobileNativeWrapper tests, move executeZombieProofTest to thaliMobileNativeTestUtils, move getSamePeerWithRetry from testUtils to thaliMobileNativeTestUtils
[ { "change_type": "MODIFY", "old_path": "test/www/jxcore/bv_tests/testThaliMobileNative.js", "new_path": "test/www/jxcore/bv_tests/testThaliMobileNative.js", "diff": "@@ -264,68 +264,6 @@ function connectToListenerSendMessageGetResponseLength(t, port, request,\n});\n}\n-function executeZombieProofTest (t, server, testFunction) {\n- console.log(\"TEST: execute ZombieProof test\");\n- var status = connectStatus.NOT_CONNECTED;\n- var availablePeers = [];\n-\n- var onConnectSuccess = function (err, connection, peer) {\n- console.log(\"TEST: onConnectSuccess\");\n- testFunction(err, connection, peer);\n- };\n-\n- var tryToConnect = function () {\n- availablePeers.forEach(function (peer) {\n- if (peer.peerAvailable && status === connectStatus.NOT_CONNECTED) {\n- status = connectStatus.CONNECTING;\n- console.log(\"TEST: connecting to peer:\", peer.peerIdentifier);\n- thaliMobileNativeTestUtils.connectToPeer(peer)\n- .then(function (connection) {\n- status = connectStatus.CONNECTED;\n- onConnectSuccess(null, connection, peer);\n- })\n- .catch(function (error) {\n- status = connectStatus.NOT_CONNECTED;\n- console.log(\"TEST: failed to connect to peer:\", peer.peerIdentifier);\n- // Remove the peer from the availablePeers list in case it is still there\n- for (var i = availablePeers.length - 1; i >= 0; i--) {\n- if (availablePeers[i].peerIdentifier === peer.peerIdentifier) {\n- availablePeers.splice(i, 1);\n- logger.debug(\"TEST: peer removed:\", peer.peerIdentifier);\n- }\n- }\n- tryToConnect();\n- });\n- }\n- });\n- };\n-\n- function peerAvailabilityChanged(peers) {\n- console.log(\"TEST: peerAvailabilityChangedHandler invoked\");\n- peers.forEach(function (peer) {\n- if (peer.peerAvailable == true) {\n- // Add the peer to the availablePeers list\n- availablePeers.push(peer);\n- console.log(\"TEST: peer added:\", peer);\n- } else {\n- // Remove the peer from the availablePeers list\n- for (var i = availablePeers.length - 1; i >= 0; i--) {\n- if (availablePeers[i].peerIdentifier === peer.peerIdentifier) {\n- availablePeers.splice(i, 1);\n- console.log(\"TEST: peer removed:\", peer);\n- }\n- }\n- }\n- });\n-\n- if (status === connectStatus.NOT_CONNECTED && availablePeers.length > 0) {\n- tryToConnect();\n- }\n- }\n-\n- thaliMobileNativeTestUtils.startAndListen(t, server, peerAvailabilityChanged);\n-}\n-\ntest('Can connect to a remote peer', function (t) {\nvar server = net.createServer(function (socket) {\nsocket.pipe(socket);\n@@ -333,7 +271,8 @@ test('Can connect to a remote peer', function (t) {\nserver = makeIntoCloseAllServer(server);\nserverToBeClosed = server;\n- executeZombieProofTest(t, server, function (err, connection, peer) {\n+ thaliMobileNativeTestUtils.executeZombieProofTest(t, server,\n+ function (err, connection, peer) {\n// Called if we successfully connect to to a peer\nlogger.info(connection);\npeerIdsToBeClosed.push(peer.peerIdentifier);\n@@ -435,7 +374,8 @@ test('Can shift data', function (t) {\nserver = makeIntoCloseAllServer(server);\nserverToBeClosed = server;\n- executeZombieProofTest(t, server, function (err, connection, peer) {\n+ thaliMobileNativeTestUtils.executeZombieProofTest(t, server,\n+ function (err, connection, peer) {\npeerIdsToBeClosed.push(peer.peerIdentifier);\nvar nativePort = connection.listeningPort;\n@@ -461,7 +401,8 @@ test('Can shift data via parallel connections',\nserver = makeIntoCloseAllServer(server);\nserverToBeClosed = server;\n- executeZombieProofTest(t, server, function (err, connection, peer) {\n+ thaliMobileNativeTestUtils.executeZombieProofTest(t, server,\n+ function (err, connection, peer) {\npeerIdsToBeClosed.push(peer.peerIdentifier);\nvar nativePort = connection.listeningPort;\nPromise.all([\n@@ -560,7 +501,8 @@ test('Can shift data securely', function (t) {\nreturn waitForEvent(sock, 'close');\n}\n- executeZombieProofTest(t, server, function(err, connection, peer) {\n+ thaliMobileNativeTestUtils.executeZombieProofTest(t, server,\n+ function (err, connection, peer) {\npeerIdsToBeClosed.push(peer.peerIdentifier);\nreturn connect(tls, {\n@@ -635,7 +577,8 @@ test('Can shift large amounts of data', function (t) {\nsock.write(toSend);\n}\n- executeZombieProofTest(t, server, function (err, connection, peer) {\n+ thaliMobileNativeTestUtils.executeZombieProofTest(t, server,\n+ function (err, connection, peer) {\nvar client = null;\npeerIdsToBeClosed.push(peer.peerIdentifier);\n" }, { "change_type": "MODIFY", "old_path": "test/www/jxcore/bv_tests/testThaliMobileNativeWrapper.js", "new_path": "test/www/jxcore/bv_tests/testThaliMobileNativeWrapper.js", "diff": "@@ -24,16 +24,6 @@ var uuid = require('node-uuid');\nvar peerIdsToBeClosed = [];\n-/**\n- * @readonly\n- * @type {{NOT_CONNECTED: string, CONNECTING: string, CONNECTED: string}}\n- */\n-var connectStatus = {\n- NOT_CONNECTED : 'notConnected',\n- CONNECTING : 'connecting',\n- CONNECTED : 'connected'\n-};\n-\nvar test = tape({\nsetup: function (t) {\n// Make sure right handlers are registered in case\n@@ -165,70 +155,6 @@ test('error returned with bad router', function (t) {\n});\n});\n-function executeZombieProofTest (t, testFunction) {\n- console.log(\"TEST: execute ZombieProof test\");\n- var status = connectStatus.NOT_CONNECTED;\n- var availablePeers = [];\n-\n- var onConnectSuccess = function (err, connection, peer) {\n- console.log(\"TEST: onConnectSuccess\");\n- testFunction(err, connection, peer);\n- };\n-\n- var tryToConnect = function () {\n- availablePeers.forEach(function (peer) {\n- if (peer.peerAvailable && status === connectStatus.NOT_CONNECTED) {\n- status = connectStatus.CONNECTING;\n- console.log(\"TEST: connecting to peer:\", peer.peerIdentifier);\n- thaliMobileNativeTestUtils.connectToPeer(peer)\n- .then(function (connection) {\n- status = connectStatus.CONNECTED;\n- onConnectSuccess(null, connection, peer);\n- })\n- .catch(function (error) {\n- status = connectStatus.NOT_CONNECTED;\n- console.log(\"TEST: failed to connect to peer:\", peer.peerIdentifier);\n- // Remove the peer from the availablePeers list in case it is still there\n- for (var i = availablePeers.length - 1; i >= 0; i--) {\n- if (availablePeers[i].peerIdentifier === peer.peerIdentifier) {\n- availablePeers.splice(i, 1);\n- console.log(\"TEST: peer removed:\", peer.peerIdentifier);\n- }\n- }\n- tryToConnect();\n- });\n- }\n- });\n- };\n-\n- function nonTCPPeerAvailabilityChangedHandler(peers) {\n- console.log(\"TEST: nonTCPPeerAvailabilityChangedHandler invoked\");\n- peers.forEach(function (peer) {\n- if (peer.peerAvailable == true) {\n- // Add the peer to the availablePeers list\n- availablePeers.push(peer);\n- console.log(\"TEST: peer added:\", peer);\n- } else {\n- // Remove the peer from the availablePeers list\n- for (var i = availablePeers.length - 1; i >= 0; i--) {\n- if (availablePeers[i].peerIdentifier === peer.peerIdentifier) {\n- availablePeers.splice(i, 1);\n- console.log(\"TEST: peer removed:\", peer);\n- }\n- }\n- }\n- });\n-\n- if (status === connectStatus.NOT_CONNECTED && availablePeers.length > 0) {\n- tryToConnect();\n- }\n- }\n-\n- thaliMobileNativeWrapper.emitter.on('nonTCPPeerAvailabilityChangedEvent', function(peers) {\n- nonTCPPeerAvailabilityChangedHandler([peers]);\n- });\n-}\n-\nvar testPath = '/test';\nfunction trivialEndToEndTestScaffold(t, pskIdtoSecret, pskIdentity, pskKey,\ntestData, callback) {\n@@ -237,24 +163,15 @@ function trivialEndToEndTestScaffold(t, pskIdtoSecret, pskIdentity, pskKey,\nres.send(testData);\n});\n- thaliMobileNativeWrapper.start(router, pskIdtoSecret)\n- .then(function () {\n- return thaliMobileNativeWrapper.startListeningForAdvertisements();\n- })\n- .then(function () {\n- return thaliMobileNativeWrapper.startUpdateAdvertisingAndListening();\n- })\n- .then(function () {\n- executeZombieProofTest(t, function (err, connection, peer) {\nvar end = function (peerId, fail) {\n- peerIdsToBeClosed.push(peer.peerIdentifier);\n+ peerIdsToBeClosed.push(peerId);\nreturn callback ? callback(peerId, fail) : t.end();\n};\n- testUtils.get('127.0.0.1', connection.listeningPort, testPath, pskIdentity, pskKey)\n+ thaliMobileNativeTestUtils.getSamePeerWithRetry(testPath, pskIdentity, pskKey)\n.then(function (response) {\n- t.equal(response, testData,\n+ t.equal(response.httpResponseBody, testData,\n'response body should match testData');\nend(response.peerId);\n})\n@@ -262,7 +179,13 @@ function trivialEndToEndTestScaffold(t, pskIdtoSecret, pskIdentity, pskKey,\nt.fail('fail in trivialEndtoEndTestScaffold - ' + error);\nend(null, error);\n});\n- });\n+\n+ thaliMobileNativeWrapper.start(router, pskIdtoSecret)\n+ .then(function () {\n+ return thaliMobileNativeWrapper.startListeningForAdvertisements();\n+ })\n+ .then(function () {\n+ return thaliMobileNativeWrapper.startUpdateAdvertisingAndListening();\n});\n}\n@@ -1099,7 +1022,7 @@ test('We provide notification when a listener dies and we recreate it',\n}*/\n}\n- testUtils.getSamePeerWithRetry(testPath, pskIdentity, pskKey, peerId)\n+ thaliMobileNativeTestUtils.getSamePeerWithRetry(testPath, pskIdentity, pskKey, peerId)\n.then(function (response) {\nt.equal(response.httpResponseBody, testData,\n'recreate - response body should match testData');\n" }, { "change_type": "MODIFY", "old_path": "test/www/jxcore/bv_tests/testThaliMobileNativeiOS.js", "new_path": "test/www/jxcore/bv_tests/testThaliMobileNativeiOS.js", "diff": "@@ -23,16 +23,6 @@ var uuid = require('node-uuid');\nvar peerIdsToBeClosed = [];\n-/**\n- * @readonly\n- * @type {{NOT_CONNECTED: string, CONNECTING: string, CONNECTED: string}}\n- */\n-var connectStatus = {\n- NOT_CONNECTED : 'notConnected',\n- CONNECTING : 'connecting',\n- CONNECTED : 'connected'\n-};\n-\n// jshint -W064\n// A variable that can be used to store a server\n@@ -209,68 +199,6 @@ function reConnect(t, peerIdentifier, originalListeningPort) {\n});\n}\n-function executeZombieProofTest (t, server, testFunction) {\n- logger.debug(\"TEST: execute ZombieProof test\");\n- var status = connectStatus.NOT_CONNECTED;\n- var availablePeers = [];\n-\n- var onConnectSuccess = function (err, connection, peer) {\n- logger.debug(\"TEST: onConnectSuccess\");\n- testFunction(err, connection, peer);\n- };\n-\n- var tryToConnect = function () {\n- availablePeers.forEach(function (peer) {\n- if (peer.peerAvailable && status === connectStatus.NOT_CONNECTED) {\n- status = connectStatus.CONNECTING;\n- logger.debug(\"TEST: connecting to peer:\", peer.peerIdentifier);\n- thaliMobileNativeTestUtils.connectToPeer(peer)\n- .then(function (connection) {\n- status = connectStatus.CONNECTED;\n- onConnectSuccess(null, connection, peer);\n- })\n- .catch(function (error) {\n- status = connectStatus.NOT_CONNECTED;\n- logger.debug(\"TEST: failed to connect to peer:\", peer.peerIdentifier);\n- // Remove the peer from the availablePeers list in case it is still there\n- for (var i = availablePeers.length - 1; i >= 0; i--) {\n- if (availablePeers[i].peerIdentifier === peer.peerIdentifier) {\n- availablePeers.splice(i, 1);\n- logger.debug(\"TEST: peer removed:\", peer.peerIdentifier);\n- }\n- }\n- tryToConnect();\n- });\n- }\n- });\n- };\n-\n- function peerAvailabilityChanged(peers) {\n- logger.debug(\"TEST: peerAvailabilityChangedHandler invoked\");\n- peers.forEach(function (peer) {\n- if (peer.peerAvailable == true) {\n- // Add the peer to the availablePeers list\n- availablePeers.push(peer);\n- logger.debug(\"TEST: peer added:\", peer);\n- } else {\n- // Remove the peer from the availablePeers list\n- for (var i = availablePeers.length - 1; i >= 0; i--) {\n- if (availablePeers[i].peerIdentifier === peer.peerIdentifier) {\n- availablePeers.splice(i, 1);\n- logger.debug(\"TEST: peer removed:\", peer);\n- }\n- }\n- }\n- });\n-\n- if (status === connectStatus.NOT_CONNECTED && availablePeers.length > 0) {\n- tryToConnect();\n- }\n- }\n-\n- thaliMobileNativeTestUtils.startAndListen(t, server, peerAvailabilityChanged);\n-}\n-\ntest('Get same port when trying to connect multiple times on iOS',\nfunction (t) {\nvar server = net.createServer(function (socket) {\n@@ -279,7 +207,8 @@ test('Get same port when trying to connect multiple times on iOS',\nserver = makeIntoCloseAllServer(server);\nserverToBeClosed = server;\n- executeZombieProofTest(t, server, function (err, currentConnection, currentTestPeer) {\n+ thaliMobileNativeTestUtils.executeZombieProofTest(t, server,\n+ function (err, currentConnection, currentTestPeer) {\npeerIdsToBeClosed.push(currentTestPeer.peerIdentifier);\nvar listeningPort = currentConnection.listeningPort;\nvar connection = net.connect(listeningPort,\n" }, { "change_type": "MODIFY", "old_path": "test/www/jxcore/lib/testUtils.js", "new_path": "test/www/jxcore/lib/testUtils.js", "diff": "@@ -452,142 +452,6 @@ module.exports.getWithAgent = function (host, port, path, agent) {\n* @property {string} peerId\n*/\n-/**\n- * This function will grab the first peer it can via nonTCPAvailableHandler and\n- * will try to issue the GET request. If it fails then it will continue to\n- * listen to nonTCPAvailableHandler until it sees a port for the same PeerID\n- * and will try the GET again. It will repeat this process if there are\n- * failures until the timer runs out.\n- *\n- * @param {string} path\n- * @param {string} pskIdentity\n- * @param {Buffer} pskKey\n- * @param {?string} [selectedPeerId] This is only used for a single test that\n- * needs to reconnect to a known peer, otherwise it is null.\n- * @returns {Promise<Error | peerAndBody>}\n- */\n-module.exports.getSamePeerWithRetry = function (path, pskIdentity, pskKey,\n- selectedPeerId) {\n- // We don't load thaliMobileNativeWrapper until after the tests have started\n- // running so we pick up the right version of mobile\n- var thaliMobileNativeWrapper =\n- require('thali/NextGeneration/thaliMobileNativeWrapper');\n- return new Promise(function (resolve, reject) {\n- var retryCount = 0;\n- var MAX_TIME_TO_WAIT_IN_MILLISECONDS = 1000 * 60;\n- var GET_PORT_TIMEOUT = 1000 * 3;\n- var exitCalled = false;\n- var peerID = selectedPeerId;\n- var getRequestPromise = null;\n- var cancelGetPortTimeout = null;\n-\n- var timeoutId = setTimeout(function () {\n- exitCall(null, new Error('Timer expired'));\n- }, MAX_TIME_TO_WAIT_IN_MILLISECONDS);\n-\n- function exitCall(success, failure) {\n- if (exitCalled) {\n- return;\n- }\n- exitCalled = true;\n- clearTimeout(timeoutId);\n- clearTimeout(cancelGetPortTimeout);\n- thaliMobileNativeWrapper.emitter\n- .removeListener('nonTCPPeerAvailabilityChangedEvent',\n- nonTCPAvailableHandler);\n- return failure ? reject(failure) : resolve(\n- {\n- httpResponseBody: success,\n- peerId: peerID\n- });\n- }\n-\n- function tryAgain(portNumber) {\n- ++retryCount;\n- logger.warn('Retry count for getSamePeerWithRetry is ' + retryCount);\n- getRequestPromise = module.exports.get('127.0.0.1',\n- portNumber, path, pskIdentity, pskKey);\n- getRequestPromise\n- .then(function (result) {\n- exitCall(result);\n- })\n- .catch(function (err) {\n- logger.debug('getSamePeerWithRetry got an error it will retry - ' +\n- err);\n- });\n- }\n-\n- function callTryAgain(portNumber) {\n-\n- // We have a predefined peerID\n- if (!getRequestPromise) {\n- return tryAgain(portNumber);\n- }\n-\n- getRequestPromise\n- .then(function () {\n- // In theory this could maybe happen if a connection somehow got\n- // cut before we were notified of a successful result thus causing\n- // the system to automatically issue a new port, but that is\n- // unlikely\n- })\n- .catch(function (err) {\n- return tryAgain(portNumber, err);\n- });\n- }\n-\n- function getPort(record) {\n- return new Promise(function (resolve) {\n- if (platform.isIOS) {\n- thaliMobileNativeWrapper._multiConnect(record.peerIdentifier)\n- .then(function (port) {\n- resolve(port);\n- })\n- .catch(function () {\n- cancelGetPortTimeout = setTimeout(function () {\n- resolve(getPort(record));\n- }, GET_PORT_TIMEOUT);\n- });\n- } else {\n- resolve(record.portNumber);\n- }\n- });\n-\n- }\n-\n- function nonTCPAvailableHandler(record) {\n- // Ignore peer unavailable events\n- if (!record.peerAvailable) {\n- return;\n- }\n-\n- if (peerID && record.peerIdentifier === peerID) {\n- logger.warn('We got a peer unavailable notification for a ' +\n- 'peer we are looking for.');\n- }\n-\n- if (peerID && record.peerIdentifier !== peerID) {\n- return;\n- }\n-\n- logger.debug('We got a peer ' + JSON.stringify(record));\n-\n- if (!peerID) {\n- peerID = record.peerIdentifier;\n- }\n-\n- getPort(record)\n- .then(function (port) {\n- callTryAgain(port);\n- });\n- }\n-\n- thaliMobileNativeWrapper.emitter.on(\n- 'nonTCPPeerAvailabilityChangedEvent',\n- nonTCPAvailableHandler);\n- });\n-};\n-\nmodule.exports.validateCombinedResult = function (combinedResult) {\nif (combinedResult.wifiResult !== null ||\ncombinedResult.nativeResult !== null) {\n" }, { "change_type": "MODIFY", "old_path": "test/www/jxcore/lib/thaliMobileNativeTestUtils.js", "new_path": "test/www/jxcore/lib/thaliMobileNativeTestUtils.js", "diff": "@@ -12,10 +12,21 @@ var Promise = require('bluebird');\nvar net = require('net');\nvar inherits = require('util').inherits;\nvar EventEmitter = require('events').EventEmitter;\n+var testUtils = require('../lib/testUtils.js');\nvar ThaliMobileNativeWrapper =\nrequire('thali/NextGeneration/thaliMobileNativeWrapper.js');\n+/**\n+ * @readonly\n+ * @type {{NOT_CONNECTED: string, CONNECTING: string, CONNECTED: string}}\n+ */\n+var connectStatus = {\n+ NOT_CONNECTED : 'notConnected',\n+ CONNECTING : 'connecting',\n+ CONNECTED : 'connected'\n+};\n+\nfunction startAndListen(t, server, peerAvailabilityChangedHandler) {\nserver.listen(0, function () {\n@@ -218,6 +229,208 @@ function iOSConnectToPeer(peer, quitSignal) {\n});\n}\n+/**\n+ * This function will grab the first peer it can via nonTCPAvailableHandler and\n+ * will try to issue the GET request. If it fails then it will continue to\n+ * listen to nonTCPAvailableHandler until it sees a port for the same PeerID\n+ * and will try the GET again. It will repeat this process if there are\n+ * failures until the timer runs out.\n+ *\n+ * @param {string} path\n+ * @param {string} pskIdentity\n+ * @param {Buffer} pskKey\n+ * @param {?string} [selectedPeerId] This is only used for a single test that\n+ * needs to reconnect to a known peer, otherwise it is null.\n+ * @returns {Promise<Error | peerAndBody>}\n+ */\n+function getSamePeerWithRetry(path, pskIdentity, pskKey,\n+ selectedPeerId) {\n+ // We don't load thaliMobileNativeWrapper until after the tests have started\n+ // running so we pick up the right version of mobile\n+ var thaliMobileNativeWrapper =\n+ require('thali/NextGeneration/thaliMobileNativeWrapper');\n+ return new Promise(function (resolve, reject) {\n+ var retryCount = 0;\n+ var MAX_TIME_TO_WAIT_IN_MILLISECONDS = 1000 * 60;\n+ var exitCalled = false;\n+ var peerID = selectedPeerId;\n+ var getRequestPromise = null;\n+ var cancelGetPortTimeout = null;\n+ var status = connectStatus.NOT_CONNECTED;\n+ var availablePeers = [];\n+\n+ var timeoutId = setTimeout(function () {\n+ exitCall(null, new Error('Timer expired'));\n+ }, MAX_TIME_TO_WAIT_IN_MILLISECONDS);\n+\n+ function removeFromAvailablePeers(peer) {\n+ var i;\n+\n+ for (i = availablePeers.length - 1; i >= 0; i--) {\n+ if (availablePeers[i].peerIdentifier === peer.peerIdentifier) {\n+ availablePeers.splice(i, 1);\n+ }\n+ }\n+ }\n+\n+ function exitCall(success, failure) {\n+ if (exitCalled) {\n+ return;\n+ }\n+ exitCalled = true;\n+ clearTimeout(timeoutId);\n+ clearTimeout(cancelGetPortTimeout);\n+ thaliMobileNativeWrapper.emitter\n+ .removeListener('nonTCPPeerAvailabilityChangedEvent',\n+ nonTCPAvailableHandler);\n+ return failure ? reject(failure) : resolve(\n+ {\n+ httpResponseBody: success,\n+ peerId: peerID\n+ });\n+ }\n+\n+ function tryAgain(portNumber) {\n+ ++retryCount;\n+ logger.warn('Retry count for getSamePeerWithRetry is ' + retryCount);\n+ getRequestPromise = testUtils.get('127.0.0.1',\n+ portNumber, path, pskIdentity, pskKey);\n+ getRequestPromise\n+ .then(function (result) {\n+ exitCall(result);\n+ })\n+ .catch(function (err) {\n+ logger.debug('getSamePeerWithRetry got an error it will retry - ' +\n+ err);\n+ });\n+ }\n+\n+ function callTryAgain(portNumber) {\n+ // We have a predefined peerID\n+ if (!getRequestPromise) {\n+ return tryAgain(portNumber);\n+ }\n+\n+ getRequestPromise\n+ .then(function () {\n+ // In theory this could maybe happen if a connection somehow got\n+ // cut before we were notified of a successful result thus causing\n+ // the system to automatically issue a new port, but that is\n+ // unlikely\n+ })\n+ .catch(function (err) {\n+ return tryAgain(portNumber, err);\n+ });\n+ }\n+\n+ // In this case this method is only used when we run on iOS.\n+ function tryToConnect() {\n+ availablePeers.forEach(function (peer) {\n+ if (peer.peerAvailable && status === connectStatus.NOT_CONNECTED) {\n+ status = connectStatus.CONNECTING;\n+\n+ connectToPeer(peer)\n+ .then(function (connection) {\n+ // When we establish multi connect connections, run test.\n+ status = connectStatus.CONNECTED;\n+ callTryAgain(connection.listeningPort);\n+ })\n+ .catch(function (error) {\n+ status = connectStatus.NOT_CONNECTED;\n+\n+ removeFromAvailablePeers(peer);\n+ tryToConnect();\n+ });\n+ }\n+ });\n+ }\n+\n+ function nonTCPAvailableHandler(peer) {\n+ if (!peer.peerAvailable) {\n+ removeFromAvailablePeers(peer);\n+ return;\n+ }\n+\n+ availablePeers.push(peer);\n+\n+ logger.debug('We got a peer ' + JSON.stringify(peer));\n+\n+ if (!peerID) {\n+ peerID = peer.peerIdentifier;\n+ }\n+\n+ if (status === connectStatus.NOT_CONNECTED && availablePeers.length > 0) {\n+ if (!platform.isAndroid) {\n+ tryToConnect();\n+ } else {\n+ callTryAgain(peer.portNumber);\n+ }\n+ }\n+ }\n+\n+ thaliMobileNativeWrapper.emitter.on('nonTCPPeerAvailabilityChangedEvent', nonTCPAvailableHandler);\n+ });\n+}\n+\n+module.exports.getSamePeerWithRetry = getSamePeerWithRetry;\n+\n+function executeZombieProofTest (t, server, testFunction) {\n+ var status = connectStatus.NOT_CONNECTED;\n+ var availablePeers = [];\n+\n+ function removeFromAvailablePeers(peer) {\n+ var i;\n+\n+ for (i = availablePeers.length - 1; i >= 0; i--) {\n+ if (availablePeers[i].peerIdentifier === peer.peerIdentifier) {\n+ availablePeers.splice(i, 1);\n+ }\n+ }\n+ }\n+\n+ function tryToConnect() {\n+ availablePeers.forEach(function (peer) {\n+ if (peer.peerAvailable && status === connectStatus.NOT_CONNECTED) {\n+ status = connectStatus.CONNECTING;\n+\n+ connectToPeer(peer)\n+ .then(function (connection) {\n+ status = connectStatus.CONNECTED;\n+ testFunction(null, connection, peer);\n+ })\n+ .catch(function (error) {\n+ status = connectStatus.NOT_CONNECTED;\n+ // Remove the peer from the availablePeers list in case it is still there\n+ removeFromAvailablePeers(peer);\n+ tryToConnect();\n+ });\n+ }\n+ });\n+ }\n+\n+ // The peer we got here is in fact an one element array, so we\n+ // have to treat it like array.\n+ function peerAvailabilityChangedHandler(peerAsArray) {\n+ var peer = peerAsArray[0];\n+\n+ if (!peer.peerAvailable) {\n+ removeFromAvailablePeers(peer);\n+ return;\n+ }\n+\n+ availablePeers.push(peer);\n+\n+ logger.debug('We got a peer ' + JSON.stringify(peer));\n+\n+ if (status === connectStatus.NOT_CONNECTED && availablePeers.length > 0) {\n+ tryToConnect();\n+ }\n+ }\n+\n+ startAndListen(t, server, peerAvailabilityChangedHandler);\n+}\n+\n+module.exports.executeZombieProofTest = executeZombieProofTest;\nfunction getConnectionToOnePeerAndTest(t, connectTest) {\nvar echoServer = net.createServer(function (socket) {\n" } ]
JavaScript
MIT License
thaliproject/thali_cordovaplugin
Fix thaliMobileNativeWrapper tests, move executeZombieProofTest to thaliMobileNativeTestUtils, move getSamePeerWithRetry from testUtils to thaliMobileNativeTestUtils
675,375
08.06.2017 13:39:53
-7,200
7ea2dc52fd97792e6d71e664f36e5c27eb411658
Throw proper error when we call disconnect on iOS platform with incorrect peer identifier that is not uuid
[ { "change_type": "MODIFY", "old_path": "test/www/jxcore/lib/wifiBasedNativeMock.js", "new_path": "test/www/jxcore/lib/wifiBasedNativeMock.js", "diff": "@@ -812,6 +812,10 @@ MobileCallInstance.prototype.disconnect = function(peerIdentifier, callback) {\nreturn callback('Platform does not support multiConnect');\n}\n+ if (!uuidValidator(peerIdentifier)) {\n+ return callback('Bad parameters');\n+ }\n+\nthis._disconnect(peerIdentifier, callback);\n};\n" } ]
JavaScript
MIT License
thaliproject/thali_cordovaplugin
Throw proper error when we call disconnect on iOS platform with incorrect peer identifier that is not uuid
675,375
08.06.2017 14:58:08
-7,200
4987f6ca1aa8389c298a1ba6ab401cffac3afeae
Fix failing testThaliReplicationPeerActionCoordinated after changing wifiBasedNativeMock
[ { "change_type": "MODIFY", "old_path": "test/www/jxcore/bv_tests/testThaliReplicationPeerActionCoordinated.js", "new_path": "test/www/jxcore/bv_tests/testThaliReplicationPeerActionCoordinated.js", "diff": "@@ -112,7 +112,7 @@ test('Coordinated replication action test - each device has the same local db na\n}\nexited = true;\n- peerIdsToBeClosed.push(thaliReplicationPeerAction.getPeerIdentifier());\n+ peerIdsToBeClosed.push(notificationForUs.peerId);\nresultError = error;\nchanges.cancel();\n}\n@@ -259,7 +259,7 @@ test('Coordinated replication action test - each device has different local db n\n}\nexited = true;\n- peerIdsToBeClosed.push(thaliReplicationPeerAction.getPeerIdentifier());\n+ peerIdsToBeClosed.push(notificationForUs.peerId);\nresultError = error;\nchanges.cancel();\n}\n@@ -410,14 +410,14 @@ test('Coordinated replication action test - should throw error when wrong remote\n// This should be rejected since we provided non existing remote db\nthaliReplicationPeerAction.start(httpAgentPool, wrongRemoteDbName)\n.then(function() {\n- peerIdsToBeClosed.push(thaliReplicationPeerAction.getPeerIdentifier());\n+ peerIdsToBeClosed.push(notificationForUs.peerId);\nvar error = 'we should not be able to replicate with db that doesn\\'t exist';\nt.fail(error);\nreject(new Error(error));\n})\n.catch(function (error) {\n- peerIdsToBeClosed.push(thaliReplicationPeerAction.getPeerIdentifier());\n+ peerIdsToBeClosed.push(notificationForUs.peerId);\nt.equals(error.reason, ERROR_NO_DB_FILE, 'error should be \\'no_db_file\\'');\nresolve(true);\n" } ]
JavaScript
MIT License
thaliproject/thali_cordovaplugin
Fix failing testThaliReplicationPeerActionCoordinated after changing wifiBasedNativeMock
675,375
09.06.2017 16:38:54
-7,200
fd55b4f60dacaf4b7344b38093f46c649464adde
Adjust zombieProofFunction to properly handle more than 2 devices, refactor testHttp to use zombieProofFunction, always wait for all participants to end before calling t.end in testThaliMobileNative, testHttp, testThaliMobileNativeiOS, testThaliMobileNativeWrapper
[ { "change_type": "MODIFY", "old_path": "test/www/jxcore/bv_tests/testHttp.js", "new_path": "test/www/jxcore/bv_tests/testHttp.js", "diff": "@@ -9,32 +9,35 @@ var ThaliMobileNativeWrapper =\nvar ThaliMobile = require('thali/NextGeneration/thaliMobile');\nvar platform = require('thali/NextGeneration/utils/platform');\nvar makeIntoCloseAllServer = require('thali/NextGeneration/makeIntoCloseAllServer');\n+var thaliMobileNativeTestUtils = require('../lib/thaliMobileNativeTestUtils');\n-var router = function () {};\nvar httpServer = null;\n+var peerIdsToBeClosed = [];\n+\nvar test = tape({\nsetup: function (t) {\nhttpServer = makeIntoCloseAllServer(http.createServer(), true);\nt.end();\n},\nteardown: function (t) {\n+ if (!platform.isAndroid) {\n+ peerIdsToBeClosed.forEach(function (peerIdToBeClosed) {\n+ Mobile('disconnect').callNative(peerIdToBeClosed, function (err) {\n+ t.notOk(\n+ err,\n+ 'Should be able to call disconnect in teardown'\n+ );\n+ });\n+ });\n+ }\n+ peerIdsToBeClosed = [];\n+\n(httpServer !== null ? httpServer.closeAllPromise() :\nPromise.resolve())\n.catch(function (err) {\nt.fail('httpServer had stop err ' + err);\n})\n- .then(function () {\n- return ThaliMobileNativeWrapper.stop();\n- })\n- .then(function() {\n- return new Promise(function(res) {\n- setTimeout(function() {\n- res();\n- }, 15000);\n- });\n- })\n- .catch(t.fail)\n.then(t.end);\n}\n});\n@@ -157,49 +160,22 @@ test('Single coordinated request ios native',\n},\nfunction (t) {\nvar total = t.participants.length - 1;\n- var peerFinder = new PeerFinder();\n+ var counter = 0;\nhttpServer.on('request', function (req, res) {\nvar reply = req.method + ' ' + req.url;\nres.end(reply);\n});\n- var listenNative = ThaliMobileNativeWrapper.start(router).then(function () {\n- return ThaliMobileNativeWrapper.startListeningForAdvertisements();\n- });\n- var listenServer = serverIsListening(httpServer, 0);\n-\n- var findPeers = peerFinder.find(total);\n+ thaliMobileNativeTestUtils.executeZombieProofTest(t, httpServer, function (err, connection, peer) {\n+ makeRequest('127.0.0.1', httpServer.address().port, 'GET', '/path')\n+ .then(function (response) {\n+ peerIdsToBeClosed.push(peer.peerIdentifier);\n+ t.equal(response.toString(), 'GET /path');\n- Promise.all([ listenNative, listenServer ])\n- .then(function () {\n- var port = httpServer.address().port;\n- console.log('listening on %d', port);\n- return ThaliMobileNativeWrapper\n- .startUpdateAdvertisingAndListening(port);\n- })\n- .then(function () {\n- return findPeers;\n- })\n- .then(function (peers) {\n- return Promise.all(peers.map(function (peer) {\n- return ThaliMobileNativeWrapper._multiConnect(peer.peerIdentifier);\n- }));\n- })\n- .then(function (ports) {\n- return Promise.all(ports.map(function (port) {\n- return makeRequest('127.0.0.1', port, 'GET', '/path');\n- }));\n- })\n- .then(function (responses) {\n- responses.forEach(function (r) {\n- t.equal(r.toString(), 'GET /path');\n- });\n+ ++counter === total ? t.end() : t.pass();\n})\n.catch(t.fail)\n- .then(function () {\n- peerFinder.cleanup();\n- t.end();\n});\n});\n@@ -231,13 +207,14 @@ test('Multiple coordinated request ios native',\nglobal.NETWORK_TYPE === ThaliMobile.networkTypes.WIFI;\n},\nfunction (t) {\n- var char = 'a';\n- var firstReply = char.repeat(2000);\n- var secondReply = char.repeat(30);\n- var thirdReply = char.repeat(3000);\n+ var firstReply = 'firstReply';\n+ var secondReply = 'secondReply';\n+ var thirdReply = 'thirdReply';\n+ var expectedReplies = [ firstReply, secondReply, thirdReply ];\n+\nvar reply;\nvar total = t.participants.length - 1;\n- var peerFinder = new PeerFinder();\n+ var counter = 0;\nhttpServer.on('request', function (req, res) {\nswitch (req.url) {\n@@ -256,47 +233,17 @@ test('Multiple coordinated request ios native',\nres.end(reply);\n});\n- var listenNative = ThaliMobileNativeWrapper.start(router).then(function () {\n- return ThaliMobileNativeWrapper.startListeningForAdvertisements();\n- });\n- var listenServer = serverIsListening(httpServer, 0);\n+ thaliMobileNativeTestUtils.executeZombieProofTest(t, httpServer, function (err, connection, peer) {\n+ var localCounter = counter;\n- var findPeers = peerFinder.find(total);\n+ makeRequest('127.0.0.1', httpServer.address().port, 'GET', '/path' + localCounter)\n+ .then(function (response) {\n- Promise.all([ listenNative, listenServer ])\n- .then(function () {\n- var port = httpServer.address().port;\n- console.log('listening on %d', port);\n- return ThaliMobileNativeWrapper\n- .startUpdateAdvertisingAndListening(port);\n- })\n- .then(function () {\n- return findPeers;\n- })\n- .then(function (peers) {\n- return Promise.all(peers.map(function (peer) {\n- return ThaliMobileNativeWrapper._multiConnect(peer.peerIdentifier);\n- }));\n- })\n- .then(function (ports) {\n- return Promise.all(ports.map(function (port) {\n- return Promise.all([\n- makeRequest('127.0.0.1', port, 'GET', '/path0'),\n- makeRequest('127.0.0.1', port, 'GET', '/path1'),\n- makeRequest('127.0.0.1', port, 'GET', '/path2'),\n- ]);\n- }));\n- })\n- .then(function (responses) {\n- responses.forEach(function (r) {\n- t.equal(r[0].toString(), firstReply);\n- t.equal(r[1].toString(), secondReply);\n- t.equal(r[2].toString(), thirdReply);\n- });\n+ peerIdsToBeClosed.push(peer.peerIdentifier);\n+ t.equal(response.toString(), expectedReplies[localCounter]);\n+\n+ ++counter === total ? t.end() : t.pass();\n})\n- .catch(t.fail)\n- .then(function () {\n- peerFinder.cleanup();\n- t.end();\n+ .catch(t.fail);\n});\n});\n" }, { "change_type": "MODIFY", "old_path": "test/www/jxcore/bv_tests/testThaliMobileNative.js", "new_path": "test/www/jxcore/bv_tests/testThaliMobileNative.js", "diff": "@@ -254,6 +254,9 @@ function connectToListenerSendMessageGetResponseLength(t, port, request,\n}\ntest('Can connect to a remote peer', function (t) {\n+ var counter = 0;\n+ var total = t.participants.length - 1;\n+\nvar server = net.createServer(function (socket) {\nsocket.pipe(socket);\n});\n@@ -275,7 +278,7 @@ test('Can connect to a remote peer', function (t) {\n// is still hiding around.\nt.ok(connection.listeningPort !== 0, 'listening port should not be 0');\n- t.end();\n+ ++counter === total ? t.end() : t.pass();\n});\n});\n@@ -357,6 +360,9 @@ function createServer(t, dataLength) {\n}\ntest('Can shift data', function (t) {\n+ var counter = 0;\n+ var total = t.participants.length - 1;\n+\nvar exchangeData = 'small amount of data';\nvar server = createServer(t, exchangeData.length);\n@@ -374,7 +380,7 @@ test('Can shift data', function (t) {\n})\n.catch(t.fail)\n.then(function () {\n- t.end();\n+ ++counter === total ? t.end() : t.pass();\n});\n});\n});\n@@ -384,6 +390,9 @@ test('Can shift data via parallel connections',\nreturn platform.isAndroid;\n},\nfunction (t) {\n+ var counter = 0;\n+ var total = t.participants.length - 1;\n+\nvar dataLength = 16 * 1024;\nvar server = createServer(t, dataLength);\n@@ -407,12 +416,15 @@ test('Can shift data via parallel connections',\n})\n.catch(t.fail)\n.then(function () {\n- t.end();\n+ ++counter === total ? t.end() : t.pass();\n});\n});\n});\ntest('Can shift data securely', function (t) {\n+ var counter = 0;\n+ var total = t.participants.length - 1;\n+\nvar exchangeData = 'small amount of data';\nvar pskKey = new Buffer('psk-key');\n@@ -505,12 +517,15 @@ test('Can shift data securely', function (t) {\n})\n.catch(t.fail)\n.then(function () {\n- t.end();\n+ ++counter === total ? t.end() : t.pass();\n});\n});\n});\ntest('Can shift large amounts of data', function (t) {\n+ var counter = 0;\n+ var total = t.participants.length - 1;\n+\nvar sockets = {};\nvar server = net.createServer(function (socket) {\nsocket.on('data', function (data) {\n@@ -555,8 +570,11 @@ test('Can shift large amounts of data', function (t) {\nif (!done) {\ndone = true;\nt.ok(toSend === toRecv, 'received should match sent forward');\n+\n+ if (++counter === total) {\nt.end();\n}\n+ }\nif (data.length) {\nsock.write(data);\n}\n" }, { "change_type": "MODIFY", "old_path": "test/www/jxcore/bv_tests/testThaliMobileNativeWrapper.js", "new_path": "test/www/jxcore/bv_tests/testThaliMobileNativeWrapper.js", "diff": "@@ -158,6 +158,9 @@ test('error returned with bad router', function (t) {\nvar testPath = '/test';\nfunction trivialEndToEndTestScaffold(t, pskIdtoSecret, pskIdentity, pskKey,\ntestData, callback) {\n+ var total = t.participants.length - 1;\n+ var counter = 0;\n+\nvar router = express.Router();\nrouter.get(testPath, function (req, res) {\nres.send(testData);\n@@ -165,7 +168,7 @@ function trivialEndToEndTestScaffold(t, pskIdtoSecret, pskIdentity, pskKey,\nvar end = function (peerId, fail) {\npeerIdsToBeClosed.push(peerId);\n- return callback ? callback(peerId, fail) : t.end();\n+ return callback ? callback(peerId, fail) : ++counter === total ? t.end() : t.pass();\n};\nthaliMobileNativeTestUtils.getSamePeerWithRetry(testPath, pskIdentity, pskKey)\n" }, { "change_type": "MODIFY", "old_path": "test/www/jxcore/bv_tests/testThaliMobileNativeiOS.js", "new_path": "test/www/jxcore/bv_tests/testThaliMobileNativeiOS.js", "diff": "@@ -199,6 +199,9 @@ function reConnect(t, peerIdentifier, originalListeningPort) {\ntest('Get same port when trying to connect multiple times on iOS',\nfunction (t) {\n+ var total = t.participants.length - 1;\n+ var counter = 0;\n+\nvar server = net.createServer(function (socket) {\nsocket.pipe(socket);\n});\n@@ -219,7 +222,7 @@ test('Get same port when trying to connect multiple times on iOS',\nreturn reConnect(t, currentTestPeer.peerIdentifier,\nlisteningPort);\n}).then(function () {\n- t.end();\n+ ++counter === total ? t.end() : t.pass();\n});\n});\n" }, { "change_type": "MODIFY", "old_path": "test/www/jxcore/lib/thaliMobileNativeTestUtils.js", "new_path": "test/www/jxcore/lib/thaliMobileNativeTestUtils.js", "diff": "@@ -378,12 +378,14 @@ module.exports.getSamePeerWithRetry = getSamePeerWithRetry;\n* This function is responsible for execution of test function requiring connection to the other peer.\n* It assures that the connection is not established with the zombie advertiser. In case of the connection error\n* it checks if there are other peers available beside the one already tried.\n+ * TODO: We could collect available peers and after that fire test function for every one to avoid\n+ * not coordinated behaviour like one peer will finish before another\n* @param {object} t test object.\n* @param {net.Server} server Server object\n* @param {function} testFunction\n*/\nfunction executeZombieProofTest (t, server, testFunction) {\n- var status = connectStatus.NOT_CONNECTED;\n+ //var status = connectStatus.NOT_CONNECTED;\nvar availablePeers = [];\nfunction removeFromAvailablePeers(peer) {\n@@ -397,17 +399,20 @@ function executeZombieProofTest (t, server, testFunction) {\n}\nfunction tryToConnect() {\n- availablePeers.forEach(function (peer) {\n+ availablePeers.forEach(function (record) {\n+ var peer = record.peer;\n+ var status = record.status;\n+\nif (peer.peerAvailable && status === connectStatus.NOT_CONNECTED) {\n- status = connectStatus.CONNECTING;\n+ record.status = connectStatus.CONNECTING;\nconnectToPeer(peer)\n.then(function (connection) {\n- status = connectStatus.CONNECTED;\n+ record.status = connectStatus.CONNECTED;\ntestFunction(null, connection, peer);\n})\n.catch(function (error) {\n- status = connectStatus.NOT_CONNECTED;\n+ record.status = connectStatus.NOT_CONNECTED;\n// Remove the peer from the availablePeers list in case it is still there\nremoveFromAvailablePeers(peer);\ntryToConnect();\n@@ -426,14 +431,15 @@ function executeZombieProofTest (t, server, testFunction) {\nreturn;\n}\n- availablePeers.push(peer);\n+ availablePeers.push({\n+ peer: peer,\n+ status: connectStatus.NOT_CONNECTED\n+ });\nlogger.debug('We got a peer ' + JSON.stringify(peer));\n- if (status === connectStatus.NOT_CONNECTED && availablePeers.length > 0) {\ntryToConnect();\n}\n- }\nstartAndListen(t, server, peerAvailabilityChangedHandler);\n}\n" } ]
JavaScript
MIT License
thaliproject/thali_cordovaplugin
Adjust zombieProofFunction to properly handle more than 2 devices, refactor testHttp to use zombieProofFunction, always wait for all participants to end before calling t.end in testThaliMobileNative, testHttp, testThaliMobileNativeiOS, testThaliMobileNativeWrapper
675,375
14.06.2017 09:24:23
-7,200
9caf7c1f5514e5634b23500aedf9b67fa275d951
Fix failing unknown assertion
[ { "change_type": "MODIFY", "old_path": "test/www/jxcore/bv_tests/testHttp.js", "new_path": "test/www/jxcore/bv_tests/testHttp.js", "diff": "@@ -38,7 +38,9 @@ var test = tape({\n.catch(function (err) {\nt.fail('httpServer had stop err ' + err);\n})\n- .then(t.end);\n+ .then(function () {\n+ t.end();\n+ });\n}\n});\n@@ -147,10 +149,15 @@ test('Single local http request', function (t) {\nvar port = httpServer.address().port;\nconsole.log('listening on %d', port);\nreturn makeRequest('127.0.0.1', port, 'GET', '/path');\n- }).then(function (data) {\n+ })\n+ .then(function (data) {\nt.equal(data.toString(), 'GET /path');\nreturn null;\n- }).catch(t.fail).then(t.end);\n+ })\n+ .catch(t.fail)\n+ .then(function () {\n+ t.end();\n+ });\n});\ntest('Single coordinated request ios native',\n@@ -193,12 +200,17 @@ test('Multiple local http requests', function (t) {\nmakeRequest('127.0.0.1', port, 'GET', '/path1'),\nmakeRequest('127.0.0.1', port, 'GET', '/path2'),\n]);\n- }).then(function (data) {\n+ })\n+ .then(function (data) {\nt.equal(data[0].toString(), 'GET /path0');\nt.equal(data[1].toString(), 'GET /path1');\nt.equal(data[2].toString(), 'GET /path2');\nreturn null;\n- }).catch(t.fail).then(t.end);\n+ })\n+ .catch(t.fail)\n+ .then(function () {\n+ t.end();\n+ });\n});\ntest('Multiple coordinated request ios native',\n" }, { "change_type": "MODIFY", "old_path": "test/www/jxcore/bv_tests/testThaliMobile.js", "new_path": "test/www/jxcore/bv_tests/testThaliMobile.js", "diff": "@@ -1484,7 +1484,9 @@ test('#disconnect fails on wifi peers', function (t) {\n'Got specific error message');\nreturn null;\n})\n- .then(t.end);\n+ .then(function () {\n+ t.end();\n+ });\n};\nThaliMobile.emitter.on('peerAvailabilityChanged', availabilityHandler);\n" }, { "change_type": "MODIFY", "old_path": "test/www/jxcore/bv_tests/testThaliMobileNative.js", "new_path": "test/www/jxcore/bv_tests/testThaliMobileNative.js", "diff": "@@ -372,7 +372,9 @@ test('Can shift data', function (t) {\nreturn shiftData(t, socket, exchangeData);\n})\n.catch(t.fail)\n- .then(t.end);\n+ .then(function () {\n+ t.end();\n+ });\n});\n});\n@@ -403,7 +405,9 @@ test('Can shift data via parallel connections',\n}));\n})\n.catch(t.fail)\n- .then(t.end);\n+ .then(function () {\n+ t.end();\n+ });\n});\n});\n@@ -499,7 +503,9 @@ test('Can shift data securely', function (t) {\nreturn shiftData(socket);\n})\n.catch(t.fail)\n- .then(t.end);\n+ .then(function () {\n+ t.end();\n+ });\n});\n});\n" }, { "change_type": "MODIFY", "old_path": "test/www/jxcore/bv_tests/testThaliMobileNativeiOS.js", "new_path": "test/www/jxcore/bv_tests/testThaliMobileNativeiOS.js", "diff": "@@ -218,7 +218,10 @@ test('Get same port when trying to connect multiple times on iOS',\n.then(function () {\nreturn reConnect(t, currentTestPeer.peerIdentifier,\nlisteningPort);\n- }).then(t.end);\n+ })\n+ .then(function () {\n+ t.end();\n+ });\n});\nconnection.on('error', function (err) {\nt.fail('lost connection because of ' + err);\n" }, { "change_type": "MODIFY", "old_path": "test/www/jxcore/lib/thaliMobileNativeTestUtils.js", "new_path": "test/www/jxcore/lib/thaliMobileNativeTestUtils.js", "diff": "@@ -436,7 +436,6 @@ function executeZombieProofTest (t, server, testFunction) {\nstartAndListen(t, server, peerAvailabilityChangedHandler);\n}\n-\nmodule.exports.executeZombieProofTest = executeZombieProofTest;\nfunction getConnectionToOnePeerAndTest(t, connectTest) {\n" } ]
JavaScript
MIT License
thaliproject/thali_cordovaplugin
Fix failing unknown assertion
675,375
14.06.2017 10:32:59
-7,200
90c44805d96704b9548e2554fd737a751d11daa0
Remove not used argument, set proper peerId in testThaliMobileNativeWrapper
[ { "change_type": "MODIFY", "old_path": "test/www/jxcore/bv_tests/testHttp.js", "new_path": "test/www/jxcore/bv_tests/testHttp.js", "diff": "@@ -174,7 +174,7 @@ test('Single coordinated request ios native',\nres.end(reply);\n});\n- thaliMobileNativeTestUtils.executeZombieProofTest(t, httpServer, function (err, connection, peer) {\n+ thaliMobileNativeTestUtils.executeZombieProofTest(t, httpServer, function (connection, peer) {\nmakeRequest('127.0.0.1', httpServer.address().port, 'GET', '/path')\n.then(function (response) {\npeerIdsToBeClosed.push(peer.peerIdentifier);\n@@ -245,7 +245,7 @@ test('Multiple coordinated request ios native',\nres.end(reply);\n});\n- thaliMobileNativeTestUtils.executeZombieProofTest(t, httpServer, function (err, connection, peer) {\n+ thaliMobileNativeTestUtils.executeZombieProofTest(t, httpServer, function (connection, peer) {\nvar localCounter = counter;\nmakeRequest('127.0.0.1', httpServer.address().port, 'GET', '/path' + localCounter)\n" }, { "change_type": "MODIFY", "old_path": "test/www/jxcore/bv_tests/testThaliMobileNative.js", "new_path": "test/www/jxcore/bv_tests/testThaliMobileNative.js", "diff": "@@ -261,7 +261,7 @@ test('Can connect to a remote peer', function (t) {\nserverToBeClosed = server;\nthaliMobileNativeTestUtils.executeZombieProofTest(t, server,\n- function (err, connection, peer) {\n+ function (connection, peer) {\n// Called if we successfully connect to to a peer\nlogger.info(connection);\npeerIdsToBeClosed.push(peer.peerIdentifier);\n@@ -363,7 +363,7 @@ test('Can shift data', function (t) {\nserverToBeClosed = server;\nthaliMobileNativeTestUtils.executeZombieProofTest(t, server,\n- function (err, connection, peer) {\n+ function (connection, peer) {\npeerIdsToBeClosed.push(peer.peerIdentifier);\nvar nativePort = connection.listeningPort;\n@@ -390,7 +390,7 @@ test('Can shift data via parallel connections',\nserverToBeClosed = server;\nthaliMobileNativeTestUtils.executeZombieProofTest(t, server,\n- function (err, connection, peer) {\n+ function (connection, peer) {\npeerIdsToBeClosed.push(peer.peerIdentifier);\nvar nativePort = connection.listeningPort;\nPromise.all([\n@@ -490,7 +490,7 @@ test('Can shift data securely', function (t) {\n}\nthaliMobileNativeTestUtils.executeZombieProofTest(t, server,\n- function (err, connection, peer) {\n+ function (connection, peer) {\npeerIdsToBeClosed.push(peer.peerIdentifier);\nreturn connect(tls, {\n@@ -566,7 +566,7 @@ test('Can shift large amounts of data', function (t) {\n}\nthaliMobileNativeTestUtils.executeZombieProofTest(t, server,\n- function (err, connection, peer) {\n+ function (connection, peer) {\nvar client = null;\npeerIdsToBeClosed.push(peer.peerIdentifier);\n" }, { "change_type": "MODIFY", "old_path": "test/www/jxcore/lib/thaliMobileNativeTestUtils.js", "new_path": "test/www/jxcore/lib/thaliMobileNativeTestUtils.js", "diff": "@@ -332,6 +332,7 @@ function getSamePeerWithRetry(path, pskIdentity, pskKey,\nconnectToPeer(peer)\n.then(function (connection) {\n// When we establish multi connect connections, run test.\n+ peerID = peer.peerIdentifier;\nstatus = connectStatus.CONNECTED;\ncallTryAgain(connection.listeningPort);\n})\n@@ -355,10 +356,6 @@ function getSamePeerWithRetry(path, pskIdentity, pskKey,\nlogger.debug('We got a peer ' + JSON.stringify(peer));\n- if (!peerID) {\n- peerID = peer.peerIdentifier;\n- }\n-\nif (status === connectStatus.NOT_CONNECTED && availablePeers.length > 0) {\nif (!platform.isAndroid) {\ntryToConnect();\n@@ -406,7 +403,7 @@ function executeZombieProofTest (t, server, testFunction) {\nconnectToPeer(peer)\n.then(function (connection) {\nstatus = connectStatus.CONNECTED;\n- testFunction(null, connection, peer);\n+ testFunction(connection, peer);\n})\n.catch(function (error) {\nstatus = connectStatus.NOT_CONNECTED;\n" } ]
JavaScript
MIT License
thaliproject/thali_cordovaplugin
Remove not used argument, set proper peerId in testThaliMobileNativeWrapper
675,375
14.06.2017 12:50:24
-7,200
6fd0a8a7e9be99409066d217030c9ed11148c2b0
Do not kill connections in testThaliReplicationPeerActionCoordinated. It supposed to be done automatically by Thali, so we should not do this manually
[ { "change_type": "MODIFY", "old_path": "test/www/jxcore/bv_tests/testThaliManagerCoordinated.js", "new_path": "test/www/jxcore/bv_tests/testThaliManagerCoordinated.js", "diff": "@@ -7,6 +7,7 @@ if (!tape.coordinated) {\nvar testUtils = require('../lib/testUtils.js');\nvar logger = require('../lib/testLogger.js')('testThaliManagerCoordinated');\n+var platform = require('thali/NextGeneration/utils/platform');\nvar crypto = require('crypto');\nvar Promise = require('bluebird');\n@@ -17,6 +18,8 @@ var thaliConfig = require('thali/NextGeneration/thaliConfig');\nvar ThaliManager = require('thali/NextGeneration/thaliManager');\nvar ThaliPeerPoolDefault =\nrequire('thali/NextGeneration/thaliPeerPool/thaliPeerPoolDefault');\n+var thaliMobileNativeWrapper =\n+ require('thali/NextGeneration/thaliMobileNativeWrapper');\n// Public key for local device should be passed\n// to the tape 'setup' as 'tape.data'.\n@@ -32,19 +35,41 @@ PouchDB = testUtils.getLevelDownPouchDb();\nvar thaliManager;\n+var peerIdsToBeClosed = [];\n+\nvar test = tape({\nsetup: function (t) {\n+ thaliMobileNativeWrapper.emitter.on('nonTCPPeerAvailabilityChangedEvent', nonTcpPeerAvailableChangedListener);\nt.data = publicKeyForLocalDevice.toJSON();\nt.end();\n},\nteardown: function (t) {\nPromise.resolve()\n+ .then(function () {\n+ peerIdsToBeClosed.forEach(function (peerIdToBeClosed) {\n+\n+ });\n+ })\n.then(function () {\nif (thaliManager) {\nreturn thaliManager.stop();\n}\n})\n.then(function () {\n+ if (!platform.isAndroid) {\n+ peerIdsToBeClosed.forEach(function (peerIdToBeClosed) {\n+ Mobile('disconnect').callNative(peerIdToBeClosed, function (err) {\n+ t.notOk(\n+ err,\n+ 'Should be able to call disconnect in teardown'\n+ );\n+ });\n+ });\n+ }\n+ peerIdsToBeClosed = [];\n+\n+ thaliMobileNativeWrapper.emitter.removeListener('nonTCPPeerAvailabilityChangedEvent',\n+ nonTcpPeerAvailableChangedListener);\nt.end();\n});\n},\n@@ -55,6 +80,10 @@ var test = tape({\nteardownTimeout: 3 * 60 * 1000\n});\n+function nonTcpPeerAvailableChangedListener(peer) {\n+ peerIdsToBeClosed.push(peer.peerIdentifier);\n+}\n+\nvar DEBUG = false;\nfunction debug() {\nif (!DEBUG) {\n" }, { "change_type": "MODIFY", "old_path": "test/www/jxcore/bv_tests/testThaliReplicationPeerActionCoordinated.js", "new_path": "test/www/jxcore/bv_tests/testThaliReplicationPeerActionCoordinated.js", "diff": "@@ -16,7 +16,6 @@ var ThaliNotificationClient = require('thali/NextGeneration/notification/thal\nvar ThaliPeerPoolDefault = require('thali/NextGeneration/thaliPeerPool/thaliPeerPoolDefault');\nvar ThaliReplicationPeerAction = require('thali/NextGeneration/replication/thaliReplicationPeerAction');\n-var platform = require('thali/NextGeneration/utils/platform');\nvar devicePublicPrivateKey = crypto.createECDH(thaliConfig.BEACON_CURVE);\nvar devicePublicKey = devicePublicPrivateKey.generateKeys();\nvar TestPouchDB = testUtils.getLevelDownPouchDb();\n@@ -31,8 +30,6 @@ var LOCAL_DB_NAME = 'repActionTest';\nvar EXPIRATION_TIMEOUT = 60 * 60 * 1000;\nvar ERROR_NO_DB_FILE = 'no_db_file';\n-var peerIdsToBeClosed = [];\n-\nif (!tape.coordinated) {\nreturn;\n}\n@@ -47,17 +44,6 @@ var test = tape({\nif (localPouchDB) {\nlocalPouchDB.destroy();\n}\n- if (!platform.isAndroid) {\n- peerIdsToBeClosed.forEach(function (peerIdToBeClosed) {\n- Mobile('disconnect').callNative(peerIdToBeClosed, function (err) {\n- t.notOk(\n- err,\n- 'Should be able to call disconnect in teardown'\n- );\n- });\n- });\n- }\n- peerIdsToBeClosed = [];\nt.end();\n}\n});\n@@ -112,7 +98,6 @@ test('Coordinated replication action test - each device has the same local db na\n}\nexited = true;\n- peerIdsToBeClosed.push(notificationForUs.peerId);\nresultError = error;\nchanges.cancel();\n}\n@@ -259,7 +244,6 @@ test('Coordinated replication action test - each device has different local db n\n}\nexited = true;\n- peerIdsToBeClosed.push(notificationForUs.peerId);\nresultError = error;\nchanges.cancel();\n}\n@@ -398,7 +382,6 @@ test('Coordinated replication action test - should throw error when wrong remote\npeerActions.push(thaliReplicationPeerAction);\nreturn new Promise(function (resolve, reject) {\n-\nvar httpAgentPool = new ForeverAgent.SSL({\nrejectUnauthorized: false,\nmaxSockets: 8,\n@@ -410,15 +393,11 @@ test('Coordinated replication action test - should throw error when wrong remote\n// This should be rejected since we provided non existing remote db\nthaliReplicationPeerAction.start(httpAgentPool, wrongRemoteDbName)\n.then(function() {\n- peerIdsToBeClosed.push(notificationForUs.peerId);\n-\nvar error = 'we should not be able to replicate with db that doesn\\'t exist';\nt.fail(error);\nreject(new Error(error));\n})\n.catch(function (error) {\n- peerIdsToBeClosed.push(notificationForUs.peerId);\n-\nt.equals(error.reason, ERROR_NO_DB_FILE, 'error should be \\'no_db_file\\'');\nresolve(true);\n});\n" } ]
JavaScript
MIT License
thaliproject/thali_cordovaplugin
Do not kill connections in testThaliReplicationPeerActionCoordinated. It supposed to be done automatically by Thali, so we should not do this manually
675,375
14.06.2017 14:04:03
-7,200
a997e0f8f4a85a37276abadc47c842486ae34a57
Fix dekstop tests
[ { "change_type": "MODIFY", "old_path": "test/www/jxcore/lib/thaliMobileNativeTestUtils.js", "new_path": "test/www/jxcore/lib/thaliMobileNativeTestUtils.js", "diff": "@@ -331,9 +331,10 @@ function getSamePeerWithRetry(path, pskIdentity, pskKey,\nconnectToPeer(peer)\n.then(function (connection) {\n- // When we establish multi connect connections, run test.\n- peerID = peer.peerIdentifier;\nstatus = connectStatus.CONNECTED;\n+ // When running on iOS, change peerID to the one we connected with\n+ peerID = peer.peerIdentifier;\n+ // When we establish multi connect connections, run test.\ncallTryAgain(connection.listeningPort);\n})\n.catch(function (error) {\n@@ -354,6 +355,10 @@ function getSamePeerWithRetry(path, pskIdentity, pskKey,\navailablePeers.push(peer);\n+ if (!peerID) {\n+ peerID = peer.peerIdentifier;\n+ }\n+\nlogger.debug('We got a peer ' + JSON.stringify(peer));\nif (status === connectStatus.NOT_CONNECTED && availablePeers.length > 0) {\n" } ]
JavaScript
MIT License
thaliproject/thali_cordovaplugin
Fix dekstop tests