wallet-storage
Version:
BRC100 conforming wallet, wallet storage and wallet signer components
118 lines • 5.61 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const TestUtilsWalletStorage_1 = require("../utils/TestUtilsWalletStorage");
const StorageKnex_1 = require("../../src/storage/StorageKnex");
describe('count tests', () => {
jest.setTimeout(99999999);
const storages = [];
const chain = 'test';
const setups = [];
const env = TestUtilsWalletStorage_1._tu.getEnv(chain);
beforeAll(async () => {
const localSQLiteFile = await TestUtilsWalletStorage_1._tu.newTmpFile('storagecounttest.sqlite', false, false, true);
const knexSQLite = TestUtilsWalletStorage_1._tu.createLocalSQLite(localSQLiteFile);
storages.push(new StorageKnex_1.StorageKnex({ ...StorageKnex_1.StorageKnex.defaultOptions(), chain, knex: knexSQLite }));
if (!env.noMySQL) {
const knexMySQL = TestUtilsWalletStorage_1._tu.createLocalMySQL('storagecounttest');
storages.push(new StorageKnex_1.StorageKnex({ ...StorageKnex_1.StorageKnex.defaultOptions(), chain, knex: knexMySQL }));
}
for (const storage of storages) {
await storage.dropAllData();
await storage.migrate('insert tests', '1'.repeat(64));
setups.push({ storage, setup: await TestUtilsWalletStorage_1._tu.createTestSetup1(storage) });
}
});
afterAll(async () => {
for (const storage of storages) {
await storage.destroy();
}
});
test('0 count ProvenTx', async () => {
for (const { storage, setup } of setups) {
expect(await storage.countProvenTxs({ partial: {} })).toBe(1);
}
});
test('1 count ProvenTxReq', async () => {
for (const { storage, setup } of setups) {
expect(await storage.countProvenTxReqs({ partial: {} })).toBe(2);
}
});
test('2 count User', async () => {
for (const { storage, setup } of setups) {
expect(await storage.countUsers({ partial: {} })).toBe(2);
}
});
test('3 count Certificate', async () => {
for (const { storage, setup } of setups) {
expect(await storage.countCertificates({ partial: {} })).toBe(3);
expect(await storage.countCertificates({ partial: {}, certifiers: [setup.u1cert1.certifier] })).toBe(1);
expect(await storage.countCertificates({ partial: {}, certifiers: ['none'] })).toBe(0);
expect(await storage.countCertificates({ partial: {}, types: [setup.u1cert2.type] })).toBe(1);
expect(await storage.countCertificates({ partial: {}, types: ['oblongata'] })).toBe(0);
}
});
test('4 count CertificateField', async () => {
for (const { storage, setup } of setups) {
expect(await storage.countCertificateFields({ partial: {} })).toBe(3);
expect(await storage.countCertificateFields({ partial: { userId: setup.u1.userId } })).toBe(3);
expect(await storage.countCertificateFields({ partial: { userId: setup.u2.userId } })).toBe(0);
expect(await storage.countCertificateFields({ partial: { userId: 99 } })).toBe(0);
expect(await storage.countCertificateFields({ partial: { fieldName: "name" } })).toBe(2);
expect(await storage.countCertificateFields({ partial: { fieldName: "bob" } })).toBe(1);
expect(await storage.countCertificateFields({ partial: { fieldName: "bob42" } })).toBe(0);
}
});
test('5 count OutputBasket', async () => {
for (const { storage, setup } of setups) {
expect(await storage.countOutputBaskets({ partial: {} })).toBe(3);
expect(await storage.countOutputBaskets({ partial: {}, since: setup.u1.created_at })).toBe(3);
expect(await storage.countOutputBaskets({ partial: {}, since: new Date() })).toBe(0);
}
});
test('6 count Transaction', async () => {
for (const { storage, setup } of setups) {
expect(await storage.countTransactions({ partial: {} })).toBe(3);
}
});
test('7 count Commission', async () => {
for (const { storage, setup } of setups) {
expect(await storage.countCommissions({ partial: {} })).toBe(3);
}
});
test('8 count Output', async () => {
for (const { storage, setup } of setups) {
expect(await storage.countOutputs({ partial: {} })).toBe(3);
}
});
test('9 count OutputTag', async () => {
for (const { storage, setup } of setups) {
expect(await storage.countOutputTags({ partial: {} })).toBe(2);
}
});
test('10 count OutputTagMap', async () => {
for (const { storage, setup } of setups) {
expect(await storage.countOutputTagMaps({ partial: {} })).toBe(3);
}
});
test('11 count TxLabel', async () => {
for (const { storage, setup } of setups) {
expect(await storage.countTxLabels({ partial: {} })).toBe(3);
}
});
test('12 count TxLabelMap', async () => {
for (const { storage, setup } of setups) {
expect(await storage.countTxLabelMaps({ partial: {} })).toBe(3);
}
});
test('13 count MonitorEvent', async () => {
for (const { storage, setup } of setups) {
expect(await storage.countMonitorEvents({ partial: {} })).toBe(1);
}
});
test('14 count SyncState', async () => {
for (const { storage, setup } of setups) {
expect(await storage.countSyncStates({ partial: {} })).toBe(1);
}
});
});
//# sourceMappingURL=count.test.js.map