Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Database and storage refactoring #177

Merged
merged 20 commits into from Apr 22, 2020
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 0 additions & 75 deletions __mocks__/Database.ts

This file was deleted.

28 changes: 14 additions & 14 deletions __mocks__/Wallets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import {SimpleWallet, Account, NetworkType, Password} from 'symbol-sdk';

// internal dependencies
import {WalletsModel, WalletType} from '@/core/database/entities/WalletsModel';
import {WalletModel, WalletType} from '@/core/database/entities/WalletModel';

export const wallet1Params = {
walletName: 'wallet_name',
Expand All @@ -37,16 +37,16 @@ export const simpleWallet1 = SimpleWallet.createFromPrivateKey(
wallet1Params.networkType,
)

export const WalletsModel1 = new WalletsModel(
new Map<string, any>([
['accountName', 'account_name'],
['name', wallet1Params.walletName],
['type', WalletType.fromDescriptor('Pk')],
['address', simpleWallet1.address.plain()],
['publicKey', wallet1Account.publicKey],
['encPrivate', simpleWallet1.encryptedPrivateKey.encryptedKey],
['encIv', simpleWallet1.encryptedPrivateKey.iv],
['path', ''],
['isMultisig', false],
])
)
export const WalletsModel1: WalletModel = {
id: 'someId',
node: '',
accountName: 'account_name',
name: wallet1Params.walletName,
type: WalletType.PRIVATE_KEY,
address: simpleWallet1.address.plain(),
publicKey: wallet1Account.publicKey,
encPrivate: simpleWallet1.encryptedPrivateKey.encryptedKey,
encIv: simpleWallet1.encryptedPrivateKey.iv,
path: '',
isMultisig: false
}
28 changes: 14 additions & 14 deletions __tests__/components/MosaicInputManager.spec.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
import {Mosaic, MosaicId, UInt64} from 'symbol-sdk'
import {MosaicInputsManager} from '@/views/forms/FormTransferTransaction/MosaicInputsManager.ts'
import {MosaicModel} from '@/core/database/entities/MosaicModel'

export const mockMosaic1 = new Mosaic(
new MosaicId('619CE7E50DB644DE'),
UInt64.fromUint(1),
)
export const mockMosaic1: MosaicModel = {
mosaicIdHex: '619CE7E50DB644DE',
balance: 1,
} as MosaicModel

export const mockMosaic2 = new Mosaic(
new MosaicId('28A59CC8B0C9E4DD'),
UInt64.fromUint(1),
)
export const mockMosaic2: MosaicModel = {
mosaicIdHex: '28A59CC8B0C9E4DD',
balance: 1,
} as MosaicModel

export const mockMosaic3 = new Mosaic(
new MosaicId('2D58F9BF5F8C014D'),
UInt64.fromUint(1),
)
export const mockMosaic3: MosaicModel = {
mosaicIdHex: '2D58F9BF5F8C014D',
balance: 1,
} as MosaicModel

const mockMosaics = [ mockMosaic1, mockMosaic2, mockMosaic3 ]
const mockMosaicHexIds = mockMosaics.map(({id}) => id.toHex())
const mockMosaicHexIds = mockMosaics.map(({mosaicIdHex}) => mosaicIdHex)

describe('components/MosaicInputManager', () => {
describe('initialize() should', () => {
Expand Down
28 changes: 6 additions & 22 deletions __tests__/components/WalletSelectorField.spec.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,24 @@
/**
* Copyright 2020 NEM Foundation (https://nem.io)
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*
* http://www.apache.org/licenses/LICENSE-2.0
*
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// internal dependencies
import {getFakeModel, getAdapter} from '@MOCKS/Database'
import {getComponent} from '@MOCKS/Components'
import WalletStore from '@/store/Wallet'

// @ts-ignore
import WalletSelectorField from '@/components/WalletSelectorField/WalletSelectorField.vue'
import {WalletService} from '@/services/WalletService'
import {WalletModel} from '@/core/database/entities/WalletModel'

describe('components/WalletSelectorField', () => {
describe('getter for property "currentWalletIdentifier" should', () => {
Expand All @@ -41,9 +39,9 @@ describe('components/WalletSelectorField', () => {

test('return wallet identifier given value', () => {
// prepare
const wallet = getFakeModel('5678')
const wallet = {id: '5678'} as WalletModel
const wrapper = getComponent(WalletSelectorField, {wallet: WalletStore}, {}, {
value: wallet.getIdentifier(),
value: wallet.id,
})
const component = (wrapper.vm as WalletSelectorField)

Expand All @@ -68,20 +66,6 @@ describe('components/WalletSelectorField', () => {
expect(wrapper.vm.$store.dispatch).not.toHaveBeenCalled()
})

test('dispatch "notification/ADD_ERROR" given invalid identifier', () => {
// prepare
const wrapper = getComponent(WalletSelectorField, {wallet: WalletStore}, {})
const service = new WalletService(wrapper.vm.$store, getAdapter())
const component = (wrapper.vm as WalletSelectorField)
component.service = service

// act
component.currentWalletIdentifier = '1234' // wallet identifier does not exist
expect(component.$store.dispatch).toHaveBeenCalledWith(
'notification/ADD_ERROR',
'Wallet with identifier \'1234\' does not exist.',
)
})
})

describe('getter for property "currentWallets" should', () => {
Expand Down
160 changes: 0 additions & 160 deletions __tests__/database/BaseStorageAdapter.spec.ts

This file was deleted.

Loading