This repository has been archived by the owner on Jun 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* ⚡ Allow slack in index readiness when scheduling history export jobs * ⚡ Do not re-schedule duplicate jobs * 📝 Improve logging * 🐛 Fix index readiness check logic for export job scheduling * 🐎 Optimize code * 🔨 Refactor code. Prefer early exit from the loop * 🐛 Fix queue config and initialization * 🔨 Automatically se-schedule a job if it timesout * 🔧 Add microservice dependencies for export microservice * 🐎 Optimize genesis asset query * 🔨 Fix broken unit tests * ✔️ Fix unit tests * 🚨 Add new unit tests * 👌 Apply review suggestion * 🔧 Limit indexing pace to assist in app node performance * 🐎 Use lighter endpoint invocations to verify account existence * 🔨 Locally cache genesis token assets at init * ✔️ Fix unit tests * 🔨 Clear any stale intervals * 🎨 Add logs * 🔧 Revert ratelimiting on the indexing jobs * 🔨 Increase query payload size * ✅ Add unit tests * 🐛 Add prefix handling when extracting transactionID from event topics * 🚨 Add more unit tests * 📝 Fix swagger docs --------- Co-authored-by: nagdahimanshu <himanshu.nagda@lightcurve.io>
- Loading branch information
1 parent
559d266
commit a752ea6
Showing
22 changed files
with
1,138 additions
and
145 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 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
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
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
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
156 changes: 156 additions & 0 deletions
156
...ces/blockchain-indexer/tests/unit/shared/dataservice/business/token/accountExists.test.js
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,156 @@ | ||
/* | ||
* LiskHQ/lisk-service | ||
* Copyright © 2024 Lisk Foundation | ||
* | ||
* See the LICENSE file at the top-level directory of this distribution | ||
* for licensing information. | ||
* | ||
* Unless otherwise agreed in a custom licensing agreement with the Lisk Foundation, | ||
* no part of this software, including this file, may be copied, modified, | ||
* propagated, or distributed except according to the terms contained in the | ||
* LICENSE file. | ||
* | ||
* Removal or modification of this copyright notice is prohibited. | ||
* | ||
*/ | ||
|
||
/* eslint-disable import/no-dynamic-require */ | ||
const { resolve } = require('path'); | ||
|
||
const mockRequestFilePath = resolve(`${__dirname}/../../../../../../shared/utils/request`); | ||
const mockTokenAvailableIDsFilePath = resolve( | ||
`${__dirname}/../../../../../../shared/dataService/business/token/availableIDs`, | ||
); | ||
const mockTokenaccountExistsFilePath = resolve( | ||
`${__dirname}/../../../../../../shared/dataService/business/token/accountExists`, | ||
); | ||
const mockValidatorUtilsPath = resolve( | ||
`${__dirname}/../../../../../../shared/dataService/utils/validator`, | ||
); | ||
|
||
beforeEach(() => jest.resetModules()); | ||
|
||
jest.mock('lisk-service-framework', () => { | ||
const actual = jest.requireActual('lisk-service-framework'); | ||
return { | ||
...actual, | ||
DB: { | ||
...actual.DB, | ||
MySQL: { | ||
...actual.DB.MySQL, | ||
KVStore: { | ||
...actual.DB.MySQL.KVStore, | ||
getKeyValueTable: jest.fn(), | ||
}, | ||
}, | ||
}, | ||
CacheRedis: jest.fn(), | ||
CacheLRU: jest.fn(), | ||
}; | ||
}); | ||
|
||
describe('tokenHasUserAccount', () => { | ||
const tokenID = '0000000000000000'; | ||
const accAddressExists = 'lskyvvam5rxyvbvofxbdfcupxetzmqxu22phm4yuo'; | ||
const accAddressNotExists = 'lskz23xokaxhmmkpbzdjt5agcq59qkby7bne2hwpk'; | ||
const name = 'testAccount'; | ||
const publicKey = '3972849f2ab66376a68671c10a00e8b8b67d880434cc65b04c6ed886dfa91c2c'; | ||
|
||
describe('should return isExists true when user account exists', () => { | ||
it('when called with tokenID and address', async () => { | ||
jest.mock(mockRequestFilePath, () => ({ | ||
requestConnector: jest.fn(() => ({ exists: true })), | ||
})); | ||
|
||
// Make a query to tokenHasUserAccount function | ||
const { tokenHasUserAccount } = require(mockTokenaccountExistsFilePath); | ||
const result = await tokenHasUserAccount({ address: accAddressExists, tokenID }); | ||
|
||
expect(result).toEqual({ | ||
data: { | ||
isExists: true, | ||
}, | ||
meta: {}, | ||
}); | ||
}); | ||
|
||
it('when called with tokenID and publicKey', async () => { | ||
jest.mock(mockRequestFilePath, () => ({ | ||
requestConnector: jest.fn(() => ({ exists: true })), | ||
})); | ||
|
||
// Make a query to tokenHasUserAccount function | ||
const { tokenHasUserAccount } = require(mockTokenaccountExistsFilePath); | ||
const result = await tokenHasUserAccount({ publicKey, tokenID }); | ||
expect(result).toEqual({ | ||
data: { | ||
isExists: true, | ||
}, | ||
meta: {}, | ||
}); | ||
}); | ||
|
||
it('when called with tokenID and name', async () => { | ||
jest.mock(mockRequestFilePath, () => ({ | ||
requestConnector: jest.fn(() => ({ exists: true })), | ||
})); | ||
|
||
jest.mock(mockValidatorUtilsPath); | ||
const { getAddressByName } = require(mockValidatorUtilsPath); | ||
getAddressByName.mockReturnValueOnce(accAddressExists); | ||
|
||
// Make a query to tokenHasUserAccount function | ||
const { tokenHasUserAccount } = require(mockTokenaccountExistsFilePath); | ||
const result = await tokenHasUserAccount({ name, tokenID }); | ||
expect(result).toEqual({ | ||
data: { | ||
isExists: true, | ||
}, | ||
meta: {}, | ||
}); | ||
}); | ||
|
||
it('when called with address', async () => { | ||
jest.mock(mockRequestFilePath, () => ({ | ||
requestConnector: jest.fn(() => ({ exists: true })), | ||
})); | ||
|
||
jest.mock(mockTokenAvailableIDsFilePath); | ||
const { getAvailableTokenIDs } = require(mockTokenAvailableIDsFilePath); | ||
getAvailableTokenIDs.mockReturnValueOnce({ | ||
data: { tokenIDs: ['0000000000000000'] }, | ||
meta: {}, | ||
}); | ||
|
||
// Make a query to tokenHasUserAccount function | ||
const { tokenHasUserAccount } = require(mockTokenaccountExistsFilePath); | ||
const result = await tokenHasUserAccount({ address: accAddressExists }); | ||
|
||
expect(result).toEqual({ | ||
data: { | ||
isExists: true, | ||
}, | ||
meta: {}, | ||
}); | ||
}); | ||
}); | ||
|
||
describe('should return isExists false when user account does not exists', () => { | ||
it('when called with tokenID and address', async () => { | ||
jest.mock(mockRequestFilePath, () => ({ | ||
requestConnector: jest.fn(() => ({ exists: false })), | ||
})); | ||
|
||
// Make a query to tokenHasUserAccount function | ||
const { tokenHasUserAccount } = require(mockTokenaccountExistsFilePath); | ||
const result = await tokenHasUserAccount({ address: accAddressNotExists, tokenID }); | ||
|
||
expect(result).toEqual({ | ||
data: { | ||
isExists: false, | ||
}, | ||
meta: {}, | ||
}); | ||
}); | ||
}); | ||
}); |
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.