Skip to content

Commit

Permalink
Merge branch 'master' into 166445617-using-good-gun
Browse files Browse the repository at this point in the history
  • Loading branch information
dminones committed Jun 5, 2019
2 parents 49b7a2a + 103da4b commit 1fb81a7
Show file tree
Hide file tree
Showing 58 changed files with 374 additions and 286 deletions.
19 changes: 0 additions & 19 deletions .github/ISSUE_TEMPLATE/BUG_REPORT.md

This file was deleted.

10 changes: 0 additions & 10 deletions .github/ISSUE_TEMPLATE/FEATURE_REQUEST.md

This file was deleted.

20 changes: 0 additions & 20 deletions .github/PULL_REQUEST_TEMPLATE.md

This file was deleted.

File renamed without changes
File renamed without changes.
133 changes: 133 additions & 0 deletions loadtest/loadTest.js
@@ -0,0 +1,133 @@
import './mock-browser'
import { GoodWallet } from '../src/lib/wallet/GoodWallet'
import bip39 from 'bip39-light'
import { GoodWalletLogin } from '../src/lib/login/GoodWalletLogin'
import { UserStorage } from '../src/lib/gundb/UserStorage'
import Config from '../src/config/config'
import API from '../src/lib/API/api'
import faker from 'faker'
import range from 'lodash/range'
import FormData from 'form-data'
import fs from 'fs'
import fetch from 'node-fetch'
const Timeout = (timeout = 3000) => {
return new Promise((res, rej) => {
setTimeout(res, timeout)
})
}
let failedTests = {}
const createReq = (id, jwt) => {
let req = new FormData()
const facemap = fs.createReadStream('./loadtest/facemap.zip', { contentType: 'application/zip' })
const auditTrailImage = fs.createReadStream('./loadtest/face.png')
req.append('sessionId', faker.random.number())
req.append('facemap', facemap)
req.append('auditTrailImage', auditTrailImage)
req.append('enrollmentIdentifier', id)
return fetch(`${Config.serverUrl}/verify/facerecognition`, {
method: 'POST',
body: req,
headers: { Authorization: `Bearer ${jwt}` }
})
}

