Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into 166445617-using-good-gun
- Loading branch information
Showing
58 changed files
with
374 additions
and
286 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
File renamed without changes
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
// }) | ||
// }) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" | ||
} | ||
] | ||
} |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.