Skip to content

Commit

Permalink
fix: fix typos and remove comments
Browse files Browse the repository at this point in the history
  • Loading branch information
aimensahnoun committed Apr 16, 2024
1 parent 670523d commit 9b911d4
Showing 1 changed file with 2 additions and 44 deletions.
46 changes: 2 additions & 44 deletions packages/transaction-manager/test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ describe('index', () => {
const ret = await transactionManager.persistTransaction(data, channelId, extraTopics);

const resultConfirmed1 = await new Promise((resolve) => ret.on('confirmed', resolve));
// 'result Confirmed wrong'
expect(resultConfirmed1).toEqual({
meta: {
dataAccessMeta: { transactionStorageLocation: 'fakeDataId', topics: extraTopics },
Expand All @@ -110,9 +109,7 @@ describe('index', () => {
result: {},
});

// 'ret.result is wrong'
expect(ret.result).toEqual({});
// 'ret.meta is wrong'
expect(ret.meta).toEqual({
dataAccessMeta: fakeMetaDataAccessPersistReturn.meta,
encryptionMethod: undefined,
Expand All @@ -133,9 +130,7 @@ describe('index', () => {
TestData.idRaw3.encryptionParams,
]);

// 'ret.result is wrong'
expect(ret.result).toEqual({});
// 'ret.meta is wrong'
expect(ret.meta).toEqual({
dataAccessMeta: fakeMetaDataAccessPersistReturn.meta,
encryptionMethod: 'ecies-aes256-gcm',
Expand All @@ -162,13 +157,10 @@ describe('index', () => {
const ret = await transactionManager.persistTransaction(data, channelId, extraTopics);

ret.on('error', (error) => {
// 'result Confirmed wrong'
expect(error).toBe('error for test purpose');
});

// 'ret.result is wrong'
expect(ret.result).toEqual({});
// 'ret.meta is wrong'
expect(ret.meta).toEqual({
dataAccessMeta: fakeMetaDataAccessPersistReturn.meta,
encryptionMethod: undefined,
Expand All @@ -181,7 +173,7 @@ describe('index', () => {
});
});

describe('in an existing new channel', () => {
describe('in an existing channel', () => {
afterEach(() => {
jest.clearAllMocks();
});
Expand All @@ -190,9 +182,7 @@ describe('index', () => {

const ret = await transactionManager.persistTransaction(data2, channelId, extraTopics);

// 'ret.result is wrong'
expect(ret.result).toEqual({});
// 'ret.meta is wrong'
expect(ret.meta).toEqual({
dataAccessMeta: fakeMetaDataAccessPersistReturn.meta,
encryptionMethod: undefined,
Expand Down Expand Up @@ -243,9 +233,7 @@ describe('index', () => {
);
const ret = await transactionManager.persistTransaction(data2, channelId, extraTopics);

// 'ret.result is wrong'
expect(ret.result).toEqual({});
// 'ret.meta is wrong'
expect(ret.meta).toEqual({
dataAccessMeta: fakeMetaDataAccessPersistReturn.meta,
encryptionMethod: 'ecies-aes256-gcm',
Expand Down Expand Up @@ -332,9 +320,7 @@ describe('index', () => {
TestData.idRaw2.encryptionParams,
]);

// 'ret.result is wrong'
expect(ret.result).toEqual({});
// 'ret.meta is wrong'
expect(ret.meta).toEqual({
dataAccessMeta: fakeMetaDataAccessPersistReturn.meta,
encryptionMethod: 'ecies-aes256-gcm',
Expand Down Expand Up @@ -390,7 +376,7 @@ describe('index', () => {
});
});

describe('in an existing new channel', () => {
describe('in an existing channel', () => {
afterEach(() => {
jest.clearAllMocks();
});
Expand All @@ -400,7 +386,6 @@ describe('index', () => {
const ret = await transactionManager.persistTransaction(data2, channelId, extraTopics);

expect(ret.result).toEqual({});
// 'ret.meta is wrong'
expect(ret.meta).toEqual({
dataAccessMeta: { persisted: false },
encryptionMethod: undefined,
Expand Down Expand Up @@ -520,9 +505,7 @@ describe('index', () => {

const ret = await transactionManager.getTransactionsByChannelId(channelId);

// 'ret.result is wrong'
expect(ret.result).toEqual(fakeMetaDataAccessGetReturn.result);
// 'ret.meta is wrong'
expect(ret.meta).toEqual({
dataAccessMeta: fakeMetaDataAccessGetReturn.meta,
ignoredTransactions: [null, null],
Expand Down Expand Up @@ -558,7 +541,6 @@ describe('index', () => {

const ret = await transactionManager.getTransactionsByChannelId(channelId);

// 'ret.meta is wrong'
expect(ret.meta).toEqual({
dataAccessMeta: fakeMetaDataAccessGetReturnFirstHashWrong.meta,
ignoredTransactions: [
Expand All @@ -571,7 +553,6 @@ describe('index', () => {
],
});

// 'ret.result is wrong'
expect(ret.result).toEqual({
transactions: [null, tx, tx2],
});
Expand Down Expand Up @@ -606,7 +587,6 @@ describe('index', () => {

const ret = await transactionManager.getTransactionsByChannelId(channelId);

// 'ret.meta is wrong'
expect(ret.meta).toEqual({
dataAccessMeta: fakeMetaDataAccessGetReturnFirstHashWrong.meta,
ignoredTransactions: [
Expand All @@ -619,7 +599,6 @@ describe('index', () => {
],
});

// 'ret.result is wrong'
expect(ret.result).toEqual({
transactions: [null, tx, tx2],
});
Expand Down Expand Up @@ -664,7 +643,6 @@ describe('index', () => {
);
const ret = await transactionManager.getTransactionsByChannelId(channelId);

// 'return is wrong'
expect(ret).toEqual({
meta: {
dataAccessMeta: { transactionsStorageLocation: ['fakeDataId1'] },
Expand Down Expand Up @@ -718,7 +696,6 @@ describe('index', () => {
const transactionManager = new TransactionManager(fakeDataAccess);
const ret = await transactionManager.getTransactionsByChannelId(channelId);

// 'return is wrong'
expect(ret).toEqual({
meta: {
dataAccessMeta: { transactionsStorageLocation: ['fakeDataId1'] },
Expand Down Expand Up @@ -881,7 +858,6 @@ describe('index', () => {
);
const ret = await transactionManager.getTransactionsByChannelId(channelId);

// 'return is wrong'
expect(ret).toEqual({
meta: {
dataAccessMeta: {
Expand Down Expand Up @@ -957,7 +933,6 @@ describe('index', () => {
);
const ret = await transactionManager.getTransactionsByChannelId(channelId);

// 'return is wrong'
expect(ret).toEqual({
meta: {
dataAccessMeta: {
Expand Down Expand Up @@ -1036,7 +1011,6 @@ describe('index', () => {

const ret = await transactionManager.getTransactionsByChannelId(channelId);

// 'return is wrong'
expect(ret).toEqual({
meta: {
dataAccessMeta: {
Expand Down Expand Up @@ -1112,7 +1086,6 @@ describe('index', () => {
);
const ret = await transactionManager.getTransactionsByChannelId(channelId);

// 'return is wrong'
expect(ret).toEqual({
meta: {
dataAccessMeta: {
Expand Down Expand Up @@ -1260,7 +1233,6 @@ describe('index', () => {
);
const ret = await transactionManager.getTransactionsByChannelId(channelId);

// 'return is wrong'
expect(ret).toEqual(expectedRet);
});
});
Expand All @@ -1271,9 +1243,7 @@ describe('index', () => {

const ret = await transactionManager.getChannelsByTopic(extraTopics[0]);

// 'ret.result is wrong'
expect(ret.result).toEqual(fakeMetaDataAccessGetChannelsReturn.result);
// 'ret.meta is wrong'
expect(ret.meta).toEqual({
dataAccessMeta: fakeMetaDataAccessGetChannelsReturn.meta,
ignoredTransactions: {
Expand Down Expand Up @@ -1328,13 +1298,11 @@ describe('index', () => {

const ret = await transactionManager.getChannelsByTopic(extraTopics[0]);

// 'ret.result is wrong'
expect(ret.result).toEqual({
transactions: {
[channelId]: [tx],
},
});
// 'ret.meta is wrong'
expect(ret.meta).toEqual({
dataAccessMeta: fakeMetaDataAccessGetReturnWithEncryptedTransaction.meta,
ignoredTransactions: {
Expand Down Expand Up @@ -1386,13 +1354,11 @@ describe('index', () => {

const ret = await transactionManager.getChannelsByTopic(extraTopics[0]);

// 'ret.result is wrong'
expect(ret.result).toEqual({
transactions: {
[channelId]: [null],
},
});
// 'ret.meta is wrong'
expect(ret.meta).toEqual({
dataAccessMeta: fakeMetaDataAccessGetReturnWithEncryptedTransaction.meta,
ignoredTransactions: {
Expand Down Expand Up @@ -1458,7 +1424,6 @@ describe('index', () => {

const ret = await transactionManager.getChannelsByTopic(extraTopics[0]);

// 'ret.result is wrong'
expect(ret.result).toEqual({
transactions: {
[channelId]: [
Expand All @@ -1471,7 +1436,6 @@ describe('index', () => {
],
},
});
// 'ret.meta is wrong'
expect(ret.meta).toEqual({
dataAccessMeta: fakeMetaDataAccessGetReturnWithEncryptedTransaction.meta,
ignoredTransactions: {
Expand Down Expand Up @@ -1520,11 +1484,9 @@ describe('index', () => {

const ret = await transactionManager.getChannelsByTopic(extraTopics[0]);

// 'ret.result is wrong'
expect(ret.result).toEqual({
transactions: { [channelId]: [null, tx, tx2] },
});
// 'ret.meta is wrong'
expect(ret.meta).toEqual({
dataAccessMeta: fakeMetaDataAccessGetReturnFirstHashWrong.meta,
ignoredTransactions: {
Expand Down Expand Up @@ -1595,14 +1557,12 @@ describe('index', () => {

const ret = await transactionManager.getChannelsByTopic(extraTopics[0]);

// 'ret.result is wrong'
expect(ret.result).toEqual({
transactions: {
[channelId]: [tx],
[channelId2]: [tx2],
},
});
// 'ret.meta is wrong'
expect(ret.meta).toEqual({
dataAccessMeta: fakeMetaDataAccessGetReturnWithEncryptedTransaction.meta,
ignoredTransactions: {
Expand All @@ -1620,9 +1580,7 @@ describe('index', () => {

const ret = await transactionManager.getChannelsByMultipleTopics([extraTopics[0]]);

// 'ret.result is wrong'
expect(ret.result).toEqual(fakeMetaDataAccessGetChannelsReturn.result);
// 'ret.meta is wrong'
expect(ret.meta).toEqual({
dataAccessMeta: fakeMetaDataAccessGetChannelsReturn.meta,
ignoredTransactions: {
Expand Down

0 comments on commit 9b911d4

Please sign in to comment.