export const mytest = async i => {
try {
const gun = global.Gun({ file: './loadtest/loadtest' + i + '.json', peers: [`${Config.serverUrl}/gun`] })
let mnemonic = bip39.generateMnemonic()
let wallet = new GoodWallet({ mnemonic })
await wallet.ready
await API.ready
let storage = new UserStorage(wallet, gun)
let login = new GoodWalletLogin(wallet, storage)
await storage.ready
let creds = await login.auth()
// console.log({ creds })
var randomName = faker.name.findName() // Rowan Nikolaus
var randomEmail = faker.internet.email() // Kassandra.Haley@erich.biz
var randomCard = faker.phone.phoneNumber('+97250#######')
// console.log(randomCard, randomName, randomEmail)
let adduser = await Promise.race([
Timeout(20000).then(x => {
throw new Error('adduser timeout')
}),
API.addUser({
fullName: randomName,
email: randomEmail,
mobile: randomCard,
walletAddress: wallet.account
})
])
console.log('/user/add:', adduser.data)
if (adduser.data.ok !== 1) throw new Error('adduser failed')
await storage.setProfile({
fullName: randomName,
email: randomEmail,
mobile: randomCard,
walletAddress: wallet.account
})
let fr = await Promise.race([
Timeout(20000).then(x => {
throw new Error('FR timeout')
}),
createReq(wallet.getAccountForType('zoomId'), creds.jwt).then(r => r.json())
])

console.log('/verify/facerecognition:', fr)
if (fr.ok !== 1) throw new Error(`FR failed`)
let gunres = 0
await new Promise((res, rej) => {
gun.get('users/byemail').once(r => {
if (r && r.err) rej(new Error(r.err))
if (!r) rej(new Error('Empty gun data'))
else if (++gunres === 1) res()
})
// // gun.get('users/bymobile').open(r => {
// // if (r.err) rej(new Error(r.err))
// // else if (++gunres === 2) res()
// // })
// // gun.get('users/bywalletAddress').open(r => {
// // if (r.err) rej(new Error(r.err))
// // else if (++gunres === 3) res()
// // })
})
} catch (error) {
console.log(`Test failed`, error)
failedTests[error.message] !== undefined ? (failedTests[error.message] += 1) : (failedTests[error.message] = 1)
} finally {
// fs.unlinkSync('./loadtest/loadtest' + i + '.json')
}
}
const run = async numTests => {
let promises = []
for (let i = 0; i < numTests; i++) {
promises[i] = mytest(i)
await Timeout(10000)
}
console.log('Waiting for tests to finish...')
await Promise.all(promises)
console.log('Done running tests', { total: promises.length, failedTests })
console.log('Waiting for server memory stats')
await Timeout(5000)
console.log('Done. Quiting')
process.exit(-1)
}
let numTests = process.argv[2]
console.log('arrgs', process.argv, numTests)
run(numTests)
// describe('load test', () => {
// it('loadtest', async () => {
// const doLogin = async () => {
// let mnemonic = bip39.generateMnemonic()
// let wallet = new GoodWallet({ mnemonic })
// await wallet.ready
// expect(wallet).toBeTruthy()
// let login = new GoodWalletLogin(wallet)
// let creds = await login.auth()
// console.log({ creds })
// return expect(creds).toBeTruthy()
// }
// let promises = range(3).map(i => doLogin())
// await Promise.all(promises)
// })
// })
2 changes: 1 addition & 1 deletion src/loadtest/mock-browser.js → loadtest/mock-browser.js
@@ -1,5 +1,5 @@
import { LocalStorage } from 'node-localStorage'
import Config from '../config/config'
import Config from '../src/config/config'
import Gun from 'gun'
import SEA from 'gun/sea'
import load from 'gun/lib/load'
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "@gooddollar/gooddapp",
"version": "0.2.0",
"version": "0.2.1",
"engines": {
"node": "10.x",
"npm": "6.x"
Expand Down
Binary file modified public/android-icon-144x144.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/android-icon-192x192.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/android-icon-36x36.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/android-icon-48x48.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/android-icon-72x72.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/android-icon-96x96.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/apple-icon-114x114.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/apple-icon-120x120.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/apple-icon-144x144.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/apple-icon-152x152.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/apple-icon-180x180.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/apple-icon-57x57.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/apple-icon-60x60.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/apple-icon-72x72.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/apple-icon-76x76.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/apple-icon-precomposed.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/apple-icon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/favicon-16x16.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/favicon-32x32.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/favicon-96x96.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/favicon.ico
Binary file not shown.
55 changes: 52 additions & 3 deletions public/index.html
@@ -1,6 +1,56 @@
<!DOCTYPE html>
<html lang="en">
<head>
<script>
window['_fs_debug'] = false
window['_fs_host'] = 'fullstory.com'
window['_fs_org'] = 'MBF4Z'
window['_fs_namespace'] = 'FS'
;(function(m, n, e, t, l, o, g, y) {
if (e in m) {
if (m.console && m.console.log) {
m.console.log('FullStory namespace conflict. Please set window["_fs_namespace"].')
}
return
}
g = m[e] = function(a, b, s) {
g.q ? g.q.push([a, b, s]) : g._api(a, b, s)
}
g.q = []
o = n.createElement(t)
o.async = 1
o.crossOrigin = 'anonymous'
o.src = 'https://' + _fs_host + '/s/fs.js'
y = n.getElementsByTagName(t)[0]
y.parentNode.insertBefore(o, y)
g.identify = function(i, v, s) {
g(l, { uid: i }, s)
if (v) g(l, v, s)
}
g.setUserVars = function(v, s) {
g(l, v, s)
}
g.event = function(i, v, s) {
g('event', { n: i, p: v }, s)
}
g.shutdown = function() {
g('rec', !1)
}
g.restart = function() {
g('rec', !0)
}
g.consent = function(a) {
g('consent', !arguments.length || a)
}
g.identifyAccount = function(i, v) {
o = 'account'
v = v || {}
v.acctId = i
g(o, v)
}
g.clearUserCookie = function() {}
})(window, document, window['_fs_namespace'], 'script', 'user')
</script>
<script>
var _rollbarConfig = {
accessToken: '%REACT_APP_ROLLBAR_API_KEY%',
Expand Down Expand Up @@ -406,7 +456,7 @@
</script>
<meta charset="utf-8" />
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, height=device-height, initial-scale=1, shrink-to-fit=no">
<meta name="viewport" content="width=device-width, height=device-height, initial-scale=1, shrink-to-fit=no" />
<meta name="theme-color" content="#000000" />
<!--
manifest.json provides metadata used when your web app is added to the
Expand Down Expand Up @@ -445,7 +495,7 @@
<noscript>
You need to enable JavaScript to run this app.
</noscript>

<div id="root"></div>
<!--
This HTML file is a template.
Expand All @@ -458,5 +508,4 @@
To create a production bundle, use `npm run build` or `yarn build`.
-->
</body>

</html>
78 changes: 39 additions & 39 deletions public/manifest.json
@@ -1,41 +1,41 @@
{
"name": "GoodDollar",
"icons": [
{
"src": "/android-icon-36x36.png",
"sizes": "36x36",
"type": "image/png",
"density": "0.75"
},
{
"src": "/android-icon-48x48.png",
"sizes": "48x48",
"type": "image/png",
"density": "1.0"
},
{
"src": "/android-icon-72x72.png",
"sizes": "72x72",
"type": "image/png",
"density": "1.5"
},
{
"src": "/android-icon-96x96.png",
"sizes": "96x96",
"type": "image/png",
"density": "2.0"
},
{
"src": "/android-icon-144x144.png",
"sizes": "144x144",
"type": "image/png",
"density": "3.0"
},
{
"src": "/android-icon-192x192.png",
"sizes": "192x192",
"type": "image/png",
"density": "4.0"
}
]
"name": "GoodDollar",
"icons": [
{
"src": "/android-icon-36x36.png",
"sizes": "36x36",
"type": "image/png",
"density": "0.75"
},
{
"src": "/android-icon-48x48.png",
"sizes": "48x48",
"type": "image/png",
"density": "1.0"
},
{
"src": "/android-icon-72x72.png",
"sizes": "72x72",
"type": "image/png",
"density": "1.5"
},
{
"src": "/android-icon-96x96.png",
"sizes": "96x96",
"type": "image/png",
"density": "2.0"
},
{
"src": "/android-icon-144x144.png",
"sizes": "144x144",
"type": "image/png",
"density": "3.0"
},
{
"src": "/android-icon-192x192.png",
"sizes": "192x192",
"type": "image/png",
"density": "4.0"
}
]
}
Binary file modified public/ms-icon-144x144.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/ms-icon-150x150.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/ms-icon-310x310.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/ms-icon-70x70.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 0 additions & 2 deletions pull_request_template.md

This file was deleted.

4 changes: 3 additions & 1 deletion src/components/common/BigGoodDollar.js
Expand Up @@ -11,6 +11,8 @@ type Props = { number: any, props?: {} }
* @param {Number} [props.number]
* @returns {React.Node}
*/
const BigGoodDollar = ({ number, ...props }: Props) => <BigNumber number={weiToMask(number)} unit={'G$'} {...props} />
const BigGoodDollar = ({ number, ...props }: Props) => (
<BigNumber number={number !== undefined ? weiToMask(number) : '-.--'} unit={'G$'} {...props} />
)

export default BigGoodDollar
Expand Up @@ -149,7 +149,7 @@ exports[`TopBar matches snapshot with balance 1`] = `
}
}
>
0.00
-.--
</div>
<div
className="css-text-76zvg2"
Expand Down

0 comments on commit 1fb81a7

Please sign in to comment.