-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
157 changed files
with
3,512 additions
and
2,495 deletions.
There are no files selected for viewing
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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,36 @@ | ||
import LOCModel from '../../src/models/LOCModel' | ||
import LOCModel, { THE_90_DAYS } from '../../src/models/LOCModel' | ||
|
||
describe('LOC model', () => { | ||
it('should construct and return data', () => { | ||
const model = new LOCModel({address: 0x100, hasConfirmed: true, locName: 'LocX', website: 'www', issueLimit: 1000, issued: 10, redeemed: 5, expDate: 4545454545, status: 1}) | ||
expect(model.getAddress()).toBe(0x100) | ||
expect(model.name()).toBe('LocX') | ||
expect(model.issueLimit()).toBe(1000 / 100000000) | ||
expect(model.issued()).toBe(10 / 100000000) | ||
expect(model.redeemed()).toBe(5) | ||
expect(model.expDate()).toBe(4545454545) | ||
let model = new LOCModel({ | ||
name: 'name', | ||
oldName: 'oldName', | ||
website: 'www', | ||
issueLimit: 1000, | ||
issued: 10, | ||
redeemed: 5, | ||
status: 1, | ||
currency: 2, | ||
isNew: false | ||
}) | ||
|
||
expect(model.name()).toBe('name') | ||
expect(model.oldName()).toBe('oldName') | ||
expect(model.issueLimit()).toBe(1000) | ||
expect(model.issued()).toBe(10) | ||
expect(model.expDate() - model.createDate()).toEqual(THE_90_DAYS) | ||
expect(model.daysLeft()).toBe(90 - 1) | ||
expect(model.status()).toBe(1) | ||
expect(model.currency()).toBe(2) | ||
expect(model.currencyString()).toBe('LHT') | ||
expect(model.isNew()).toBe(false) | ||
|
||
model = model.isPending(true) | ||
expect(model.isPending()).toBe(true) | ||
expect(model.isFailed()).toBe(false) | ||
|
||
model = model.isFailed(true) | ||
expect(model.isPending()).toBe(false) | ||
expect(model.isFailed()).toBe(true) | ||
}) | ||
}) |
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,9 @@ | ||
import walletGenerator from '../../src/network/walletGenerator' | ||
|
||
describe('wallet generator', () =>{ | ||
it('should generate different wallets', async () => { | ||
const wallet1 = await walletGenerator('123') | ||
const wallet2 = await walletGenerator('123') | ||
expect(wallet1).not.toEqual(wallet2) | ||
}) | ||
}) |
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,131 +1,125 @@ | ||
// import * as actions from '../../../src/redux/locs/list/actions' | ||
import * as formActions from '../../../src/redux/locs/locForm/actions' | ||
// import { LOCS_LIST, LOC_CREATE, LOC_UPDATE, LOC_REMOVE } from '../../../src/redux/locs/list/reducer' | ||
// import {LOCS_FETCH_START, LOCS_FETCH_END} from '../../../src/redux/locs/commonProps/' | ||
// import {LOCS_COUNTER} from '../../../src/redux/locs/counter' | ||
// import LOCManagerDAO from '../../../src/dao/LOCManagerDAO' | ||
import * as a from '../../../src/redux/locs/actions' | ||
import ContractsManagerDAO from '../../../src/dao/ContractsManagerDAO' | ||
import { store } from '../../init' | ||
// import { address as validateAddress } from '../../../src/components/forms/validate' | ||
import LOCModel from '../../../src/models/LOCModel' | ||
// import web3Provider from '../../../src/network/Web3Provider' | ||
|
||
// const account = web3Provider.getWeb3instance().eth.accounts[0] | ||
// let address | ||
const loc1 = new LOCModel({ | ||
name: 'loc1', | ||
oldName: 'loc1', | ||
website: 'dkchv.ru', | ||
createDate: Date.now(), | ||
expDate: Date.now() | ||
}) | ||
|
||
const loc2 = new LOCModel({ | ||
name: 'loc2', | ||
oldName: 'loc2', | ||
website: 'dkchv2.ru', | ||
createDate: Date.now(), | ||
expDate: Date.now() | ||
}) | ||
|
||
describe('LOCs actions', () => { | ||
// it('should propose new LOC', done => { | ||
// const loc = new LOCModel({ | ||
// locName: '1484554656', | ||
// website: 'www.ru', | ||
// issueLimit: 1000, | ||
// publishedHash: 'QmTeW79w7QQ6Npa3b1d5tANreCDxF2iDaAPsDvW6KtLmfB', | ||
// expDate: 1484554656 | ||
// }) | ||
// | ||
// LOCManagerDAO.newLOCWatch((locModel) => { | ||
// // address = locModel.getAddress() | ||
// expect(locModel.name()).toEqual('1484554656') | ||
// done() | ||
// }, account).then(() => | ||
// store.dispatch(formActions.submitLOC(loc, account)) | ||
// ) | ||
// }) | ||
|
||
it.skip('should NOT propose new LOC', () => { | ||
const loc = new LOCModel() | ||
|
||
return store.dispatch(formActions.submitLOC(loc)).then((r) => | ||
expect(r).toBe(false) | ||
) | ||
it('should subscribe on watch', async () => { | ||
const locManager = await ContractsManagerDAO.getLOCManagerDAO() | ||
spyOn(locManager, '_watch').and.returnValue(Promise.resolve()) | ||
|
||
await store.dispatch(a.watchInitLOC()) | ||
expect(locManager._watch.calls.argsFor(0)[0]).toEqual('NewLOC') | ||
expect(locManager._watch.calls.argsFor(1)[0]).toEqual('UpdLOCName') | ||
expect(locManager._watch.calls.argsFor(2)[0]).toEqual('UpdLOCStatus') | ||
expect(locManager._watch.calls.argsFor(3)[0]).toEqual('RemLOC') | ||
expect(locManager._watch.calls.argsFor(4)[0]).toEqual('Reissue') | ||
}) | ||
|
||
// it('should fetch LOCs', () => { | ||
// return store.dispatch(actions.getLOCs(account)).then(() => { | ||
// expect(store.getActions()[0].type).toEqual(LOCS_FETCH_START) | ||
// expect(store.getActions()[1].type).toEqual(LOCS_LIST) | ||
// const address_ = store.getActions()[1].data.keySeq().toArray()[0] | ||
// expect(validateAddress(address_)).toEqual(null) | ||
// expect(store.getActions()[2].type).toEqual(LOCS_FETCH_END) | ||
// }) | ||
// }) | ||
|
||
// it('should fetch LOCs counter', () => { | ||
// return store.dispatch(actions.getLOCsCounter(account)).then(() => { | ||
// const action = store.getActions()[0] | ||
// expect(action.type).toEqual(LOCS_COUNTER) | ||
// expect(action.payload).toBeGreaterThanOrEqual(0) | ||
// }) | ||
// }) | ||
|
||
// it('should update LOC', (done) => { | ||
// LOCManagerDAO.updLOCValueWatch((locAddr, settingName, value, instance) => { | ||
// instance.stopWatching() | ||
// expect(locAddr).toEqual(address) | ||
// expect(value).toEqual(2000) | ||
// done() | ||
// }) | ||
// | ||
// const loc = new LOCModel({ address, issueLimit: 2000 }) | ||
// store.dispatch(formActions.submitLOC(loc, account)) | ||
// }) | ||
// | ||
// // TODO @dkchv: off | ||
// // it('should NOT update LOC', () => { | ||
// // const loc = new LOCModel({ address: '0x6777151f532964a7cf234c1989564d3822c8210e', issueLimit: 2000 }) | ||
// // return store.dispatch(formActions.submitLOC(loc, account)).then((r) => | ||
// // expect(r).toBe(false) | ||
// // ) | ||
// // }) | ||
// | ||
// it('should remove LOC', (done) => { | ||
// LOCManagerDAO.remLOCWatch((r) => { | ||
// expect(r).toEqual(address) | ||
// done() | ||
// }) | ||
// | ||
// store.dispatch(formActions.removeLOC(address, account)) | ||
// }) | ||
|
||
// it('should NOT remove LOC', () => { | ||
// return store.dispatch(formActions.removeLOC(0, 0)).then(() => | ||
// expect(store.getActions()).toContainEqual({payload: {modalProps: | ||
// {message: 'Transaction canceled!', title: 'Remove LOC Error!'}, | ||
// modalType: 'modals/ALERT_TYPE'}, | ||
// type: 'modal/SHOW'}) | ||
// ) | ||
// }) | ||
// | ||
// it('should issue LH', () => { | ||
// return store.dispatch(actions.issueLH({account, issueAmount: 48, address})).then(() => | ||
// expect(store.getActions()).toContainEqual({data: {address, value: true, valueName: 'isIssuing'}, type: LOC_UPDATE}) | ||
// ) | ||
// }) | ||
// | ||
// it('should redeem LH', () => { | ||
// return store.dispatch(actions.redeemLH({account, redeemAmount: 47, address})).then(() => | ||
// expect(store.getActions()).toContainEqual({data: {address, value: false, valueName: 'isRedeeming'}, type: LOC_UPDATE}) | ||
// ) | ||
// }) | ||
// | ||
// it('should NOT redeem LH', () => { | ||
// return store.dispatch(actions.redeemLH({account: 0, redeemAmount: 46, address: 0})).then(() => | ||
// expect(store.getActions()).toContainEqual({data: {address: 0, value: false, valueName: 'isRedeeming'}, type: LOC_UPDATE, result: 'error'}) | ||
// ) | ||
// }) | ||
// | ||
// it('should create an action to show what LOC is created', () => { | ||
// const locModel = new LOCModel({address: 0x10}) | ||
// store.dispatch(actions.handleNewLOC(locModel, 995)) | ||
// expect(store.getActions()).toContainEqual({data: locModel, type: LOC_CREATE}) | ||
// }) | ||
// | ||
// it('should create an action to show what LOC is updated', () => { | ||
// store.dispatch(actions.handleUpdateLOCValue(address, 'issued', 178)) | ||
// expect(store.getActions()).toContainEqual({data: {valueName: 'issued', value: 178, address}, type: LOC_UPDATE}) | ||
// }) | ||
// | ||
// it('should create an action to show what LOC is removed', () => { | ||
// store.dispatch(actions.handleRemoveLOC(address)) | ||
// expect(store.getActions()).toContainEqual({data: {address}, type: LOC_REMOVE}) | ||
// }) | ||
it('should add LOC', async (done) => { | ||
const watchCallback = (loc) => { | ||
const actions = store.getActions() | ||
expect(actions[0].type).toEqual(a.LOC_CREATE) | ||
expect(loc.get('name')).toEqual('loc1') | ||
done() | ||
} | ||
const locManagerDAO = await ContractsManagerDAO.getLOCManagerDAO() | ||
await locManagerDAO.watchNewLOC(watchCallback) | ||
await store.dispatch(a.addLOC(loc1)) | ||
}) | ||
|
||
it('should get LOCs list', async (done) => { | ||
const watchCallback = async () => { | ||
await store.dispatch(a.getLOCs()) | ||
const actions = store.getActions() | ||
|
||
expect(actions[1].type).toEqual(a.LOCS_LIST_FETCH) | ||
expect(actions[2].type).toEqual(a.LOCS_LIST) | ||
expect(actions[2].locs.size).toEqual(1) | ||
|
||
const fetchedLOC = actions[2].locs.get('loc1').toJS() | ||
expect(fetchedLOC.name).toEqual('loc1') | ||
expect(fetchedLOC.website).toEqual('dkchv.ru') | ||
done() | ||
} | ||
|
||
const locManagerDAO = await ContractsManagerDAO.getLOCManagerDAO() | ||
await locManagerDAO.watchNewLOC(watchCallback) | ||
await store.dispatch(a.addLOC(loc1)) | ||
}) | ||
|
||
it.skip('should update LOC', async (done) => { | ||
// 3 | ||
const watchUpdateCallback = (loc) => { | ||
// TODO @dkchv: wrong answer in SC, wait for update | ||
const actions = store.getActions() | ||
expect(actions[1]).toEqual({type: a.LOC_REMOVE, name: loc2.get('oldName')}) | ||
expect(actions[2]).toEqual({type: a.LOC_UPDATE, loc: loc2.isPending(true)}) | ||
expect(loc.get('name')).toEqual('loc2') | ||
expect(loc.get('website')).toEqual('dkchv2.ru') | ||
done() | ||
} | ||
|
||
// 2 | ||
const watchAddCallback = async () => { | ||
await store.dispatch(a.updateLOC(loc2)) | ||
} | ||
|
||
// 1 | ||
const locManagerDAO = await ContractsManagerDAO.getLOCManagerDAO() | ||
await locManagerDAO.watchNewLOC(watchAddCallback) | ||
await locManagerDAO.watchUpdateLOC(watchUpdateCallback) | ||
await store.dispatch(a.addLOC(loc1)) | ||
}) | ||
|
||
// TODO @dkchv: multisig return false | ||
it.skip('should remove LOC', async (done) => { | ||
// 3 catch remove | ||
const watchRemoveCallback = (name) => { | ||
const actions = store.getActions() | ||
expect(actions[2].type).toEqual(a.LOC_REMOVE) | ||
expect(name).toEqual('loc1') | ||
done() | ||
} | ||
// 2 remove | ||
const watchAddCallback = async () => { | ||
await store.dispatch(a.removeLOC(loc1)) | ||
} | ||
// 1 watch and create | ||
const locManagerDAO = await ContractsManagerDAO.getLOCManagerDAO() | ||
await locManagerDAO.watchNewLOC(watchAddCallback) | ||
await locManagerDAO.watchRemoveLOC(watchRemoveCallback) | ||
await store.dispatch(a.addLOC(loc1)) | ||
}) | ||
|
||
// TODO @dkchv: multisig too | ||
it.skip('should issue asset', () => { | ||
|
||
}) | ||
|
||
// TODO @dkchv: multisig too | ||
it.skip('should revoke asset', () => { | ||
|
||
}) | ||
|
||
// TODO @dkchv: multisig too | ||
it.skip('should update status', () => { | ||
|
||
}) | ||
}) |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.