Skip to content

Commit 97fbc23

Browse files
Merge pull request #840 from HathorNetwork/master
Release v2.2.0
2 parents b405690 + 6dedc79 commit 97fbc23

32 files changed

+2153
-3213
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@ lib
1010
tsconfig.tsbuildinfo
1111

1212
// Generated test database files
13-
*.leveldb
13+
*.leveldb*
14+
tmp/

__tests__/__mock_helpers__/wallet-service.fixtures.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import Network from '../../src/models/network';
22
import HathorWalletServiceWallet from '../../src/wallet/wallet';
3+
import { JSONBigInt } from '../../src/utils/bigint';
34

45
export const defaultWalletSeed =
56
'purse orchard camera cloud piece joke hospital mechanic timber horror shoulder rebuild you decrease garlic derive rebuild random naive elbow depart okay parrot cliff';
67
export const buildSuccessTxByIdTokenDataResponse = (): string => {
78
const txTokens = [
89
{
9-
balance: 10,
10+
balance: 10n,
1011
height: 1,
1112
timestamp: 10,
1213
tokenId: 'token1',
@@ -18,7 +19,7 @@ export const buildSuccessTxByIdTokenDataResponse = (): string => {
1819
weight: 65.4321,
1920
},
2021
{
21-
balance: 7,
22+
balance: 7n,
2223
height: 1,
2324
timestamp: 10,
2425
tokenId: 'token2',
@@ -30,7 +31,7 @@ export const buildSuccessTxByIdTokenDataResponse = (): string => {
3031
weight: 65.4321,
3132
},
3233
];
33-
return JSON.stringify({
34+
return JSONBigInt.stringify({
3435
success: true,
3536
txTokens,
3637
});

__tests__/integration/storage/leveldb.test.ts

Lines changed: 0 additions & 83 deletions
This file was deleted.

__tests__/integration/storage/storage.test.ts

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ import {
1212
import HathorWallet from '../../../src/new/wallet';
1313
import { loggers } from '../utils/logger.util';
1414
import SendTransaction from '../../../src/new/sendTransaction';
15-
import { LevelDBStore, MemoryStore, Storage } from '../../../src/storage';
16-
import walletUtils from '../../../src/utils/wallet';
15+
import { MemoryStore, Storage } from '../../../src/storage';
1716
import transactionUtils from '../../../src/utils/transaction';
1817
import { NATIVE_TOKEN_UID } from '../../../src/constants';
1918
import { IHathorWallet } from '../../../src/wallet/types';
@@ -101,17 +100,6 @@ describe('locked utxos', () => {
101100
const storeMem = new MemoryStore();
102101
const storageMem = new Storage(storeMem);
103102
await testUnlockWhenSpent(storageMem, walletDataMem);
104-
105-
// LevelDB test
106-
const DATA_DIR = './testdata.leveldb';
107-
const walletDataLDB = precalculationHelpers.test.getPrecalculatedWallet();
108-
const xpubkeyLDB = walletUtils.getXPubKeyFromSeed(walletDataLDB.words, {
109-
accountDerivationIndex: "0'/0",
110-
});
111-
const walletId = walletUtils.getWalletIdFromXPub(xpubkeyLDB);
112-
const storeLDB = new LevelDBStore(walletId, DATA_DIR);
113-
const storageLDB = new Storage(storeLDB);
114-
await testUnlockWhenSpent(storageLDB, walletDataLDB);
115103
});
116104
});
117105

__tests__/storage/common_store.test.ts

Lines changed: 4 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,9 @@
55
* LICENSE file in the root directory of this source tree.
66
*/
77

8-
import { HDPrivateKey } from 'bitcore-lib';
9-
import { LevelDBStore, MemoryStore, Storage } from '../../src/storage';
8+
import { MemoryStore, Storage } from '../../src/storage';
109
import { TOKEN_AUTHORITY_MASK, TOKEN_MINT_MASK, GAP_LIMIT } from '../../src/constants';
11-
import walletUtils from '../../src/utils/wallet';
12-
import { ILockedUtxo, IUtxo, OutputValueType } from '../../src/types';
13-
14-
const DATA_DIR = './testdata.leveldb';
10+
import { ILockedUtxo, IStore, IUtxo, OutputValueType } from '../../src/types';
1511

1612
describe('locked utxo methods', () => {
1713
const spyDate = jest.spyOn(Date, 'now');
@@ -33,16 +29,9 @@ describe('locked utxo methods', () => {
3329
await testLockedUtxoMethods(store);
3430
});
3531

36-
it('should work with leveldb store', async () => {
37-
const xpriv = new HDPrivateKey();
38-
const walletId = walletUtils.getWalletIdFromXPub(xpriv.xpubkey);
39-
const store = new LevelDBStore(walletId, DATA_DIR);
40-
await testLockedUtxoMethods(store);
41-
});
42-
4332
// helper functions
4433

45-
async function countUtxos(store: LevelDBStore) {
34+
async function countUtxos(store: IStore) {
4635
let utxoCount = 0;
4736
let lutxoCount = 0;
4837
for await (const _ of store.utxoIter()) {
@@ -115,7 +104,7 @@ describe('locked utxo methods', () => {
115104

116105
// actual test body
117106

118-
async function testLockedUtxoMethods(store: LevelDBStore) {
107+
async function testLockedUtxoMethods(store: IStore) {
119108
const lockedUtxos = [
120109
// utxo to be unlocked by time
121110
getLockedUtxo(
@@ -190,13 +179,6 @@ describe('registered tokens', () => {
190179
await testRegisteredTokens(store);
191180
});
192181

193-
it('should work with leveldb store', async () => {
194-
const xpriv = new HDPrivateKey();
195-
const walletId = walletUtils.getWalletIdFromXPub(xpriv.xpubkey);
196-
const store = new LevelDBStore(walletId, DATA_DIR);
197-
await testRegisteredTokens(store);
198-
});
199-
200182
async function testRegisteredTokens(store) {
201183
const storage = new Storage(store);
202184
await storage.registerToken({ uid: 'abc1', name: 'test token 1', symbol: 'TST1' });
@@ -211,13 +193,6 @@ describe('scanning policy methods', () => {
211193
await testScanningPolicies(store);
212194
});
213195

214-
it('should work with leveldb store', async () => {
215-
const xpriv = new HDPrivateKey();
216-
const walletId = walletUtils.getWalletIdFromXPub(xpriv.xpubkey);
217-
const store = new LevelDBStore(walletId, DATA_DIR);
218-
await testScanningPolicies(store);
219-
});
220-
221196
async function testScanningPolicies(store) {
222197
const storage = new Storage(store);
223198
// Default is gap-limit

0 commit comments

Comments
 (0)