From 5156b03b0d04caae6dda642e0a152d43771a76a7 Mon Sep 17 00:00:00 2001 From: Hadas Zeilberger Date: Wed, 10 Oct 2018 13:15:00 -0400 Subject: [PATCH 01/56] this is a mock for doc purposes --- src/utils/meat-grinder.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 src/utils/meat-grinder.js diff --git a/src/utils/meat-grinder.js b/src/utils/meat-grinder.js new file mode 100644 index 0000000..df17c91 --- /dev/null +++ b/src/utils/meat-grinder.js @@ -0,0 +1,20 @@ +//arguments: file - plaintext file +//return value:encrypted file +function encryptWtihAes(plainTextFile) {} +//arguments: encrypted file +//return value: array of (x,y) coordinates +function encryptWithShamirs(encryptedFile) {} +//arguments:array points needed to reconstruct encryptedFile +//return value: array of new (x,y) coordinates +function hashPointsWithPrivateKey(arrayOfPoints) {} +//argument: array of (x,y) coordinates +//return value: Promise that resolves to an array of IPFS Hashe's +async function submitPointsToIPFS(points) {} + +async function saveToVault(plainTextFile) { + let points = hashPointsWithPrivateKey( + encryptWithShamirs(encryptWithAes(plainTextFile)) + ); + let ipfsHashes = await submitPointsToIPFS(points); + return ipfsHashes; +} From a135e8bcb46a2293b649ef325dd53f76fac5eda6 Mon Sep 17 00:00:00 2001 From: Hadas Zeilberger Date: Fri, 12 Oct 2018 17:14:42 -0400 Subject: [PATCH 02/56] implemented aes function --- package.json | 2 ++ src/utils/meat-grinder.js | 14 +++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index e670f46..0bc1120 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,8 @@ "prettier": "prettier \"**/*.{js,json,css,md}\" --write" }, "dependencies": { + "@trackforce/react-native-aes-crypto": "^1.2.3", + "bitcore-mnemonic-react-native": "^1.2.4", "react": "16.5.0", "react-native": "0.57.2", "react-native-dotenv": "^0.2.0", diff --git a/src/utils/meat-grinder.js b/src/utils/meat-grinder.js index df17c91..900f014 100644 --- a/src/utils/meat-grinder.js +++ b/src/utils/meat-grinder.js @@ -1,8 +1,19 @@ +import Aes from '@trackforce/react-native-aes-crypto'; //arguments: file - plaintext file //return value:encrypted file -function encryptWtihAes(plainTextFile) {} +export async function encryptWithAes(privateKey, plainTextFile) { + const iv = 'base 64 random 16 bytes string'; + try { + const ciphertext = await Aes.encrypt(plainTextFile, privateKey, iv); + return { ciphertext, iv }; + } catch (error) { + throw error; + } +} + //arguments: encrypted file //return value: array of (x,y) coordinates +/* function encryptWithShamirs(encryptedFile) {} //arguments:array points needed to reconstruct encryptedFile //return value: array of new (x,y) coordinates @@ -18,3 +29,4 @@ async function saveToVault(plainTextFile) { let ipfsHashes = await submitPointsToIPFS(points); return ipfsHashes; } +*/ From bedf211b95d96b7f3b1cb135048ef7e71bf11fbd Mon Sep 17 00:00:00 2001 From: Hadas Zeilberger Date: Tue, 16 Oct 2018 12:09:10 -0400 Subject: [PATCH 03/56] iOS unit tests --- ios/sojournTests/RCTAesTestCase.m | 48 +++++++++++++++++ ios/sojournTests/RCTBridgeTestCase.h | 28 ++++++++++ ios/sojournTests/RCTBridgeTestCase.m | 78 ++++++++++++++++++++++++++++ 3 files changed, 154 insertions(+) create mode 100644 ios/sojournTests/RCTAesTestCase.m create mode 100644 ios/sojournTests/RCTBridgeTestCase.h create mode 100644 ios/sojournTests/RCTBridgeTestCase.m diff --git a/ios/sojournTests/RCTAesTestCase.m b/ios/sojournTests/RCTAesTestCase.m new file mode 100644 index 0000000..eac298e --- /dev/null +++ b/ios/sojournTests/RCTAesTestCase.m @@ -0,0 +1,48 @@ +// +// RCTAesTestCase.m +// sojournTests +// +// Created by Hadas Zeilberger on 10/16/18. +// Copyright © 2018 Facebook. All rights reserved. +// +//aes unit tests +#import +#import +#import "RCTBridgeTestCase.h" +#import +@interface RCTAesTestCase : RCTBridgeTestCase + +@end + +@implementation RCTAesTestCase + + +-(NSString *)moduleName +{ + return @"RCTAesTests"; +} +-(NSArray> *)bridgeModules{ + RCTAes *aes = [RCTAes alloc]; + return @[aes]; +} +- (void)setup { + [super setup]; +} + +- (void)tearDown { + // Put teardown code here. This method is called after the invocation of each test method in the class. +} + +- (void)testExample { + // This is an example of a functional test case. + // Use XCTAssert and related functions to verify your tests produce the correct results. +} + +- (void)testPerformanceExample { + // This is an example of a performance test case. + [self measureBlock:^{ + // Put the code you want to measure the h of here. + }]; +} + +@end diff --git a/ios/sojournTests/RCTBridgeTestCase.h b/ios/sojournTests/RCTBridgeTestCase.h new file mode 100644 index 0000000..303adff --- /dev/null +++ b/ios/sojournTests/RCTBridgeTestCase.h @@ -0,0 +1,28 @@ +// +// RCTBridgeTestCase.h +// sojournTests +// +// Created by Hadas Zeilberger on 10/16/18. +// Copyright © 2018 Facebook. All rights reserved. +// + +#ifndef RCTBridgeTestCase_h +#define RCTBridgeTestCase_h + +#import +#import +#import +#define CURRENT_METHOD _cmd + +@interface RCTBridgeTestCase : XCTestCase + +@property (nonatomic, strong, readonly, nonnull) NSString *moduleName; +@property (nonatomic,strong,readonly,nullable) NSArray> *bridgeModules; +@property (nonatomic, assign, readonly) NSTimeInterval timeout; + +- (void)runTest:(nonnull SEL)selector; +- (void)runTest:(nonnull SEL)selector timeout:(NSTimeInterval)timeout; +- (void) setup; + +@end +#endif /* RCTBridgeTestCase_h */ diff --git a/ios/sojournTests/RCTBridgeTestCase.m b/ios/sojournTests/RCTBridgeTestCase.m new file mode 100644 index 0000000..6975783 --- /dev/null +++ b/ios/sojournTests/RCTBridgeTestCase.m @@ -0,0 +1,78 @@ +// +// RCTBridgeTestCase.m +// sojournTests +// +// Created by Hadas Zeilberger on 10/15/18. +// Copyright © 2018 Facebook. All rights reserved. +// +//entry point for unit tests + +#import "RCTBridgeTestCase.h" +#define CURRENT_METHOD _cmd + + +@implementation RCTBridgeTestCase{ + RCTTestRunner *_runner; +} + +- (void)setUp { + [super setUp]; + //load the component that contains all tests - nativetests.js in this case + _runner = RCTInitRunnerForApp(@"nativetests",[self moduleProvider],@"http://localhost:8080"); + _runner.recordMode = NO;<#(nonnull NSString *)#> + // Put setup code here. This method is called before the invocation of each test method in the class. +} + +- (NSArray> *(^)(void))moduleProvider +{ + NSArray *bridges = self.bridgeModules; + + if (bridges && bridges.count > 0) { + return ^() { + return bridges; + }; + } + + return nil; +} + +- (void)runTest:(SEL)selector +{ + [self runTest:selector timeout:self.timeout]; +} + +- (void)runTest:(SEL)selector timeout:(NSTimeInterval)timeout +{ + NSString *name = self.moduleName; + if (name) { + NSDictionary *dict = @{ + @"testName": NSStringFromSelector(selector), + @"testTimeout": @(timeout) + }; + + [_runner runTest:_cmd module:name initialProps:dict configurationBlock:nil]; + } + else { + @throw [NSException exceptionWithName:@"exception" + reason:@"missing module" + userInfo:nil]; + } +} + +- (void)tearDown { + // Put teardown code here. This method is called after the invocation of each test method in the class. +} + +- (void)testExample { + // This is an example of a functional test case. + // Use XCTAssert and related functions to verify your tests produce the correct results. +} + +- (void)testPerformanceExample { + // This is an example of a performance test case. + [self measureBlock:^{ + // Put the code you want to measure the time of here. + }]; +} + +@end From b2397e666b6e326ef353580c7c761b09937b1c33 Mon Sep 17 00:00:00 2001 From: Hadas Zeilberger Date: Wed, 17 Oct 2018 15:33:34 -0400 Subject: [PATCH 04/56] detox setup --- e2e/config.json | 4 ++++ e2e/firstTest.spec.js | 19 +++++++++++++++++++ e2e/init.js | 19 +++++++++++++++++++ package.json | 12 ++++++++++++ src/App.js | 2 +- 5 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 e2e/config.json create mode 100644 e2e/firstTest.spec.js create mode 100644 e2e/init.js diff --git a/e2e/config.json b/e2e/config.json new file mode 100644 index 0000000..cb0de04 --- /dev/null +++ b/e2e/config.json @@ -0,0 +1,4 @@ +{ + "setupTestFrameworkScriptFile": "./init.js", + "testEnvironment": "node" +} diff --git a/e2e/firstTest.spec.js b/e2e/firstTest.spec.js new file mode 100644 index 0000000..240987d --- /dev/null +++ b/e2e/firstTest.spec.js @@ -0,0 +1,19 @@ +describe('Example', () => { + beforeEach(async () => { + await device.reloadReactNative(); + }); + + it('should have welcome screen', async () => { + await expect(element(by.id('welcome'))).toBeVisible(); + }); + /* it('should show hello screen after tap', async () => { + await element(by.id('hello_button')).tap(); + await expect(element(by.text('Hello!!!'))).toBeVisible(); + }); + + it('should show world screen after tap', async () => { + await element(by.id('world_button')).tap(); + await expect(element(by.text('World!!!'))).toBeVisible(); + }); +*/ +}); diff --git a/e2e/init.js b/e2e/init.js new file mode 100644 index 0000000..38c13e3 --- /dev/null +++ b/e2e/init.js @@ -0,0 +1,19 @@ +const detox = require('detox'); +const config = require('../package.json').detox; +const adapter = require('detox/runners/jest/adapter'); + +jest.setTimeout(120000); +jasmine.getEnv().addReporter(adapter); + +beforeAll(async () => { + await detox.init(config); +}); + +beforeEach(async () => { + await adapter.beforeEach(); +}); + +afterAll(async () => { + await adapter.afterAll(); + await detox.cleanup(); +}); diff --git a/package.json b/package.json index 0bc1120..82e64b4 100644 --- a/package.json +++ b/package.json @@ -23,6 +23,7 @@ "babel-core": "7.0.0-bridge.0", "babel-eslint": "^10.0.1", "babel-jest": "^23.6.0", + "detox": "^9.0.4", "eslint": "^5.6.1", "eslint-config-prettier": "^3.1.0", "eslint-plugin-prettier": "^3.0.0", @@ -48,5 +49,16 @@ "hooks": { "pre-commit": "pretty-quick --staged" } + }, + "detox": { + "configurations": { + "ios.sim.debug": { + "binaryPath": "ios/build/Build/Products/Debug-iphonesimulator/sojourn.app", + "build": "xcodebuild -project ios/sojourn.xcodeproj -scheme sojourn -configuration Debug -sdk iphonesimulator -derivedDataPath ios/build", + "type": "ios.simulator", + "name": "iPhone XS" + } + }, + "test-runner": "jest" } } diff --git a/src/App.js b/src/App.js index 1aff6c4..44cd679 100644 --- a/src/App.js +++ b/src/App.js @@ -31,7 +31,7 @@ export default class App extends Component { render() { return ( - + Welcome to React Native! To get started, edit App.js {instructions} From b2800365a98ccd3f82b9592b76693fa8161f1d86 Mon Sep 17 00:00:00 2001 From: Hadas Zeilberger Date: Fri, 19 Oct 2018 10:09:17 -0400 Subject: [PATCH 05/56] test app for detox --- index.debug.js | 5 +++++ index.test.js | 4 ++++ package.json | 12 +++++++++--- src/RCTAesTests.js | 22 ++++++++++++++++++++++ 4 files changed, 40 insertions(+), 3 deletions(-) create mode 100644 index.debug.js create mode 100644 index.test.js create mode 100644 src/RCTAesTests.js diff --git a/index.debug.js b/index.debug.js new file mode 100644 index 0000000..8819056 --- /dev/null +++ b/index.debug.js @@ -0,0 +1,5 @@ +/** @format */ +import { AppRegistry } from 'react-native'; +import App from './src/App'; +import { name as appName } from './app.json'; +AppRegistry.registerComponent(appName, () => App); diff --git a/index.test.js b/index.test.js new file mode 100644 index 0000000..06a9062 --- /dev/null +++ b/index.test.js @@ -0,0 +1,4 @@ +import { AppRegistry } from 'react-native'; +import { name as appName } from './app.json'; +import RCTAesTests from './e2e/TestApp/RCTAesTests'; +AppRegistry.registerComponent(appName, () => RCTAesTests); diff --git a/package.json b/package.json index 82e64b4..cfe9755 100644 --- a/package.json +++ b/package.json @@ -12,11 +12,15 @@ }, "dependencies": { "@trackforce/react-native-aes-crypto": "^1.2.3", + "big-integer": "^1.6.5", "bitcore-mnemonic-react-native": "^1.2.4", + "get-random-values": "^1.1.1", + "global": "^4.3.0", "react": "16.5.0", "react-native": "0.57.2", "react-native-dotenv": "^0.2.0", - "react-native-uport-connect": "git+https://github.com/barlock/react-native-uport-connect.git#support-babel-7" + "react-native-uport-connect": "git+https://github.com/barlock/react-native-uport-connect.git#support-babel-7", + "utf-8": "^1.0.0" }, "devDependencies": { "@babel/runtime": "^7.1.2", @@ -34,7 +38,9 @@ "metro-react-native-babel-preset": "^0.48.0", "prettier": "^1.14.3", "pretty-quick": "^1.7.0", - "react-test-renderer": "16.5.0" + "react-test-renderer": "16.5.0", + "browserify": "^12.0.1", + "uglify-js": "^2.6.0" }, "resolutions": { "babel-core": "7.0.0-bridge.0" @@ -54,7 +60,7 @@ "configurations": { "ios.sim.debug": { "binaryPath": "ios/build/Build/Products/Debug-iphonesimulator/sojourn.app", - "build": "xcodebuild -project ios/sojourn.xcodeproj -scheme sojourn -configuration Debug -sdk iphonesimulator -derivedDataPath ios/build", + "build": "cp index.test.js index.js && xcodebuild -project ios/sojourn.xcodeproj -configuration Debug -scheme sojourn -destination id=AC488766-22CC-4F2F-AEE5-F699F8D3BE7A -derivedDataPath ios/build", "type": "ios.simulator", "name": "iPhone XS" } diff --git a/src/RCTAesTests.js b/src/RCTAesTests.js new file mode 100644 index 0000000..bdffd16 --- /dev/null +++ b/src/RCTAesTests.js @@ -0,0 +1,22 @@ +import React, { Component } from 'react'; +import { encryptWithAes } from '../utils/meat-grinder.js'; +import { View } from 'react-native'; +const testPrivateKey = + '8238BAE35C77FE4AEBB2DEB1B83A6F0027A01D0E4D93BF5B81F7117796955A17'; +export default class RCTAesTests extends Component { + async testAesEncryption() { + let aesOutput = await encryptWithAes( + testPrivateKey, + 'ffffffffffffffffffffffffffffffffffffffffffffffffffff' + ); + if (!aesOutput) { + throw Error('output is not good'); + } + console.warn(aesOutput); + return 'success'; + } + render() { + this.testAesEncryption(); + return ; + } +} From 487a645dc29f62a6898f0cd3751d2a7c97c57040 Mon Sep 17 00:00:00 2001 From: Hadas Zeilberger Date: Fri, 19 Oct 2018 13:31:32 -0400 Subject: [PATCH 06/56] m --- .../AppIcon.appiconset/Contents.json | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/ios/sojourn/Images.xcassets/AppIcon.appiconset/Contents.json b/ios/sojourn/Images.xcassets/AppIcon.appiconset/Contents.json index 48e64ae..d25ce24 100644 --- a/ios/sojourn/Images.xcassets/AppIcon.appiconset/Contents.json +++ b/ios/sojourn/Images.xcassets/AppIcon.appiconset/Contents.json @@ -1,5 +1,15 @@ { "images": [ + { + "idiom": "iphone", + "size": "20x20", + "scale": "2x" + }, + { + "idiom": "iphone", + "size": "20x20", + "scale": "3x" + }, { "idiom": "iphone", "size": "29x29", @@ -29,6 +39,11 @@ "idiom": "iphone", "size": "60x60", "scale": "3x" + }, + { + "idiom": "ios-marketing", + "size": "1024x1024", + "scale": "1x" } ], "info": { From 7a943755fa4a44aae93f012b957f942a6158394f Mon Sep 17 00:00:00 2001 From: Hadas Zeilberger Date: Sat, 20 Oct 2018 14:36:06 -0400 Subject: [PATCH 07/56] reset index.js in cleanup of detox tests --- e2e/init.js | 4 +++- index.test.js | 2 +- package.json | 5 +++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/e2e/init.js b/e2e/init.js index 38c13e3..ab0e6ef 100644 --- a/e2e/init.js +++ b/e2e/init.js @@ -1,7 +1,7 @@ const detox = require('detox'); const config = require('../package.json').detox; const adapter = require('detox/runners/jest/adapter'); - +const { exec } = require('child_process'); jest.setTimeout(120000); jasmine.getEnv().addReporter(adapter); @@ -15,5 +15,7 @@ beforeEach(async () => { afterAll(async () => { await adapter.afterAll(); + console.log('cleaning up'); + exec('cp ../index.debug.js index.js'); await detox.cleanup(); }); diff --git a/index.test.js b/index.test.js index 06a9062..4443fe4 100644 --- a/index.test.js +++ b/index.test.js @@ -1,4 +1,4 @@ import { AppRegistry } from 'react-native'; import { name as appName } from './app.json'; -import RCTAesTests from './e2e/TestApp/RCTAesTests'; +import RCTAesTests from './src/RCTAesTests'; AppRegistry.registerComponent(appName, () => RCTAesTests); diff --git a/package.json b/package.json index cfe9755..48181fa 100644 --- a/package.json +++ b/package.json @@ -4,11 +4,12 @@ "private": true, "scripts": { "start": "react-native start", - "ios": "react-native run-ios", + "ios": "cp index.debug.js index.js && react-native run-ios", "lint": "eslint .", "jest": "jest", "test": "npm run lint && npm run jest", - "prettier": "prettier \"**/*.{js,json,css,md}\" --write" + "prettier": "prettier \"**/*.{js,json,css,md}\" --write", + "postinstall": "react-native link" }, "dependencies": { "@trackforce/react-native-aes-crypto": "^1.2.3", From 2bd464cf671cda633754fc9d5b82cea1e2e5e880 Mon Sep 17 00:00:00 2001 From: Hadas Zeilberger Date: Sat, 20 Oct 2018 14:38:17 -0400 Subject: [PATCH 08/56] including e2e test notes in readme --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 74ce49c..0c42f73 100644 --- a/README.md +++ b/README.md @@ -12,3 +12,9 @@ UPORT_APP_NAME=Sojourn UPORT_APP_ADDRESS=2onKAS55Vs9hGwDPsBT6DYHwAP1HJ3FsBXh UPORT_PRIVATE_KEY= ``` + +# Testing + +### End to End Tests + +Run `detox build` followed by `detox test` for end to end tests From bf9f553aec9d64887d4a9d8c96900a663ce11a96 Mon Sep 17 00:00:00 2001 From: Hadas Zeilberger Date: Sat, 20 Oct 2018 14:47:53 -0400 Subject: [PATCH 09/56] make iv proper length, delete unused files --- ios/sojournTests/RCTAesTestCase.m | 48 ----------------- ios/sojournTests/RCTBridgeTestCase.h | 28 ---------- ios/sojournTests/RCTBridgeTestCase.m | 78 ---------------------------- src/utils/meat-grinder.js | 2 +- 4 files changed, 1 insertion(+), 155 deletions(-) delete mode 100644 ios/sojournTests/RCTAesTestCase.m delete mode 100644 ios/sojournTests/RCTBridgeTestCase.h delete mode 100644 ios/sojournTests/RCTBridgeTestCase.m diff --git a/ios/sojournTests/RCTAesTestCase.m b/ios/sojournTests/RCTAesTestCase.m deleted file mode 100644 index eac298e..0000000 --- a/ios/sojournTests/RCTAesTestCase.m +++ /dev/null @@ -1,48 +0,0 @@ -// -// RCTAesTestCase.m -// sojournTests -// -// Created by Hadas Zeilberger on 10/16/18. -// Copyright © 2018 Facebook. All rights reserved. -// -//aes unit tests -#import -#import -#import "RCTBridgeTestCase.h" -#import -@interface RCTAesTestCase : RCTBridgeTestCase - -@end - -@implementation RCTAesTestCase - - --(NSString *)moduleName -{ - return @"RCTAesTests"; -} --(NSArray> *)bridgeModules{ - RCTAes *aes = [RCTAes alloc]; - return @[aes]; -} -- (void)setup { - [super setup]; -} - -- (void)tearDown { - // Put teardown code here. This method is called after the invocation of each test method in the class. -} - -- (void)testExample { - // This is an example of a functional test case. - // Use XCTAssert and related functions to verify your tests produce the correct results. -} - -- (void)testPerformanceExample { - // This is an example of a performance test case. - [self measureBlock:^{ - // Put the code you want to measure the h of here. - }]; -} - -@end diff --git a/ios/sojournTests/RCTBridgeTestCase.h b/ios/sojournTests/RCTBridgeTestCase.h deleted file mode 100644 index 303adff..0000000 --- a/ios/sojournTests/RCTBridgeTestCase.h +++ /dev/null @@ -1,28 +0,0 @@ -// -// RCTBridgeTestCase.h -// sojournTests -// -// Created by Hadas Zeilberger on 10/16/18. -// Copyright © 2018 Facebook. All rights reserved. -// - -#ifndef RCTBridgeTestCase_h -#define RCTBridgeTestCase_h - -#import -#import -#import -#define CURRENT_METHOD _cmd - -@interface RCTBridgeTestCase : XCTestCase - -@property (nonatomic, strong, readonly, nonnull) NSString *moduleName; -@property (nonatomic,strong,readonly,nullable) NSArray> *bridgeModules; -@property (nonatomic, assign, readonly) NSTimeInterval timeout; - -- (void)runTest:(nonnull SEL)selector; -- (void)runTest:(nonnull SEL)selector timeout:(NSTimeInterval)timeout; -- (void) setup; - -@end -#endif /* RCTBridgeTestCase_h */ diff --git a/ios/sojournTests/RCTBridgeTestCase.m b/ios/sojournTests/RCTBridgeTestCase.m deleted file mode 100644 index 6975783..0000000 --- a/ios/sojournTests/RCTBridgeTestCase.m +++ /dev/null @@ -1,78 +0,0 @@ -// -// RCTBridgeTestCase.m -// sojournTests -// -// Created by Hadas Zeilberger on 10/15/18. -// Copyright © 2018 Facebook. All rights reserved. -// -//entry point for unit tests - -#import "RCTBridgeTestCase.h" -#define CURRENT_METHOD _cmd - - -@implementation RCTBridgeTestCase{ - RCTTestRunner *_runner; -} - -- (void)setUp { - [super setUp]; - //load the component that contains all tests - nativetests.js in this case - _runner = RCTInitRunnerForApp(@"nativetests",[self moduleProvider],@"http://localhost:8080"); - _runner.recordMode = NO;<#(nonnull NSString *)#> - // Put setup code here. This method is called before the invocation of each test method in the class. -} - -- (NSArray> *(^)(void))moduleProvider -{ - NSArray *bridges = self.bridgeModules; - - if (bridges && bridges.count > 0) { - return ^() { - return bridges; - }; - } - - return nil; -} - -- (void)runTest:(SEL)selector -{ - [self runTest:selector timeout:self.timeout]; -} - -- (void)runTest:(SEL)selector timeout:(NSTimeInterval)timeout -{ - NSString *name = self.moduleName; - if (name) { - NSDictionary *dict = @{ - @"testName": NSStringFromSelector(selector), - @"testTimeout": @(timeout) - }; - - [_runner runTest:_cmd module:name initialProps:dict configurationBlock:nil]; - } - else { - @throw [NSException exceptionWithName:@"exception" - reason:@"missing module" - userInfo:nil]; - } -} - -- (void)tearDown { - // Put teardown code here. This method is called after the invocation of each test method in the class. -} - -- (void)testExample { - // This is an example of a functional test case. - // Use XCTAssert and related functions to verify your tests produce the correct results. -} - -- (void)testPerformanceExample { - // This is an example of a performance test case. - [self measureBlock:^{ - // Put the code you want to measure the time of here. - }]; -} - -@end diff --git a/src/utils/meat-grinder.js b/src/utils/meat-grinder.js index 900f014..9062c48 100644 --- a/src/utils/meat-grinder.js +++ b/src/utils/meat-grinder.js @@ -2,7 +2,7 @@ import Aes from '@trackforce/react-native-aes-crypto'; //arguments: file - plaintext file //return value:encrypted file export async function encryptWithAes(privateKey, plainTextFile) { - const iv = 'base 64 random 16 bytes string'; + const iv = 'sixteen bytes iv'; //To DO: randomly generate try { const ciphertext = await Aes.encrypt(plainTextFile, privateKey, iv); return { ciphertext, iv }; From 03f3358a835fff849484e8d8e6b0c9c508b677da Mon Sep 17 00:00:00 2001 From: Hadas Zeilberger Date: Wed, 10 Oct 2018 13:15:00 -0400 Subject: [PATCH 10/56] this is a mock for doc purposes --- src/utils/meat-grinder.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 src/utils/meat-grinder.js diff --git a/src/utils/meat-grinder.js b/src/utils/meat-grinder.js new file mode 100644 index 0000000..df17c91 --- /dev/null +++ b/src/utils/meat-grinder.js @@ -0,0 +1,20 @@ +//arguments: file - plaintext file +//return value:encrypted file +function encryptWtihAes(plainTextFile) {} +//arguments: encrypted file +//return value: array of (x,y) coordinates +function encryptWithShamirs(encryptedFile) {} +//arguments:array points needed to reconstruct encryptedFile +//return value: array of new (x,y) coordinates +function hashPointsWithPrivateKey(arrayOfPoints) {} +//argument: array of (x,y) coordinates +//return value: Promise that resolves to an array of IPFS Hashe's +async function submitPointsToIPFS(points) {} + +async function saveToVault(plainTextFile) { + let points = hashPointsWithPrivateKey( + encryptWithShamirs(encryptWithAes(plainTextFile)) + ); + let ipfsHashes = await submitPointsToIPFS(points); + return ipfsHashes; +} From 0cdca4ee9fef2bfb8c98ace42e4133997870ca02 Mon Sep 17 00:00:00 2001 From: Hadas Zeilberger Date: Fri, 12 Oct 2018 17:14:42 -0400 Subject: [PATCH 11/56] implemented aes function --- package.json | 2 ++ src/utils/meat-grinder.js | 14 +++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index f91ce6e..18be688 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,8 @@ "drizzle-react": "^1.2.0", "eth-block-tracker": "^4.0.3", "node-libs-react-native": "^1.0.3", + "@trackforce/react-native-aes-crypto": "^1.2.3", + "bitcore-mnemonic-react-native": "^1.2.4", "react": "16.5.0", "react-native": "0.57.2", "react-native-dotenv": "^0.2.0", diff --git a/src/utils/meat-grinder.js b/src/utils/meat-grinder.js index df17c91..900f014 100644 --- a/src/utils/meat-grinder.js +++ b/src/utils/meat-grinder.js @@ -1,8 +1,19 @@ +import Aes from '@trackforce/react-native-aes-crypto'; //arguments: file - plaintext file //return value:encrypted file -function encryptWtihAes(plainTextFile) {} +export async function encryptWithAes(privateKey, plainTextFile) { + const iv = 'base 64 random 16 bytes string'; + try { + const ciphertext = await Aes.encrypt(plainTextFile, privateKey, iv); + return { ciphertext, iv }; + } catch (error) { + throw error; + } +} + //arguments: encrypted file //return value: array of (x,y) coordinates +/* function encryptWithShamirs(encryptedFile) {} //arguments:array points needed to reconstruct encryptedFile //return value: array of new (x,y) coordinates @@ -18,3 +29,4 @@ async function saveToVault(plainTextFile) { let ipfsHashes = await submitPointsToIPFS(points); return ipfsHashes; } +*/ From 91508b8b6aa765a306439cf4d45635593d36eac3 Mon Sep 17 00:00:00 2001 From: Hadas Zeilberger Date: Tue, 16 Oct 2018 12:09:10 -0400 Subject: [PATCH 12/56] iOS unit tests --- ios/sojournTests/RCTAesTestCase.m | 48 +++++++++++++++++ ios/sojournTests/RCTBridgeTestCase.h | 28 ++++++++++ ios/sojournTests/RCTBridgeTestCase.m | 78 ++++++++++++++++++++++++++++ 3 files changed, 154 insertions(+) create mode 100644 ios/sojournTests/RCTAesTestCase.m create mode 100644 ios/sojournTests/RCTBridgeTestCase.h create mode 100644 ios/sojournTests/RCTBridgeTestCase.m diff --git a/ios/sojournTests/RCTAesTestCase.m b/ios/sojournTests/RCTAesTestCase.m new file mode 100644 index 0000000..eac298e --- /dev/null +++ b/ios/sojournTests/RCTAesTestCase.m @@ -0,0 +1,48 @@ +// +// RCTAesTestCase.m +// sojournTests +// +// Created by Hadas Zeilberger on 10/16/18. +// Copyright © 2018 Facebook. All rights reserved. +// +//aes unit tests +#import +#import +#import "RCTBridgeTestCase.h" +#import +@interface RCTAesTestCase : RCTBridgeTestCase + +@end + +@implementation RCTAesTestCase + + +-(NSString *)moduleName +{ + return @"RCTAesTests"; +} +-(NSArray> *)bridgeModules{ + RCTAes *aes = [RCTAes alloc]; + return @[aes]; +} +- (void)setup { + [super setup]; +} + +- (void)tearDown { + // Put teardown code here. This method is called after the invocation of each test method in the class. +} + +- (void)testExample { + // This is an example of a functional test case. + // Use XCTAssert and related functions to verify your tests produce the correct results. +} + +- (void)testPerformanceExample { + // This is an example of a performance test case. + [self measureBlock:^{ + // Put the code you want to measure the h of here. + }]; +} + +@end diff --git a/ios/sojournTests/RCTBridgeTestCase.h b/ios/sojournTests/RCTBridgeTestCase.h new file mode 100644 index 0000000..303adff --- /dev/null +++ b/ios/sojournTests/RCTBridgeTestCase.h @@ -0,0 +1,28 @@ +// +// RCTBridgeTestCase.h +// sojournTests +// +// Created by Hadas Zeilberger on 10/16/18. +// Copyright © 2018 Facebook. All rights reserved. +// + +#ifndef RCTBridgeTestCase_h +#define RCTBridgeTestCase_h + +#import +#import +#import +#define CURRENT_METHOD _cmd + +@interface RCTBridgeTestCase : XCTestCase + +@property (nonatomic, strong, readonly, nonnull) NSString *moduleName; +@property (nonatomic,strong,readonly,nullable) NSArray> *bridgeModules; +@property (nonatomic, assign, readonly) NSTimeInterval timeout; + +- (void)runTest:(nonnull SEL)selector; +- (void)runTest:(nonnull SEL)selector timeout:(NSTimeInterval)timeout; +- (void) setup; + +@end +#endif /* RCTBridgeTestCase_h */ diff --git a/ios/sojournTests/RCTBridgeTestCase.m b/ios/sojournTests/RCTBridgeTestCase.m new file mode 100644 index 0000000..6975783 --- /dev/null +++ b/ios/sojournTests/RCTBridgeTestCase.m @@ -0,0 +1,78 @@ +// +// RCTBridgeTestCase.m +// sojournTests +// +// Created by Hadas Zeilberger on 10/15/18. +// Copyright © 2018 Facebook. All rights reserved. +// +//entry point for unit tests + +#import "RCTBridgeTestCase.h" +#define CURRENT_METHOD _cmd + + +@implementation RCTBridgeTestCase{ + RCTTestRunner *_runner; +} + +- (void)setUp { + [super setUp]; + //load the component that contains all tests - nativetests.js in this case + _runner = RCTInitRunnerForApp(@"nativetests",[self moduleProvider],@"http://localhost:8080"); + _runner.recordMode = NO;<#(nonnull NSString *)#> + // Put setup code here. This method is called before the invocation of each test method in the class. +} + +- (NSArray> *(^)(void))moduleProvider +{ + NSArray *bridges = self.bridgeModules; + + if (bridges && bridges.count > 0) { + return ^() { + return bridges; + }; + } + + return nil; +} + +- (void)runTest:(SEL)selector +{ + [self runTest:selector timeout:self.timeout]; +} + +- (void)runTest:(SEL)selector timeout:(NSTimeInterval)timeout +{ + NSString *name = self.moduleName; + if (name) { + NSDictionary *dict = @{ + @"testName": NSStringFromSelector(selector), + @"testTimeout": @(timeout) + }; + + [_runner runTest:_cmd module:name initialProps:dict configurationBlock:nil]; + } + else { + @throw [NSException exceptionWithName:@"exception" + reason:@"missing module" + userInfo:nil]; + } +} + +- (void)tearDown { + // Put teardown code here. This method is called after the invocation of each test method in the class. +} + +- (void)testExample { + // This is an example of a functional test case. + // Use XCTAssert and related functions to verify your tests produce the correct results. +} + +- (void)testPerformanceExample { + // This is an example of a performance test case. + [self measureBlock:^{ + // Put the code you want to measure the time of here. + }]; +} + +@end From 39919c7e0f7b97e7b77a454bb4a8f9b8793e42c4 Mon Sep 17 00:00:00 2001 From: Hadas Zeilberger Date: Wed, 17 Oct 2018 15:33:34 -0400 Subject: [PATCH 13/56] detox setup --- e2e/config.json | 4 ++++ e2e/firstTest.spec.js | 19 +++++++++++++++++++ e2e/init.js | 19 +++++++++++++++++++ package.json | 12 ++++++++++++ 4 files changed, 54 insertions(+) create mode 100644 e2e/config.json create mode 100644 e2e/firstTest.spec.js create mode 100644 e2e/init.js diff --git a/e2e/config.json b/e2e/config.json new file mode 100644 index 0000000..cb0de04 --- /dev/null +++ b/e2e/config.json @@ -0,0 +1,4 @@ +{ + "setupTestFrameworkScriptFile": "./init.js", + "testEnvironment": "node" +} diff --git a/e2e/firstTest.spec.js b/e2e/firstTest.spec.js new file mode 100644 index 0000000..240987d --- /dev/null +++ b/e2e/firstTest.spec.js @@ -0,0 +1,19 @@ +describe('Example', () => { + beforeEach(async () => { + await device.reloadReactNative(); + }); + + it('should have welcome screen', async () => { + await expect(element(by.id('welcome'))).toBeVisible(); + }); + /* it('should show hello screen after tap', async () => { + await element(by.id('hello_button')).tap(); + await expect(element(by.text('Hello!!!'))).toBeVisible(); + }); + + it('should show world screen after tap', async () => { + await element(by.id('world_button')).tap(); + await expect(element(by.text('World!!!'))).toBeVisible(); + }); +*/ +}); diff --git a/e2e/init.js b/e2e/init.js new file mode 100644 index 0000000..38c13e3 --- /dev/null +++ b/e2e/init.js @@ -0,0 +1,19 @@ +const detox = require('detox'); +const config = require('../package.json').detox; +const adapter = require('detox/runners/jest/adapter'); + +jest.setTimeout(120000); +jasmine.getEnv().addReporter(adapter); + +beforeAll(async () => { + await detox.init(config); +}); + +beforeEach(async () => { + await adapter.beforeEach(); +}); + +afterAll(async () => { + await adapter.afterAll(); + await detox.cleanup(); +}); diff --git a/package.json b/package.json index 18be688..2ed2e61 100644 --- a/package.json +++ b/package.json @@ -38,6 +38,7 @@ "babel-eslint": "^10.0.1", "babel-jest": "^23.6.0", "concurrently": "^4.0.1", + "detox": "^9.0.4", "eslint": "^5.6.1", "eslint-config-prettier": "^3.1.0", "eslint-plugin-prettier": "^3.0.0", @@ -62,5 +63,16 @@ "hooks": { "pre-commit": "pretty-quick --staged" } + }, + "detox": { + "configurations": { + "ios.sim.debug": { + "binaryPath": "ios/build/Build/Products/Debug-iphonesimulator/sojourn.app", + "build": "xcodebuild -project ios/sojourn.xcodeproj -scheme sojourn -configuration Debug -sdk iphonesimulator -derivedDataPath ios/build", + "type": "ios.simulator", + "name": "iPhone XS" + } + }, + "test-runner": "jest" } } From d0402c03b174fa4bfdad273b8befc84170c5e494 Mon Sep 17 00:00:00 2001 From: Hadas Zeilberger Date: Fri, 19 Oct 2018 10:09:17 -0400 Subject: [PATCH 14/56] test app for detox --- index.debug.js | 5 +++++ index.test.js | 4 ++++ package.json | 13 ++++++++++++- src/RCTAesTests.js | 22 ++++++++++++++++++++++ 4 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 index.debug.js create mode 100644 index.test.js create mode 100644 src/RCTAesTests.js diff --git a/index.debug.js b/index.debug.js new file mode 100644 index 0000000..8819056 --- /dev/null +++ b/index.debug.js @@ -0,0 +1,5 @@ +/** @format */ +import { AppRegistry } from 'react-native'; +import App from './src/App'; +import { name as appName } from './app.json'; +AppRegistry.registerComponent(appName, () => App); diff --git a/index.test.js b/index.test.js new file mode 100644 index 0000000..06a9062 --- /dev/null +++ b/index.test.js @@ -0,0 +1,4 @@ +import { AppRegistry } from 'react-native'; +import { name as appName } from './app.json'; +import RCTAesTests from './e2e/TestApp/RCTAesTests'; +AppRegistry.registerComponent(appName, () => RCTAesTests); diff --git a/package.json b/package.json index 2ed2e61..3343174 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,10 @@ "eth-block-tracker": "^4.0.3", "node-libs-react-native": "^1.0.3", "@trackforce/react-native-aes-crypto": "^1.2.3", + "big-integer": "^1.6.5", "bitcore-mnemonic-react-native": "^1.2.4", + "get-random-values": "^1.1.1", + "global": "^4.3.0", "react": "16.5.0", "react-native": "0.57.2", "react-native-dotenv": "^0.2.0", @@ -30,6 +33,8 @@ "react-redux": "^5.0.7", "redux": "^4.0.1", "whatwg-url": "^7.0.0" + "react-native-uport-connect": "git+https://github.com/barlock/react-native-uport-connect.git#support-babel-7", + "utf-8": "^1.0.0" }, "devDependencies": { "@babel/core": "^7.1.2", @@ -51,10 +56,16 @@ "metro-react-native-babel-preset": "^0.48.0", "prettier": "^1.14.3", "pretty-quick": "^1.7.0", +<<<<<<< HEAD "prop-types": "^15.6.2", "react-test-renderer": "16.5.0", "truffle": "^5.0.0-next.12", "web3-fake-provider": "^0.1.0" +======= + "react-test-renderer": "16.5.0", + "browserify": "^12.0.1", + "uglify-js": "^2.6.0" +>>>>>>> test app for detox }, "resolutions": { "babel-core": "7.0.0-bridge.0" @@ -68,7 +79,7 @@ "configurations": { "ios.sim.debug": { "binaryPath": "ios/build/Build/Products/Debug-iphonesimulator/sojourn.app", - "build": "xcodebuild -project ios/sojourn.xcodeproj -scheme sojourn -configuration Debug -sdk iphonesimulator -derivedDataPath ios/build", + "build": "cp index.test.js index.js && xcodebuild -project ios/sojourn.xcodeproj -configuration Debug -scheme sojourn -destination id=AC488766-22CC-4F2F-AEE5-F699F8D3BE7A -derivedDataPath ios/build", "type": "ios.simulator", "name": "iPhone XS" } diff --git a/src/RCTAesTests.js b/src/RCTAesTests.js new file mode 100644 index 0000000..bdffd16 --- /dev/null +++ b/src/RCTAesTests.js @@ -0,0 +1,22 @@ +import React, { Component } from 'react'; +import { encryptWithAes } from '../utils/meat-grinder.js'; +import { View } from 'react-native'; +const testPrivateKey = + '8238BAE35C77FE4AEBB2DEB1B83A6F0027A01D0E4D93BF5B81F7117796955A17'; +export default class RCTAesTests extends Component { + async testAesEncryption() { + let aesOutput = await encryptWithAes( + testPrivateKey, + 'ffffffffffffffffffffffffffffffffffffffffffffffffffff' + ); + if (!aesOutput) { + throw Error('output is not good'); + } + console.warn(aesOutput); + return 'success'; + } + render() { + this.testAesEncryption(); + return ; + } +} From 81aed5ba43ae68f7c0cea5e06751f285bed24fdb Mon Sep 17 00:00:00 2001 From: Hadas Zeilberger Date: Sat, 20 Oct 2018 14:36:06 -0400 Subject: [PATCH 15/56] reset index.js in cleanup of detox tests --- e2e/init.js | 4 +++- index.test.js | 2 +- package.json | 6 +++--- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/e2e/init.js b/e2e/init.js index 38c13e3..ab0e6ef 100644 --- a/e2e/init.js +++ b/e2e/init.js @@ -1,7 +1,7 @@ const detox = require('detox'); const config = require('../package.json').detox; const adapter = require('detox/runners/jest/adapter'); - +const { exec } = require('child_process'); jest.setTimeout(120000); jasmine.getEnv().addReporter(adapter); @@ -15,5 +15,7 @@ beforeEach(async () => { afterAll(async () => { await adapter.afterAll(); + console.log('cleaning up'); + exec('cp ../index.debug.js index.js'); await detox.cleanup(); }); diff --git a/index.test.js b/index.test.js index 06a9062..4443fe4 100644 --- a/index.test.js +++ b/index.test.js @@ -1,4 +1,4 @@ import { AppRegistry } from 'react-native'; import { name as appName } from './app.json'; -import RCTAesTests from './e2e/TestApp/RCTAesTests'; +import RCTAesTests from './src/RCTAesTests'; AppRegistry.registerComponent(appName, () => RCTAesTests); diff --git a/package.json b/package.json index 3343174..272f9d3 100644 --- a/package.json +++ b/package.json @@ -8,11 +8,14 @@ "start:ganache": "yarn build:truffle && ganache-cli", "build:truffle": "truffle compile", "ios": "react-native run-ios", + "start": "react-native start", + "ios": "cp index.debug.js index.js && react-native run-ios", "lint": "eslint .", "jest": "yarn build:truffle && jest", "test": "npm run lint && npm run jest", "prettier": "prettier \"**/*.{js,json,css,md}\" --write", "postinstall": "node ./scripts/post-install.js" + "postinstall": "react-native link" }, "dependencies": { "@babel/plugin-proposal-class-properties": "^7.1.0", @@ -56,16 +59,13 @@ "metro-react-native-babel-preset": "^0.48.0", "prettier": "^1.14.3", "pretty-quick": "^1.7.0", -<<<<<<< HEAD "prop-types": "^15.6.2", "react-test-renderer": "16.5.0", "truffle": "^5.0.0-next.12", "web3-fake-provider": "^0.1.0" -======= "react-test-renderer": "16.5.0", "browserify": "^12.0.1", "uglify-js": "^2.6.0" ->>>>>>> test app for detox }, "resolutions": { "babel-core": "7.0.0-bridge.0" From 4662b2abdd94838227e71115f6ee7e939ec0c553 Mon Sep 17 00:00:00 2001 From: Hadas Zeilberger Date: Sat, 20 Oct 2018 14:38:17 -0400 Subject: [PATCH 16/56] including e2e test notes in readme --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 74ce49c..0c42f73 100644 --- a/README.md +++ b/README.md @@ -12,3 +12,9 @@ UPORT_APP_NAME=Sojourn UPORT_APP_ADDRESS=2onKAS55Vs9hGwDPsBT6DYHwAP1HJ3FsBXh UPORT_PRIVATE_KEY= ``` + +# Testing + +### End to End Tests + +Run `detox build` followed by `detox test` for end to end tests From cbc5eeca5604241699a33569c55c1d3fed59fb38 Mon Sep 17 00:00:00 2001 From: Hadas Zeilberger Date: Sat, 20 Oct 2018 14:47:53 -0400 Subject: [PATCH 17/56] make iv proper length, delete unused files --- ios/sojournTests/RCTAesTestCase.m | 48 ----------------- ios/sojournTests/RCTBridgeTestCase.h | 28 ---------- ios/sojournTests/RCTBridgeTestCase.m | 78 ---------------------------- src/utils/meat-grinder.js | 2 +- 4 files changed, 1 insertion(+), 155 deletions(-) delete mode 100644 ios/sojournTests/RCTAesTestCase.m delete mode 100644 ios/sojournTests/RCTBridgeTestCase.h delete mode 100644 ios/sojournTests/RCTBridgeTestCase.m diff --git a/ios/sojournTests/RCTAesTestCase.m b/ios/sojournTests/RCTAesTestCase.m deleted file mode 100644 index eac298e..0000000 --- a/ios/sojournTests/RCTAesTestCase.m +++ /dev/null @@ -1,48 +0,0 @@ -// -// RCTAesTestCase.m -// sojournTests -// -// Created by Hadas Zeilberger on 10/16/18. -// Copyright © 2018 Facebook. All rights reserved. -// -//aes unit tests -#import -#import -#import "RCTBridgeTestCase.h" -#import -@interface RCTAesTestCase : RCTBridgeTestCase - -@end - -@implementation RCTAesTestCase - - --(NSString *)moduleName -{ - return @"RCTAesTests"; -} --(NSArray> *)bridgeModules{ - RCTAes *aes = [RCTAes alloc]; - return @[aes]; -} -- (void)setup { - [super setup]; -} - -- (void)tearDown { - // Put teardown code here. This method is called after the invocation of each test method in the class. -} - -- (void)testExample { - // This is an example of a functional test case. - // Use XCTAssert and related functions to verify your tests produce the correct results. -} - -- (void)testPerformanceExample { - // This is an example of a performance test case. - [self measureBlock:^{ - // Put the code you want to measure the h of here. - }]; -} - -@end diff --git a/ios/sojournTests/RCTBridgeTestCase.h b/ios/sojournTests/RCTBridgeTestCase.h deleted file mode 100644 index 303adff..0000000 --- a/ios/sojournTests/RCTBridgeTestCase.h +++ /dev/null @@ -1,28 +0,0 @@ -// -// RCTBridgeTestCase.h -// sojournTests -// -// Created by Hadas Zeilberger on 10/16/18. -// Copyright © 2018 Facebook. All rights reserved. -// - -#ifndef RCTBridgeTestCase_h -#define RCTBridgeTestCase_h - -#import -#import -#import -#define CURRENT_METHOD _cmd - -@interface RCTBridgeTestCase : XCTestCase - -@property (nonatomic, strong, readonly, nonnull) NSString *moduleName; -@property (nonatomic,strong,readonly,nullable) NSArray> *bridgeModules; -@property (nonatomic, assign, readonly) NSTimeInterval timeout; - -- (void)runTest:(nonnull SEL)selector; -- (void)runTest:(nonnull SEL)selector timeout:(NSTimeInterval)timeout; -- (void) setup; - -@end -#endif /* RCTBridgeTestCase_h */ diff --git a/ios/sojournTests/RCTBridgeTestCase.m b/ios/sojournTests/RCTBridgeTestCase.m deleted file mode 100644 index 6975783..0000000 --- a/ios/sojournTests/RCTBridgeTestCase.m +++ /dev/null @@ -1,78 +0,0 @@ -// -// RCTBridgeTestCase.m -// sojournTests -// -// Created by Hadas Zeilberger on 10/15/18. -// Copyright © 2018 Facebook. All rights reserved. -// -//entry point for unit tests - -#import "RCTBridgeTestCase.h" -#define CURRENT_METHOD _cmd - - -@implementation RCTBridgeTestCase{ - RCTTestRunner *_runner; -} - -- (void)setUp { - [super setUp]; - //load the component that contains all tests - nativetests.js in this case - _runner = RCTInitRunnerForApp(@"nativetests",[self moduleProvider],@"http://localhost:8080"); - _runner.recordMode = NO;<#(nonnull NSString *)#> - // Put setup code here. This method is called before the invocation of each test method in the class. -} - -- (NSArray> *(^)(void))moduleProvider -{ - NSArray *bridges = self.bridgeModules; - - if (bridges && bridges.count > 0) { - return ^() { - return bridges; - }; - } - - return nil; -} - -- (void)runTest:(SEL)selector -{ - [self runTest:selector timeout:self.timeout]; -} - -- (void)runTest:(SEL)selector timeout:(NSTimeInterval)timeout -{ - NSString *name = self.moduleName; - if (name) { - NSDictionary *dict = @{ - @"testName": NSStringFromSelector(selector), - @"testTimeout": @(timeout) - }; - - [_runner runTest:_cmd module:name initialProps:dict configurationBlock:nil]; - } - else { - @throw [NSException exceptionWithName:@"exception" - reason:@"missing module" - userInfo:nil]; - } -} - -- (void)tearDown { - // Put teardown code here. This method is called after the invocation of each test method in the class. -} - -- (void)testExample { - // This is an example of a functional test case. - // Use XCTAssert and related functions to verify your tests produce the correct results. -} - -- (void)testPerformanceExample { - // This is an example of a performance test case. - [self measureBlock:^{ - // Put the code you want to measure the time of here. - }]; -} - -@end diff --git a/src/utils/meat-grinder.js b/src/utils/meat-grinder.js index 900f014..9062c48 100644 --- a/src/utils/meat-grinder.js +++ b/src/utils/meat-grinder.js @@ -2,7 +2,7 @@ import Aes from '@trackforce/react-native-aes-crypto'; //arguments: file - plaintext file //return value:encrypted file export async function encryptWithAes(privateKey, plainTextFile) { - const iv = 'base 64 random 16 bytes string'; + const iv = 'sixteen bytes iv'; //To DO: randomly generate try { const ciphertext = await Aes.encrypt(plainTextFile, privateKey, iv); return { ciphertext, iv }; From 4b36be170c7f4c4f57b8308c50cb586083ad8e41 Mon Sep 17 00:00:00 2001 From: Hadas Zeilberger Date: Wed, 10 Oct 2018 13:15:00 -0400 Subject: [PATCH 18/56] this is a mock for doc purposes --- src/utils/meat-grinder.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/utils/meat-grinder.js b/src/utils/meat-grinder.js index 9062c48..5398353 100644 --- a/src/utils/meat-grinder.js +++ b/src/utils/meat-grinder.js @@ -1,3 +1,4 @@ +<<<<<<< HEAD import Aes from '@trackforce/react-native-aes-crypto'; //arguments: file - plaintext file //return value:encrypted file @@ -14,6 +15,13 @@ export async function encryptWithAes(privateKey, plainTextFile) { //arguments: encrypted file //return value: array of (x,y) coordinates /* + +//arguments: file - plaintext file +//return value:encrypted file +function encryptWtihAes(plainTextFile) {} +//arguments: encrypted file +//return value: array of (x,y) coordinates + function encryptWithShamirs(encryptedFile) {} //arguments:array points needed to reconstruct encryptedFile //return value: array of new (x,y) coordinates From 905433dce09ead47e4680f59774ffea9dd2ac8be Mon Sep 17 00:00:00 2001 From: Hadas Zeilberger Date: Fri, 12 Oct 2018 17:14:42 -0400 Subject: [PATCH 19/56] implemented aes function --- package.json | 1 + src/utils/meat-grinder.js | 19 ++++++++++++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 272f9d3..a058dcd 100644 --- a/package.json +++ b/package.json @@ -29,6 +29,7 @@ "bitcore-mnemonic-react-native": "^1.2.4", "get-random-values": "^1.1.1", "global": "^4.3.0", + "bitcore-mnemonic-react-native": "^1.2.4", "react": "16.5.0", "react-native": "0.57.2", "react-native-dotenv": "^0.2.0", diff --git a/src/utils/meat-grinder.js b/src/utils/meat-grinder.js index 5398353..2559740 100644 --- a/src/utils/meat-grinder.js +++ b/src/utils/meat-grinder.js @@ -1,4 +1,5 @@ <<<<<<< HEAD +<<<<<<< HEAD import Aes from '@trackforce/react-native-aes-crypto'; //arguments: file - plaintext file //return value:encrypted file @@ -16,12 +17,28 @@ export async function encryptWithAes(privateKey, plainTextFile) { //return value: array of (x,y) coordinates /* +======= +import Aes from '@trackforce/react-native-aes-crypto'; +>>>>>>> implemented aes function //arguments: file - plaintext file //return value:encrypted file -function encryptWtihAes(plainTextFile) {} +export async function encryptWithAes(privateKey, plainTextFile) { + const iv = 'base 64 random 16 bytes string'; + try { + const ciphertext = await Aes.encrypt(plainTextFile, privateKey, iv); + return { ciphertext, iv }; + } catch (error) { + throw error; + } +} + //arguments: encrypted file //return value: array of (x,y) coordinates +<<<<<<< HEAD +======= +/* +>>>>>>> implemented aes function function encryptWithShamirs(encryptedFile) {} //arguments:array points needed to reconstruct encryptedFile //return value: array of new (x,y) coordinates From de6824afc3d09750821d7014aefd4b0196aa0f04 Mon Sep 17 00:00:00 2001 From: Hadas Zeilberger Date: Tue, 16 Oct 2018 12:09:10 -0400 Subject: [PATCH 20/56] iOS unit tests --- ios/sojournTests/RCTAesTestCase.m | 48 +++++++++++++++++ ios/sojournTests/RCTBridgeTestCase.h | 28 ++++++++++ ios/sojournTests/RCTBridgeTestCase.m | 78 ++++++++++++++++++++++++++++ 3 files changed, 154 insertions(+) create mode 100644 ios/sojournTests/RCTAesTestCase.m create mode 100644 ios/sojournTests/RCTBridgeTestCase.h create mode 100644 ios/sojournTests/RCTBridgeTestCase.m diff --git a/ios/sojournTests/RCTAesTestCase.m b/ios/sojournTests/RCTAesTestCase.m new file mode 100644 index 0000000..eac298e --- /dev/null +++ b/ios/sojournTests/RCTAesTestCase.m @@ -0,0 +1,48 @@ +// +// RCTAesTestCase.m +// sojournTests +// +// Created by Hadas Zeilberger on 10/16/18. +// Copyright © 2018 Facebook. All rights reserved. +// +//aes unit tests +#import +#import +#import "RCTBridgeTestCase.h" +#import +@interface RCTAesTestCase : RCTBridgeTestCase + +@end + +@implementation RCTAesTestCase + + +-(NSString *)moduleName +{ + return @"RCTAesTests"; +} +-(NSArray> *)bridgeModules{ + RCTAes *aes = [RCTAes alloc]; + return @[aes]; +} +- (void)setup { + [super setup]; +} + +- (void)tearDown { + // Put teardown code here. This method is called after the invocation of each test method in the class. +} + +- (void)testExample { + // This is an example of a functional test case. + // Use XCTAssert and related functions to verify your tests produce the correct results. +} + +- (void)testPerformanceExample { + // This is an example of a performance test case. + [self measureBlock:^{ + // Put the code you want to measure the h of here. + }]; +} + +@end diff --git a/ios/sojournTests/RCTBridgeTestCase.h b/ios/sojournTests/RCTBridgeTestCase.h new file mode 100644 index 0000000..303adff --- /dev/null +++ b/ios/sojournTests/RCTBridgeTestCase.h @@ -0,0 +1,28 @@ +// +// RCTBridgeTestCase.h +// sojournTests +// +// Created by Hadas Zeilberger on 10/16/18. +// Copyright © 2018 Facebook. All rights reserved. +// + +#ifndef RCTBridgeTestCase_h +#define RCTBridgeTestCase_h + +#import +#import +#import +#define CURRENT_METHOD _cmd + +@interface RCTBridgeTestCase : XCTestCase + +@property (nonatomic, strong, readonly, nonnull) NSString *moduleName; +@property (nonatomic,strong,readonly,nullable) NSArray> *bridgeModules; +@property (nonatomic, assign, readonly) NSTimeInterval timeout; + +- (void)runTest:(nonnull SEL)selector; +- (void)runTest:(nonnull SEL)selector timeout:(NSTimeInterval)timeout; +- (void) setup; + +@end +#endif /* RCTBridgeTestCase_h */ diff --git a/ios/sojournTests/RCTBridgeTestCase.m b/ios/sojournTests/RCTBridgeTestCase.m new file mode 100644 index 0000000..6975783 --- /dev/null +++ b/ios/sojournTests/RCTBridgeTestCase.m @@ -0,0 +1,78 @@ +// +// RCTBridgeTestCase.m +// sojournTests +// +// Created by Hadas Zeilberger on 10/15/18. +// Copyright © 2018 Facebook. All rights reserved. +// +//entry point for unit tests + +#import "RCTBridgeTestCase.h" +#define CURRENT_METHOD _cmd + + +@implementation RCTBridgeTestCase{ + RCTTestRunner *_runner; +} + +- (void)setUp { + [super setUp]; + //load the component that contains all tests - nativetests.js in this case + _runner = RCTInitRunnerForApp(@"nativetests",[self moduleProvider],@"http://localhost:8080"); + _runner.recordMode = NO;<#(nonnull NSString *)#> + // Put setup code here. This method is called before the invocation of each test method in the class. +} + +- (NSArray> *(^)(void))moduleProvider +{ + NSArray *bridges = self.bridgeModules; + + if (bridges && bridges.count > 0) { + return ^() { + return bridges; + }; + } + + return nil; +} + +- (void)runTest:(SEL)selector +{ + [self runTest:selector timeout:self.timeout]; +} + +- (void)runTest:(SEL)selector timeout:(NSTimeInterval)timeout +{ + NSString *name = self.moduleName; + if (name) { + NSDictionary *dict = @{ + @"testName": NSStringFromSelector(selector), + @"testTimeout": @(timeout) + }; + + [_runner runTest:_cmd module:name initialProps:dict configurationBlock:nil]; + } + else { + @throw [NSException exceptionWithName:@"exception" + reason:@"missing module" + userInfo:nil]; + } +} + +- (void)tearDown { + // Put teardown code here. This method is called after the invocation of each test method in the class. +} + +- (void)testExample { + // This is an example of a functional test case. + // Use XCTAssert and related functions to verify your tests produce the correct results. +} + +- (void)testPerformanceExample { + // This is an example of a performance test case. + [self measureBlock:^{ + // Put the code you want to measure the time of here. + }]; +} + +@end From 45409187c7bd8b70cd5ee690866f7b4e834190ff Mon Sep 17 00:00:00 2001 From: Hadas Zeilberger Date: Wed, 17 Oct 2018 15:33:34 -0400 Subject: [PATCH 21/56] detox setup --- e2e/init.js | 2 ++ package.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/e2e/init.js b/e2e/init.js index ab0e6ef..7a55a40 100644 --- a/e2e/init.js +++ b/e2e/init.js @@ -1,7 +1,9 @@ const detox = require('detox'); const config = require('../package.json').detox; const adapter = require('detox/runners/jest/adapter'); + const { exec } = require('child_process'); + jest.setTimeout(120000); jasmine.getEnv().addReporter(adapter); diff --git a/package.json b/package.json index a058dcd..6a1b2ab 100644 --- a/package.json +++ b/package.json @@ -80,7 +80,7 @@ "configurations": { "ios.sim.debug": { "binaryPath": "ios/build/Build/Products/Debug-iphonesimulator/sojourn.app", - "build": "cp index.test.js index.js && xcodebuild -project ios/sojourn.xcodeproj -configuration Debug -scheme sojourn -destination id=AC488766-22CC-4F2F-AEE5-F699F8D3BE7A -derivedDataPath ios/build", + "build": "xcodebuild -project ios/sojourn.xcodeproj -scheme sojourn -configuration Debug -sdk iphonesimulator -derivedDataPath ios/build", "type": "ios.simulator", "name": "iPhone XS" } From 8f4d1c1638b77a4d0d7153275c98c4c800a73c27 Mon Sep 17 00:00:00 2001 From: Hadas Zeilberger Date: Sat, 20 Oct 2018 14:47:53 -0400 Subject: [PATCH 22/56] make iv proper length, delete unused files --- ios/sojournTests/RCTAesTestCase.m | 48 ----------------- ios/sojournTests/RCTBridgeTestCase.h | 28 ---------- ios/sojournTests/RCTBridgeTestCase.m | 78 ---------------------------- src/utils/meat-grinder.js | 2 +- 4 files changed, 1 insertion(+), 155 deletions(-) delete mode 100644 ios/sojournTests/RCTAesTestCase.m delete mode 100644 ios/sojournTests/RCTBridgeTestCase.h delete mode 100644 ios/sojournTests/RCTBridgeTestCase.m diff --git a/ios/sojournTests/RCTAesTestCase.m b/ios/sojournTests/RCTAesTestCase.m deleted file mode 100644 index eac298e..0000000 --- a/ios/sojournTests/RCTAesTestCase.m +++ /dev/null @@ -1,48 +0,0 @@ -// -// RCTAesTestCase.m -// sojournTests -// -// Created by Hadas Zeilberger on 10/16/18. -// Copyright © 2018 Facebook. All rights reserved. -// -//aes unit tests -#import -#import -#import "RCTBridgeTestCase.h" -#import -@interface RCTAesTestCase : RCTBridgeTestCase - -@end - -@implementation RCTAesTestCase - - --(NSString *)moduleName -{ - return @"RCTAesTests"; -} --(NSArray> *)bridgeModules{ - RCTAes *aes = [RCTAes alloc]; - return @[aes]; -} -- (void)setup { - [super setup]; -} - -- (void)tearDown { - // Put teardown code here. This method is called after the invocation of each test method in the class. -} - -- (void)testExample { - // This is an example of a functional test case. - // Use XCTAssert and related functions to verify your tests produce the correct results. -} - -- (void)testPerformanceExample { - // This is an example of a performance test case. - [self measureBlock:^{ - // Put the code you want to measure the h of here. - }]; -} - -@end diff --git a/ios/sojournTests/RCTBridgeTestCase.h b/ios/sojournTests/RCTBridgeTestCase.h deleted file mode 100644 index 303adff..0000000 --- a/ios/sojournTests/RCTBridgeTestCase.h +++ /dev/null @@ -1,28 +0,0 @@ -// -// RCTBridgeTestCase.h -// sojournTests -// -// Created by Hadas Zeilberger on 10/16/18. -// Copyright © 2018 Facebook. All rights reserved. -// - -#ifndef RCTBridgeTestCase_h -#define RCTBridgeTestCase_h - -#import -#import -#import -#define CURRENT_METHOD _cmd - -@interface RCTBridgeTestCase : XCTestCase - -@property (nonatomic, strong, readonly, nonnull) NSString *moduleName; -@property (nonatomic,strong,readonly,nullable) NSArray> *bridgeModules; -@property (nonatomic, assign, readonly) NSTimeInterval timeout; - -- (void)runTest:(nonnull SEL)selector; -- (void)runTest:(nonnull SEL)selector timeout:(NSTimeInterval)timeout; -- (void) setup; - -@end -#endif /* RCTBridgeTestCase_h */ diff --git a/ios/sojournTests/RCTBridgeTestCase.m b/ios/sojournTests/RCTBridgeTestCase.m deleted file mode 100644 index 6975783..0000000 --- a/ios/sojournTests/RCTBridgeTestCase.m +++ /dev/null @@ -1,78 +0,0 @@ -// -// RCTBridgeTestCase.m -// sojournTests -// -// Created by Hadas Zeilberger on 10/15/18. -// Copyright © 2018 Facebook. All rights reserved. -// -//entry point for unit tests - -#import "RCTBridgeTestCase.h" -#define CURRENT_METHOD _cmd - - -@implementation RCTBridgeTestCase{ - RCTTestRunner *_runner; -} - -- (void)setUp { - [super setUp]; - //load the component that contains all tests - nativetests.js in this case - _runner = RCTInitRunnerForApp(@"nativetests",[self moduleProvider],@"http://localhost:8080"); - _runner.recordMode = NO;<#(nonnull NSString *)#> - // Put setup code here. This method is called before the invocation of each test method in the class. -} - -- (NSArray> *(^)(void))moduleProvider -{ - NSArray *bridges = self.bridgeModules; - - if (bridges && bridges.count > 0) { - return ^() { - return bridges; - }; - } - - return nil; -} - -- (void)runTest:(SEL)selector -{ - [self runTest:selector timeout:self.timeout]; -} - -- (void)runTest:(SEL)selector timeout:(NSTimeInterval)timeout -{ - NSString *name = self.moduleName; - if (name) { - NSDictionary *dict = @{ - @"testName": NSStringFromSelector(selector), - @"testTimeout": @(timeout) - }; - - [_runner runTest:_cmd module:name initialProps:dict configurationBlock:nil]; - } - else { - @throw [NSException exceptionWithName:@"exception" - reason:@"missing module" - userInfo:nil]; - } -} - -- (void)tearDown { - // Put teardown code here. This method is called after the invocation of each test method in the class. -} - -- (void)testExample { - // This is an example of a functional test case. - // Use XCTAssert and related functions to verify your tests produce the correct results. -} - -- (void)testPerformanceExample { - // This is an example of a performance test case. - [self measureBlock:^{ - // Put the code you want to measure the time of here. - }]; -} - -@end diff --git a/src/utils/meat-grinder.js b/src/utils/meat-grinder.js index 2559740..100bc19 100644 --- a/src/utils/meat-grinder.js +++ b/src/utils/meat-grinder.js @@ -23,7 +23,7 @@ import Aes from '@trackforce/react-native-aes-crypto'; //arguments: file - plaintext file //return value:encrypted file export async function encryptWithAes(privateKey, plainTextFile) { - const iv = 'base 64 random 16 bytes string'; + const iv = 'sixteen bytes iv'; //To DO: randomly generate try { const ciphertext = await Aes.encrypt(plainTextFile, privateKey, iv); return { ciphertext, iv }; From 6242961f998d099fa6383856818b1ff094f28eb8 Mon Sep 17 00:00:00 2001 From: Hadas Zeilberger Date: Mon, 22 Oct 2018 16:53:48 -0400 Subject: [PATCH 23/56] package.json --- package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 6a1b2ab..1e34cf7 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,7 @@ "jest": "yarn build:truffle && jest", "test": "npm run lint && npm run jest", "prettier": "prettier \"**/*.{js,json,css,md}\" --write", - "postinstall": "node ./scripts/post-install.js" + "postinstall": "node ./scripts/post-install.js", "postinstall": "react-native link" }, "dependencies": { @@ -36,7 +36,7 @@ "react-native-uport-connect": "^0.1.3", "react-redux": "^5.0.7", "redux": "^4.0.1", - "whatwg-url": "^7.0.0" + "whatwg-url": "^7.0.0", "react-native-uport-connect": "git+https://github.com/barlock/react-native-uport-connect.git#support-babel-7", "utf-8": "^1.0.0" }, @@ -63,7 +63,7 @@ "prop-types": "^15.6.2", "react-test-renderer": "16.5.0", "truffle": "^5.0.0-next.12", - "web3-fake-provider": "^0.1.0" + "web3-fake-provider": "^0.1.0", "react-test-renderer": "16.5.0", "browserify": "^12.0.1", "uglify-js": "^2.6.0" From 48f5e124609699f3e51f782ebd3adc222e12af6e Mon Sep 17 00:00:00 2001 From: Hadas Zeilberger Date: Mon, 22 Oct 2018 17:18:24 -0400 Subject: [PATCH 24/56] detox detox detox --- e2e/init.js | 2 +- src/RCTAesTests.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/e2e/init.js b/e2e/init.js index 1b6300e..53348ad 100644 --- a/e2e/init.js +++ b/e2e/init.js @@ -17,6 +17,6 @@ beforeEach(async () => { afterAll(async () => { await adapter.afterAll(); console.log('cleaning up'); - exec('cp ../index.debug.js index.js'); + exec('cp index.debug.js index.js'); await detox.cleanup(); }); diff --git a/src/RCTAesTests.js b/src/RCTAesTests.js index bdffd16..76c2c28 100644 --- a/src/RCTAesTests.js +++ b/src/RCTAesTests.js @@ -1,5 +1,5 @@ import React, { Component } from 'react'; -import { encryptWithAes } from '../utils/meat-grinder.js'; +import { encryptWithAes } from './utils/meat-grinder.js'; import { View } from 'react-native'; const testPrivateKey = '8238BAE35C77FE4AEBB2DEB1B83A6F0027A01D0E4D93BF5B81F7117796955A17'; From 8b5a9696b2f74d66110c690f43ce38a8e3e913fe Mon Sep 17 00:00:00 2001 From: Hadas Zeilberger Date: Mon, 22 Oct 2018 17:25:20 -0400 Subject: [PATCH 25/56] detox --- .eslintrc.js | 8 +++++--- package.json | 28 ++++++++++++---------------- 2 files changed, 17 insertions(+), 19 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index 924e2f0..8869261 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -4,14 +4,15 @@ module.exports = { es6: true, node: true, browser: true, - jest: true + jest: true, + jasmine: true }, extends: [ 'eslint:recommended', 'plugin:react/recommended', 'plugin:prettier/recommended' ], - plugins: ['react', 'react-native'], + plugins: ['react', 'react-native', 'jasmine', 'detox'], settings: { react: { pragma: 'React', @@ -19,6 +20,7 @@ module.exports = { } }, rules: { - 'react/display-name': 'off' + 'react/display-name': 'off', + 'no-console': 'off' } }; diff --git a/package.json b/package.json index 3c50a84..3002dc3 100644 --- a/package.json +++ b/package.json @@ -12,33 +12,28 @@ "jest": "yarn build:truffle && jest", "test": "npm run lint && npm run jest", "prettier": "prettier \"**/*.{js,json,css,md}\" --write", - "postinstall": "react-native link && node ./scripts/post-install.js", + "postinstall": "react-native link && node ./scripts/post-install.js" }, "dependencies": { "@babel/plugin-proposal-class-properties": "^7.1.0", + "@trackforce/react-native-aes-crypto": "^1.2.3", "Base64": "^1.0.1", + "big-integer": "^1.6.5", + "bitcore-mnemonic-react-native": "^1.2.4", "drizzle": "git+https://github.com/trufflesuite/drizzle.git#1.2.3", "drizzle-react": "^1.2.0", "eth-block-tracker": "^4.0.3", - "node-libs-react-native": "^1.0.3", -======= - "postinstall": "react-native link" - }, - "dependencies": { - "@trackforce/react-native-aes-crypto": "^1.2.3", - "big-integer": "^1.6.5", - "bitcore-mnemonic-react-native": "^1.2.4", "get-random-values": "^1.1.1", "global": "^4.3.0", - "bitcore-mnemonic-react-native": "^1.2.4", + "node-libs-react-native": "^1.0.3", "react": "16.5.0", "react-native": "0.57.2", "react-native-dotenv": "^0.2.0", "react-native-uport-connect": "^0.1.3", "react-redux": "^5.0.7", "redux": "^4.0.1", - "whatwg-url": "^7.0.0", - "utf-8": "^1.0.0" + "utf-8": "^1.0.0", + "whatwg-url": "^7.0.0" }, "devDependencies": { "@babel/core": "^7.1.2", @@ -46,10 +41,13 @@ "babel-core": "7.0.0-bridge.0", "babel-eslint": "^10.0.1", "babel-jest": "^23.6.0", + "browserify": "^12.0.1", "concurrently": "^4.0.1", "detox": "^9.0.4", "eslint": "^5.6.1", "eslint-config-prettier": "^3.1.0", + "eslint-plugin-detox": "^1.0.0", + "eslint-plugin-jasmine": "^2.10.1", "eslint-plugin-prettier": "^3.0.0", "eslint-plugin-react": "^7.11.1", "eslint-plugin-react-native": "^3.3.0", @@ -63,10 +61,8 @@ "prop-types": "^15.6.2", "react-test-renderer": "16.5.0", "truffle": "^5.0.0-next.12", - "web3-fake-provider": "^0.1.0", - "react-test-renderer": "16.5.0", - "browserify": "^12.0.1", - "uglify-js": "^2.6.0" + "uglify-js": "^2.6.0", + "web3-fake-provider": "^0.1.0" }, "resolutions": { "babel-core": "7.0.0-bridge.0" From c065df6d2f616482dbcbc9a5454c2b79e3b48f74 Mon Sep 17 00:00:00 2001 From: Hadas Zeilberger Date: Mon, 22 Oct 2018 20:07:31 -0400 Subject: [PATCH 26/56] made test directory for unit tests --- e2e/firstTest.spec.js | 1 + package.json | 2 +- src/{ => _tests_}/App.test.js | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) rename src/{ => _tests_}/App.test.js (88%) diff --git a/e2e/firstTest.spec.js b/e2e/firstTest.spec.js index 240987d..668670c 100644 --- a/e2e/firstTest.spec.js +++ b/e2e/firstTest.spec.js @@ -1,3 +1,4 @@ +/* eslint-env detox/detox, jest*/ describe('Example', () => { beforeEach(async () => { await device.reloadReactNative(); diff --git a/package.json b/package.json index 3002dc3..328dbcc 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "build:truffle": "truffle compile", "ios": "react-native run-ios", "lint": "eslint .", - "jest": "yarn build:truffle && jest", + "jest": "yarn build:truffle && jest src/_tests_", "test": "npm run lint && npm run jest", "prettier": "prettier \"**/*.{js,json,css,md}\" --write", "postinstall": "react-native link && node ./scripts/post-install.js" diff --git a/src/App.test.js b/src/_tests_/App.test.js similarity index 88% rename from src/App.test.js rename to src/_tests_/App.test.js index fc6f975..48ff299 100644 --- a/src/App.test.js +++ b/src/_tests_/App.test.js @@ -1,5 +1,5 @@ import React from 'react'; -import App from './App'; +import App from '../App'; import renderer from 'react-test-renderer'; From c235dde9f1dcd29ce6d053047c54c09bb3d04396 Mon Sep 17 00:00:00 2001 From: Hadas Zeilberger Date: Tue, 23 Oct 2018 16:00:08 -0400 Subject: [PATCH 27/56] testing detox with travis --- .travis.yml | 5 +++-- package.json | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index d832e33..acef9bc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,7 @@ language: node_js node_js: -- "8" + - '8' branches: only: - - master + - master +os: osx diff --git a/package.json b/package.json index 328dbcc..a92f995 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "ios": "react-native run-ios", "lint": "eslint .", "jest": "yarn build:truffle && jest src/_tests_", - "test": "npm run lint && npm run jest", + "test": "npm run lint && npm run jest && detox build && detox test", "prettier": "prettier \"**/*.{js,json,css,md}\" --write", "postinstall": "react-native link && node ./scripts/post-install.js" }, From 0685882f1cc9d854e9c0be3c7dc00fbbf5c6886a Mon Sep 17 00:00:00 2001 From: Hadas Zeilberger Date: Tue, 23 Oct 2018 16:42:26 -0400 Subject: [PATCH 28/56] travis <3 detox --- e2e/RCTAesTests.js | 36 ++++++++++++++++++++++++++++++++++++ package.json | 2 +- 2 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 e2e/RCTAesTests.js diff --git a/e2e/RCTAesTests.js b/e2e/RCTAesTests.js new file mode 100644 index 0000000..445f3fe --- /dev/null +++ b/e2e/RCTAesTests.js @@ -0,0 +1,36 @@ +import React, { Component } from 'react'; +import { encryptWithAes } from '../src/utils/meat-grinder.js'; +import { View, Text } from 'react-native'; +var inputSizes = [16, 20, 48]; +const testPrivateKey = + '8238BAE35C77FE4AEBB2DEB1B83A6F0027A01D0E4D93BF5B81F7117796955A17'; +export default class RCTAesTests extends Component { + constructor(props) { + super(props); + this.state = { input16: 0, input20: 0, input48: 0 }; + inputSizes.map(inputSize => { + this.encryptForSize(inputSize); + }); + } + async encryptForSize(sizeInBytes) { + let aesOutput = await encryptWithAes( + testPrivateKey, + new Array(sizeInBytes).join('x') + ); + if (!aesOutput) { + throw Error('output is not good'); + } + this.setState({ ['input'.concat(sizeInBytes)]: aesOutput.ciphertext }); + console.warn(this.state); + return 'success'; + } + render() { + return ( + + {this.state.input16.length} + {this.state.input20.length} + {this.state.input48.length} + + ); + } +} diff --git a/package.json b/package.json index a92f995..d0313f0 100644 --- a/package.json +++ b/package.json @@ -76,7 +76,7 @@ "configurations": { "ios.sim.debug": { "binaryPath": "ios/build/Build/Products/Debug-iphonesimulator/sojourn.app", - "build": "cp index.test.js index.js && xcodebuild -project ios/sojourn.xcodeproj -configuration Debug -scheme sojourn -destination id=AC488766-22CC-4F2F-AEE5-F699F8D3BE7A -derivedDataPath ios/build", + "build": "cp index.test.js index.js && xcodebuild -project ios/sojourn.xcodeproj -configuration Debug -scheme sojourn -sdk iphonesimulator -derivedDataPath ios/build -UseModernBuildSystem=NO", "type": "ios.simulator", "name": "iPhone XS" } From bbdbbe00165cd95cdb61175eca036fb044646f77 Mon Sep 17 00:00:00 2001 From: Hadas Zeilberger Date: Tue, 23 Oct 2018 21:30:36 -0400 Subject: [PATCH 29/56] travis attempt 3 --- .travis.yml | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index acef9bc..d9076b6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,11 @@ -language: node_js -node_js: - - '8' +#language: node_js +#node_js: +# - '8' +language: objective-c +xcode_project: sojourn.xcodeproj +xcode_scheme: sojourn +xcode_destination: platform=iOS Simulator,OS=10.1,name=iPad Pro (9.7-inch) +xcode_sdk: iphonesimulator branches: only: - master -os: osx From 467a591eb33d3d4d9fc143d485cdc6ad91153f89 Mon Sep 17 00:00:00 2001 From: Hadas Zeilberger Date: Tue, 23 Oct 2018 21:39:21 -0400 Subject: [PATCH 30/56] travis --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index d9076b6..990218e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,7 +2,7 @@ #node_js: # - '8' language: objective-c -xcode_project: sojourn.xcodeproj +xcode_project: ios/sojourn.xcodeproj xcode_scheme: sojourn xcode_destination: platform=iOS Simulator,OS=10.1,name=iPad Pro (9.7-inch) xcode_sdk: iphonesimulator From 50d99000df2f59c1c37be563d293a053954a85e9 Mon Sep 17 00:00:00 2001 From: Hadas Zeilberger Date: Tue, 23 Oct 2018 21:43:37 -0400 Subject: [PATCH 31/56] travis --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 990218e..d4de9c0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,7 +4,6 @@ language: objective-c xcode_project: ios/sojourn.xcodeproj xcode_scheme: sojourn -xcode_destination: platform=iOS Simulator,OS=10.1,name=iPad Pro (9.7-inch) xcode_sdk: iphonesimulator branches: only: From e6b52ad7ed051cca176813444a621e8227813b54 Mon Sep 17 00:00:00 2001 From: Hadas Zeilberger Date: Tue, 23 Oct 2018 22:03:16 -0400 Subject: [PATCH 32/56] travis <3 brew --- .travis.yml | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index d4de9c0..8f90f48 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,10 +1,11 @@ -#language: node_js -#node_js: -# - '8' -language: objective-c -xcode_project: ios/sojourn.xcodeproj -xcode_scheme: sojourn -xcode_sdk: iphonesimulator +language: node_js +node_js: + - '8' branches: only: - master +osx_image: xcode10 +addons: + homebrew: + taps: wix/brew + packages: wix/brew/applesimutils From 2f6a75c617488fdfe6c575052af7860ef15abc76 Mon Sep 17 00:00:00 2001 From: Hadas Zeilberger Date: Tue, 23 Oct 2018 22:04:36 -0400 Subject: [PATCH 33/56] travis still <3 brew --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 8f90f48..e6614cd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,6 +4,7 @@ node_js: branches: only: - master +os: osx osx_image: xcode10 addons: homebrew: From a6a32af8f6a9b28357b7433fbb7f8fc8a6f8faec Mon Sep 17 00:00:00 2001 From: Hadas Zeilberger Date: Tue, 23 Oct 2018 22:11:57 -0400 Subject: [PATCH 34/56] travis <3 xcode tools --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index e6614cd..a08cf5d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,7 +5,6 @@ branches: only: - master os: osx -osx_image: xcode10 addons: homebrew: taps: wix/brew From dff781d889fd745e39e875620633e8181531f502 Mon Sep 17 00:00:00 2001 From: Hadas Zeilberger Date: Tue, 23 Oct 2018 22:24:10 -0400 Subject: [PATCH 35/56] downgraded iphone to match xcode 9, which is used to match travis xcode cli tools --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d0313f0..1b4f04a 100644 --- a/package.json +++ b/package.json @@ -78,7 +78,7 @@ "binaryPath": "ios/build/Build/Products/Debug-iphonesimulator/sojourn.app", "build": "cp index.test.js index.js && xcodebuild -project ios/sojourn.xcodeproj -configuration Debug -scheme sojourn -sdk iphonesimulator -derivedDataPath ios/build -UseModernBuildSystem=NO", "type": "ios.simulator", - "name": "iPhone XS" + "name": "iPhone 7" } }, "test-runner": "jest" From a565988cd65f71cb7f866e1d45a78f63c8567f3a Mon Sep 17 00:00:00 2001 From: Hadas Zeilberger Date: Wed, 24 Oct 2018 09:18:48 -0400 Subject: [PATCH 36/56] updated index files --- index.js | 2 -- index.test.js | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/index.js b/index.js index 14b4a6b..8819056 100644 --- a/index.js +++ b/index.js @@ -1,7 +1,5 @@ /** @format */ -import './polyfill'; import { AppRegistry } from 'react-native'; import App from './src/App'; import { name as appName } from './app.json'; - AppRegistry.registerComponent(appName, () => App); diff --git a/index.test.js b/index.test.js index 4443fe4..c5f722c 100644 --- a/index.test.js +++ b/index.test.js @@ -1,4 +1,4 @@ import { AppRegistry } from 'react-native'; import { name as appName } from './app.json'; -import RCTAesTests from './src/RCTAesTests'; +import RCTAesTests from './e2e/RCTAesTests'; AppRegistry.registerComponent(appName, () => RCTAesTests); From b563268a4e76a29b5785788e9a6ce7e94f1f3015 Mon Sep 17 00:00:00 2001 From: Hadas Zeilberger Date: Wed, 24 Oct 2018 09:42:37 -0400 Subject: [PATCH 37/56] package json alteration to get detox to work in travis --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1b4f04a..274a21e 100644 --- a/package.json +++ b/package.json @@ -76,7 +76,7 @@ "configurations": { "ios.sim.debug": { "binaryPath": "ios/build/Build/Products/Debug-iphonesimulator/sojourn.app", - "build": "cp index.test.js index.js && xcodebuild -project ios/sojourn.xcodeproj -configuration Debug -scheme sojourn -sdk iphonesimulator -derivedDataPath ios/build -UseModernBuildSystem=NO", + "build": "cp index.test.js index.js && set -o pipefail && export CODE_SIGNING_REQUIRED=NO && export RCT_NO_LAUNCH_PACKAGER=true && xcodebuild -project ios/sojourn.xcodeproj -configuration Debug -scheme sojourn -sdk iphonesimulator -derivedDataPath ios/build -UseModernBuildSystem=NO", "type": "ios.simulator", "name": "iPhone 7" } From 9a8f407d84096eda2ffc3e80fcedbacc27d4f354 Mon Sep 17 00:00:00 2001 From: Hadas Zeilberger Date: Wed, 24 Oct 2018 11:57:34 -0400 Subject: [PATCH 38/56] ensure there is a polyfill --- e2e/firstTest.spec.js | 2 +- index.debug.js | 1 + index.test.js | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/e2e/firstTest.spec.js b/e2e/firstTest.spec.js index 668670c..144eee4 100644 --- a/e2e/firstTest.spec.js +++ b/e2e/firstTest.spec.js @@ -5,7 +5,7 @@ describe('Example', () => { }); it('should have welcome screen', async () => { - await expect(element(by.id('welcome'))).toBeVisible(); + await expect(element(by.id('16ByteInput'))).toHaveText('24'); }); /* it('should show hello screen after tap', async () => { await element(by.id('hello_button')).tap(); diff --git a/index.debug.js b/index.debug.js index 8819056..71159a3 100644 --- a/index.debug.js +++ b/index.debug.js @@ -1,4 +1,5 @@ /** @format */ +import './polyfill'; import { AppRegistry } from 'react-native'; import App from './src/App'; import { name as appName } from './app.json'; diff --git a/index.test.js b/index.test.js index c5f722c..c5098a5 100644 --- a/index.test.js +++ b/index.test.js @@ -1,3 +1,4 @@ +import './polyfill'; import { AppRegistry } from 'react-native'; import { name as appName } from './app.json'; import RCTAesTests from './e2e/RCTAesTests'; From 3cbb5a5424a795b8976612921465ad67c0302423 Mon Sep 17 00:00:00 2001 From: Hadas Zeilberger Date: Wed, 24 Oct 2018 12:26:59 -0400 Subject: [PATCH 39/56] fixed package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 274a21e..1b4f04a 100644 --- a/package.json +++ b/package.json @@ -76,7 +76,7 @@ "configurations": { "ios.sim.debug": { "binaryPath": "ios/build/Build/Products/Debug-iphonesimulator/sojourn.app", - "build": "cp index.test.js index.js && set -o pipefail && export CODE_SIGNING_REQUIRED=NO && export RCT_NO_LAUNCH_PACKAGER=true && xcodebuild -project ios/sojourn.xcodeproj -configuration Debug -scheme sojourn -sdk iphonesimulator -derivedDataPath ios/build -UseModernBuildSystem=NO", + "build": "cp index.test.js index.js && xcodebuild -project ios/sojourn.xcodeproj -configuration Debug -scheme sojourn -sdk iphonesimulator -derivedDataPath ios/build -UseModernBuildSystem=NO", "type": "ios.simulator", "name": "iPhone 7" } From 0314527aa7401df101dbd272f3a0f0c525814c27 Mon Sep 17 00:00:00 2001 From: Hadas Zeilberger Date: Wed, 24 Oct 2018 13:18:58 -0400 Subject: [PATCH 40/56] travis <3 react-native --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index a08cf5d..6bad3dd 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,6 +5,7 @@ branches: only: - master os: osx +install: -npm install -g react-native-cli addons: homebrew: taps: wix/brew From 1855763baf771bf227da65171b149102895e9c5a Mon Sep 17 00:00:00 2001 From: Hadas Zeilberger Date: Wed, 24 Oct 2018 13:22:29 -0400 Subject: [PATCH 41/56] typo --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 6bad3dd..a72f018 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,7 +5,7 @@ branches: only: - master os: osx -install: -npm install -g react-native-cli +install: npm install -g react-native-cli addons: homebrew: taps: wix/brew From a92fd4d77bdfbaa9406fb2d902454ecd8294ef43 Mon Sep 17 00:00:00 2001 From: Hadas Zeilberger Date: Wed, 24 Oct 2018 13:28:38 -0400 Subject: [PATCH 42/56] install react-native-cli --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index a72f018..9d84c59 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,7 +5,7 @@ branches: only: - master os: osx -install: npm install -g react-native-cli +before_install: npm install -g react-native-cli addons: homebrew: taps: wix/brew From 39eb25de65515cd02994f1e58524e861fdd56e32 Mon Sep 17 00:00:00 2001 From: Hadas Zeilberger Date: Wed, 24 Oct 2018 13:47:08 -0400 Subject: [PATCH 43/56] travis <3 detox-cli --- .travis.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 9d84c59..2551c0e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,7 +5,9 @@ branches: only: - master os: osx -before_install: npm install -g react-native-cli +before_install: + - npm install -g react-native-cli + - npm install -g detox-cli addons: homebrew: taps: wix/brew From bbf6367d3ade094e649050df3b4e1b74c99f4a94 Mon Sep 17 00:00:00 2001 From: Hadas Zeilberger Date: Thu, 25 Oct 2018 13:41:22 -0400 Subject: [PATCH 44/56] took detox out of travis --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1b4f04a..9d75b5e 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "ios": "react-native run-ios", "lint": "eslint .", "jest": "yarn build:truffle && jest src/_tests_", - "test": "npm run lint && npm run jest && detox build && detox test", + "test": "npm run lint && npm run jest", "prettier": "prettier \"**/*.{js,json,css,md}\" --write", "postinstall": "react-native link && node ./scripts/post-install.js" }, From 51c3f3c73aaf4beb55d7c2eb546eb4d95b65b23a Mon Sep 17 00:00:00 2001 From: Hadas Zeilberger Date: Thu, 25 Oct 2018 14:27:32 -0400 Subject: [PATCH 45/56] changed some filenames for more clarity --- .gitignore | 2 ++ README.md | 6 +++++- e2e/{RCTAesTests.js => E2ETests.js} | 2 +- index.test.js => index.e2e.js | 4 ++-- index.debug.js => index.ios.js | 0 package.json | 3 ++- 6 files changed, 12 insertions(+), 5 deletions(-) rename e2e/{RCTAesTests.js => E2ETests.js} (95%) rename index.test.js => index.e2e.js (51%) rename index.debug.js => index.ios.js (100%) diff --git a/.gitignore b/.gitignore index 33debb8..e3f0fa4 100644 --- a/.gitignore +++ b/.gitignore @@ -59,5 +59,7 @@ buck-out/ # Bundle artifact *.jsbundle +#index file that gets replaced by e2e test scripts +index.js # env .env.* diff --git a/README.md b/README.md index 0c42f73..c08b4e3 100644 --- a/README.md +++ b/README.md @@ -17,4 +17,8 @@ UPORT_PRIVATE_KEY= ### End to End Tests -Run `detox build` followed by `detox test` for end to end tests +Run yarn e2e to run end to end tests. Because schemes other than debug and release are not trivial in react-native, +and because javascript environment variables are not trivial to pass in react-native, +there are two index files, index.debug.js which is the entry point for the regular app as it should be used in production, +and index.test.js, an entry point which is used for e2e tests. This is a temporary measure, as a way to test native modules +on the javascript side that are not yet integrated into the app (mainly for cryptography functions); diff --git a/e2e/RCTAesTests.js b/e2e/E2ETests.js similarity index 95% rename from e2e/RCTAesTests.js rename to e2e/E2ETests.js index 445f3fe..c709018 100644 --- a/e2e/RCTAesTests.js +++ b/e2e/E2ETests.js @@ -4,7 +4,7 @@ import { View, Text } from 'react-native'; var inputSizes = [16, 20, 48]; const testPrivateKey = '8238BAE35C77FE4AEBB2DEB1B83A6F0027A01D0E4D93BF5B81F7117796955A17'; -export default class RCTAesTests extends Component { +export default class E2ETests extends Component { constructor(props) { super(props); this.state = { input16: 0, input20: 0, input48: 0 }; diff --git a/index.test.js b/index.e2e.js similarity index 51% rename from index.test.js rename to index.e2e.js index c5098a5..bc943c2 100644 --- a/index.test.js +++ b/index.e2e.js @@ -1,5 +1,5 @@ import './polyfill'; import { AppRegistry } from 'react-native'; import { name as appName } from './app.json'; -import RCTAesTests from './e2e/RCTAesTests'; -AppRegistry.registerComponent(appName, () => RCTAesTests); +import E2ETests from './e2e/E2ETests'; +AppRegistry.registerComponent(appName, () => E2ETests); diff --git a/index.debug.js b/index.ios.js similarity index 100% rename from index.debug.js rename to index.ios.js diff --git a/package.json b/package.json index 9d75b5e..a2f46d5 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,7 @@ "lint": "eslint .", "jest": "yarn build:truffle && jest src/_tests_", "test": "npm run lint && npm run jest", + "e2e": "detox build && detox test", "prettier": "prettier \"**/*.{js,json,css,md}\" --write", "postinstall": "react-native link && node ./scripts/post-install.js" }, @@ -76,7 +77,7 @@ "configurations": { "ios.sim.debug": { "binaryPath": "ios/build/Build/Products/Debug-iphonesimulator/sojourn.app", - "build": "cp index.test.js index.js && xcodebuild -project ios/sojourn.xcodeproj -configuration Debug -scheme sojourn -sdk iphonesimulator -derivedDataPath ios/build -UseModernBuildSystem=NO", + "build": "cp index.e2e.js index.js && xcodebuild -project ios/sojourn.xcodeproj -configuration Debug -scheme sojourn -sdk iphonesimulator -derivedDataPath ios/build -UseModernBuildSystem=NO", "type": "ios.simulator", "name": "iPhone 7" } From 3defe293cdfe9a55f7c519c3632fd70d8847e3b5 Mon Sep 17 00:00:00 2001 From: Hadas Zeilberger Date: Thu, 25 Oct 2018 14:57:40 -0400 Subject: [PATCH 46/56] updated readme --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c08b4e3..90fa232 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,6 @@ UPORT_PRIVATE_KEY= Run yarn e2e to run end to end tests. Because schemes other than debug and release are not trivial in react-native, and because javascript environment variables are not trivial to pass in react-native, -there are two index files, index.debug.js which is the entry point for the regular app as it should be used in production, -and index.test.js, an entry point which is used for e2e tests. This is a temporary measure, as a way to test native modules +there are two index files, index.ios.js which is the entry point for the regular app as it should be used in production, +and index.e2e.js, an entry point which is used for e2e tests. This is a temporary measure, as a way to test native modules on the javascript side that are not yet integrated into the app (mainly for cryptography functions); From 4abbd18929528be626493b79b682e138740a5f12 Mon Sep 17 00:00:00 2001 From: Hadas Zeilberger Date: Fri, 26 Oct 2018 11:32:57 -0400 Subject: [PATCH 47/56] code review changes --- .eslintrc.js | 3 +-- e2e/E2ETests.js | 1 - e2e/init.js | 2 +- .../AppIcon.appiconset/Contents.json | 15 ------------- jest.config.js | 3 ++- package.json | 20 +++-------------- src/RCTAesTests.js | 22 ------------------- src/_tests_/App.test.js | 9 -------- 8 files changed, 7 insertions(+), 68 deletions(-) delete mode 100644 src/RCTAesTests.js delete mode 100644 src/_tests_/App.test.js diff --git a/.eslintrc.js b/.eslintrc.js index b680324..fbc88f8 100644 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -23,7 +23,6 @@ module.exports = { } }, rules: { - 'react/display-name': 'off', - 'no-console': 'off' + 'react/display-name': 'off' } }; diff --git a/e2e/E2ETests.js b/e2e/E2ETests.js index c709018..6efbcae 100644 --- a/e2e/E2ETests.js +++ b/e2e/E2ETests.js @@ -21,7 +21,6 @@ export default class E2ETests extends Component { throw Error('output is not good'); } this.setState({ ['input'.concat(sizeInBytes)]: aesOutput.ciphertext }); - console.warn(this.state); return 'success'; } render() { diff --git a/e2e/init.js b/e2e/init.js index 53348ad..51aab07 100644 --- a/e2e/init.js +++ b/e2e/init.js @@ -7,6 +7,7 @@ jest.setTimeout(120000); jasmine.getEnv().addReporter(adapter); beforeAll(async () => { + exec('cp index.test.js index.js'); await detox.init(config); }); @@ -16,7 +17,6 @@ beforeEach(async () => { afterAll(async () => { await adapter.afterAll(); - console.log('cleaning up'); exec('cp index.debug.js index.js'); await detox.cleanup(); }); diff --git a/ios/sojourn/Images.xcassets/AppIcon.appiconset/Contents.json b/ios/sojourn/Images.xcassets/AppIcon.appiconset/Contents.json index d25ce24..48e64ae 100644 --- a/ios/sojourn/Images.xcassets/AppIcon.appiconset/Contents.json +++ b/ios/sojourn/Images.xcassets/AppIcon.appiconset/Contents.json @@ -1,15 +1,5 @@ { "images": [ - { - "idiom": "iphone", - "size": "20x20", - "scale": "2x" - }, - { - "idiom": "iphone", - "size": "20x20", - "scale": "3x" - }, { "idiom": "iphone", "size": "29x29", @@ -39,11 +29,6 @@ "idiom": "iphone", "size": "60x60", "scale": "3x" - }, - { - "idiom": "ios-marketing", - "size": "1024x1024", - "scale": "1x" } ], "info": { diff --git a/jest.config.js b/jest.config.js index 5bcd4af..b59ef2b 100644 --- a/jest.config.js +++ b/jest.config.js @@ -7,5 +7,6 @@ module.exports = { window: true }, transformIgnorePatterns: ['node_modules/(?!react-|drizzle).+\\.js$'], - setupFiles: ['./test/setup.js'] + setupFiles: ['./test/setup.js'], + testPathIgnorePatterns: ['/node_modules', '/e2e/', '/test/'] }; diff --git a/package.json b/package.json index 72ec3b3..8a42c45 100644 --- a/package.json +++ b/package.json @@ -9,24 +9,14 @@ "build:truffle": "truffle compile", "ios": "react-native run-ios", "lint": "eslint .", - "jest": "yarn build:truffle && jest src/_tests_", + "jest": "yarn build:truffle && jest", "e2e": "detox build && detox test", "prettier": "prettier \"**/*.{js,json,css,md}\" --write", "postinstall": "react-native link && node ./scripts/post-install.js", "test": "yarn lint && yarn jest --coverage" }, "dependencies": { - "@babel/plugin-proposal-class-properties": "^7.1.0", - "@trackforce/react-native-aes-crypto": "^1.2.3", - "Base64": "^1.0.1", - "big-integer": "^1.6.5", - "bitcore-mnemonic-react-native": "^1.2.4", - "drizzle": "git+https://github.com/trufflesuite/drizzle.git#1.2.3", - "drizzle-react": "^1.2.0", - "eth-block-tracker": "^4.0.3", - "get-random-values": "^1.1.1", - "global": "^4.3.0", - "node-libs-react-native": "^1.0.3", + "react-native-aes-crypto": "^1.2.3", "react": "16.5.0", "react-native": "0.57.2", "react-native-dotenv": "^0.2.0", @@ -34,8 +24,6 @@ "react-navigation": "^2.18.0", "react-redux": "^5.0.7", "redux": "^4.0.1", - "utf-8": "^1.0.0", - "whatwg-url": "^7.0.0", "redux-persist": "^5.10.0", "redux-thunk": "^2.3.0", "reselect": "^4.0.0" @@ -47,7 +35,6 @@ "babel-core": "7.0.0-bridge.0", "babel-eslint": "^10.0.1", "babel-jest": "^23.6.0", - "browserify": "^12.0.1", "concurrently": "^4.0.1", "detox": "^9.0.4", "eslint": "^5.6.1", @@ -66,7 +53,6 @@ "prop-types": "^15.6.2", "react-test-renderer": "16.5.0", "truffle": "^5.0.0-next.12", - "uglify-js": "^2.6.0", "web3-fake-provider": "^0.1.0" }, "resolutions": { @@ -81,7 +67,7 @@ "configurations": { "ios.sim.debug": { "binaryPath": "ios/build/Build/Products/Debug-iphonesimulator/sojourn.app", - "build": "cp index.e2e.js index.js && xcodebuild -project ios/sojourn.xcodeproj -configuration Debug -scheme sojourn -sdk iphonesimulator -derivedDataPath ios/build -UseModernBuildSystem=NO", + "build": "xcodebuild -project ios/sojourn.xcodeproj -configuration Debug -scheme sojourn -sdk iphonesimulator -derivedDataPath ios/build -UseModernBuildSystem=NO", "type": "ios.simulator", "name": "iPhone 7" } diff --git a/src/RCTAesTests.js b/src/RCTAesTests.js deleted file mode 100644 index 76c2c28..0000000 --- a/src/RCTAesTests.js +++ /dev/null @@ -1,22 +0,0 @@ -import React, { Component } from 'react'; -import { encryptWithAes } from './utils/meat-grinder.js'; -import { View } from 'react-native'; -const testPrivateKey = - '8238BAE35C77FE4AEBB2DEB1B83A6F0027A01D0E4D93BF5B81F7117796955A17'; -export default class RCTAesTests extends Component { - async testAesEncryption() { - let aesOutput = await encryptWithAes( - testPrivateKey, - 'ffffffffffffffffffffffffffffffffffffffffffffffffffff' - ); - if (!aesOutput) { - throw Error('output is not good'); - } - console.warn(aesOutput); - return 'success'; - } - render() { - this.testAesEncryption(); - return ; - } -} diff --git a/src/_tests_/App.test.js b/src/_tests_/App.test.js deleted file mode 100644 index 48ff299..0000000 --- a/src/_tests_/App.test.js +++ /dev/null @@ -1,9 +0,0 @@ -import React from 'react'; -import App from '../App'; - -import renderer from 'react-test-renderer'; - -it('renders without crashing', () => { - const rendered = renderer.create().toJSON(); - expect(rendered).toBeTruthy(); -}); From 2d12a1a1b696bc4529c43429a97e326fadb83080 Mon Sep 17 00:00:00 2001 From: Hadas Zeilberger Date: Fri, 26 Oct 2018 11:34:19 -0400 Subject: [PATCH 48/56] reverted travis --- .travis.yml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2551c0e..bb061ff 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,11 +4,3 @@ node_js: branches: only: - master -os: osx -before_install: - - npm install -g react-native-cli - - npm install -g detox-cli -addons: - homebrew: - taps: wix/brew - packages: wix/brew/applesimutils From 7badc02e945d7008a020a46a06f0637d91facf42 Mon Sep 17 00:00:00 2001 From: Hadas Zeilberger Date: Fri, 26 Oct 2018 11:35:40 -0400 Subject: [PATCH 49/56] made readme more readable --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 90fa232..37a6b36 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ UPORT_PRIVATE_KEY= ### End to End Tests -Run yarn e2e to run end to end tests. Because schemes other than debug and release are not trivial in react-native, +Run `yarn e2e` to run end to end tests. Because schemes other than debug and release are not trivial in react-native, and because javascript environment variables are not trivial to pass in react-native, there are two index files, index.ios.js which is the entry point for the regular app as it should be used in production, and index.e2e.js, an entry point which is used for e2e tests. This is a temporary measure, as a way to test native modules From d1f6e48fa0e7a52a474faea4f681a497d2576915 Mon Sep 17 00:00:00 2001 From: Hadas Zeilberger Date: Fri, 26 Oct 2018 12:14:23 -0400 Subject: [PATCH 50/56] post install react-native link" --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 8a42c45..3003b4f 100644 --- a/package.json +++ b/package.json @@ -12,7 +12,7 @@ "jest": "yarn build:truffle && jest", "e2e": "detox build && detox test", "prettier": "prettier \"**/*.{js,json,css,md}\" --write", - "postinstall": "react-native link && node ./scripts/post-install.js", + "post-install": "react-native link", "test": "yarn lint && yarn jest --coverage" }, "dependencies": { From 3ae77a5149f747d2a61a27dbc5588a96de32676a Mon Sep 17 00:00:00 2001 From: Hadas Zeilberger Date: Fri, 26 Oct 2018 14:14:27 -0400 Subject: [PATCH 51/56] corrected file name --- e2e/init.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e/init.js b/e2e/init.js index 51aab07..f6393fb 100644 --- a/e2e/init.js +++ b/e2e/init.js @@ -7,7 +7,7 @@ jest.setTimeout(120000); jasmine.getEnv().addReporter(adapter); beforeAll(async () => { - exec('cp index.test.js index.js'); + exec('cp index.e2e.js index.js'); await detox.init(config); }); From 6830337f9334304f693a92c08f79ece12eaafde3 Mon Sep 17 00:00:00 2001 From: Michael Barlock Date: Fri, 26 Oct 2018 14:43:18 -0400 Subject: [PATCH 52/56] Remove Polyfill from index --- index.e2e.js | 1 - 1 file changed, 1 deletion(-) diff --git a/index.e2e.js b/index.e2e.js index bc943c2..6a25305 100644 --- a/index.e2e.js +++ b/index.e2e.js @@ -1,4 +1,3 @@ -import './polyfill'; import { AppRegistry } from 'react-native'; import { name as appName } from './app.json'; import E2ETests from './e2e/E2ETests'; From 772c3956196791c7df65c8c4d07ef3742d3ea7f6 Mon Sep 17 00:00:00 2001 From: Michael Barlock Date: Fri, 26 Oct 2018 14:43:37 -0400 Subject: [PATCH 53/56] Update index.ios.js --- index.ios.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/index.ios.js b/index.ios.js index 71159a3..434afd2 100644 --- a/index.ios.js +++ b/index.ios.js @@ -1,5 +1,3 @@ -/** @format */ -import './polyfill'; import { AppRegistry } from 'react-native'; import App from './src/App'; import { name as appName } from './app.json'; From 69460caca9388b6be409aa82963aba65fb708ad3 Mon Sep 17 00:00:00 2001 From: Michael Barlock Date: Fri, 26 Oct 2018 14:44:22 -0400 Subject: [PATCH 54/56] Update meat-grinder.js --- src/utils/meat-grinder.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils/meat-grinder.js b/src/utils/meat-grinder.js index c30231a..10cc3a4 100644 --- a/src/utils/meat-grinder.js +++ b/src/utils/meat-grinder.js @@ -1,4 +1,4 @@ -import Aes from '@trackforce/react-native-aes-crypto'; +import Aes from 'react-native-aes-crypto'; //arguments: file - plaintext file //return value:encrypted file export async function encryptWithAes(privateKey, plainTextFile) { From aa1d73ca4196653f0ffe0908b5401f2734f16cb9 Mon Sep 17 00:00:00 2001 From: Michael Barlock Date: Fri, 26 Oct 2018 14:45:09 -0400 Subject: [PATCH 55/56] Update init.js --- e2e/init.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e/init.js b/e2e/init.js index f6393fb..f9215cb 100644 --- a/e2e/init.js +++ b/e2e/init.js @@ -17,6 +17,6 @@ beforeEach(async () => { afterAll(async () => { await adapter.afterAll(); - exec('cp index.debug.js index.js'); + exec('rm index.js'); await detox.cleanup(); }); From c762ff91acc46606dfdc8d98b5318b444ed5fc32 Mon Sep 17 00:00:00 2001 From: Michael Barlock Date: Fri, 26 Oct 2018 14:45:28 -0400 Subject: [PATCH 56/56] Delete index.js --- index.js | 9 --------- 1 file changed, 9 deletions(-) delete mode 100644 index.js diff --git a/index.js b/index.js deleted file mode 100644 index c56d632..0000000 --- a/index.js +++ /dev/null @@ -1,9 +0,0 @@ -import { AppRegistry, YellowBox } from 'react-native'; -import App from './src/App'; -import { name as appName } from './app.json'; - -YellowBox.ignoreWarnings([ - 'Remote debugger is in a background tab which may cause apps to perform' -]); - -AppRegistry.registerComponent(appName, () => App);