-
Notifications
You must be signed in to change notification settings - Fork 2
refactor: remove unused lambdas #155
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
Conversation
73e4c9f
to
cd595af
Compare
37f1d0b
to
3dbe90c
Compare
5f652ad
to
f047ece
Compare
3dbe90c
to
7e3603c
Compare
await expect(checkAddressBalanceTable(mysql, 4, 'address2', '00', 0, blockReward, null, 1)).resolves.toBe(true); | ||
}); | ||
|
||
test.skip('txProcessor should be able to re-process txs that were voided in the past', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the new daemon we don't need to re-process transactions, we now handle the metadataChanged
event and void the utxos as needed. We have tests for this in packages/daemon/__tests__/services/services.test.ts
@@ -152,44 +152,6 @@ afterAll(async () => { | |||
process.env = OLD_ENV; | |||
}); | |||
|
|||
// eslint-disable-next-line jest/prefer-expect-assertions, jest/expect-expect | |||
test('receive blocks and txs and then start wallet', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't have tests for this, need to create tests that use both the lambdas and the daemon
@@ -248,274 +210,3 @@ test('load wallet, and simulate DLQ event', async () => { | |||
expect.any(Logger), | |||
); | |||
}, 60000); | |||
|
|||
// eslint-disable-next-line jest/prefer-expect-assertions, jest/expect-expect | |||
test('start wallet and then receive blocks and txs', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't have tests for this, need to create tests that use both the lambdas and the daemon
}, 60000); | ||
|
||
// eslint-disable-next-line jest/prefer-expect-assertions, jest/expect-expect | ||
test('receive blocks, start wallet and then receive transactions', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't have tests for this, need to create tests that use both the lambdas and the daemon
}, 35000); | ||
|
||
// eslint-disable-next-line jest/prefer-expect-assertions, jest/expect-expect | ||
test('receive blocks and tx1, start wallet and then receive tx2', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't have tests for this, need to create tests that use both the lambdas and the daemon
}, 35000); | ||
|
||
// eslint-disable-next-line jest/prefer-expect-assertions, jest/expect-expect | ||
test('receive blocks fom 3 different miners, check miners list', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are not testing this in the new daemon, we should
/* | ||
* In an unlikely scenario, we can receive a tx spending a UTXO that is still marked as locked. | ||
*/ | ||
test.skip('spend "locked" utxo', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're handling transactions differently, we receive them in order, so this will never happen
await expect(checkWalletBalanceTable(mysql, 1, walletId, token, 2000, 0, null, 2)).resolves.toBe(true); | ||
}); | ||
|
||
test.skip('Genesis transactions should throw', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We now handle transactions differently, this test has no use anymore
/* | ||
* receive some transactions and blocks and make sure database is correct | ||
*/ | ||
test.skip('txProcessor', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have integration tests that run the simulation in the fullnode and check if balances are correct after a full sync which is way better than mocking it. So no need to re-implement this test.
)).toStrictEqual(true); | ||
}); | ||
|
||
test.skip('txProcessor should ignore NFT outputs', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are still ignoring NFT outputs, but have no tests for this case, we should add it
@@ -515,300 +93,3 @@ describe('NFT metadata updating', () => { | |||
spyCreateOrUpdate.mockRestore(); | |||
}); | |||
}); | |||
|
|||
test.skip('receive token creation tx', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We also need to add this one, we're adding token information into the tokens
table, but not testing it.
Maybe an integration test with token creation simulations.
expect(tokenInfo.symbol).toBe(tokenCreationTx.token_symbol); | ||
}); | ||
|
||
test.skip('onHandleVoidedTxRequest', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We handle voided transactions differently now, this lambda is dead.
await expect(checkAddressBalanceTable(mysql, 2, addr, token, 2500, 0, null, 1)).resolves.toBe(true); | ||
}, 20000); | ||
|
||
test.skip('txProcessor should rollback the entire transaction if an error occurs on balance calculation', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are still rolling back when we fail to process a message, but now on different methods — handleVoidedTx
, handleVertexAccepted
, handleUnvoidedTx
We should re-create this test for all of them
await expect(checkAddressBalanceTable(mysql, 1, 'address1', '00', blockReward * 4, blockReward, null, 5)).resolves.toBe(true); | ||
}); | ||
|
||
test.skip('txProcess onNewTxRequest with push notification', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The daemon now simply calls the push notification lambda, but we don't have tests for it, we should add it
expect(invokeOnTxPushNotificationRequestedLambdaMock).toHaveBeenCalledTimes(1); | ||
}); | ||
|
||
test.skip('onNewTxRequest should send alert on SQS on failure', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are dealing with events differently now, but we're not sending an alert with rich metadata when the daemon stops. We should refactor the daemon to add an alert directly to SQS (instead of just logging the error) and add a test for it.
0de6578
to
a951693
Compare
7e3603c
to
3779b1e
Compare
* feat: added nft utils * tests: added tests for common utils * chore: added common module to CI * refactor: moved used types to common package * tests: removed nft utils * tests: fixed nft tests on txProcessor * tests: mocking network on getconfig * tests: fixed nft tests on txProcessor * refactor: passing logger to invoke nft handler * refactor: no need to ignore ts * chore: removed jest script, instead using only test * chore: added hathor header * refactor: using common utils on txProcessor * tests: nft utils using old syntax * tests: skipped txProcessor tests * tests: fixed txProcessor tests * refactor: using isAuthority from common utils * refactor: using isAuthority from common types * refactor: using assertEnvVariablesExistance from common project * refactor: getting CREATE_NFT_MAX_RETRIES from env * docs: updated docstrings on nft utils * chore: removed events/nftCreationTx.ts * refactor: invalid import locations * refactor: remove unused lambdas (#155) * tests: fixed nft tests on txProcessor * refactor: removed all methods related to the old wallet-service txProcessor
* feat: added nft utils * tests: added tests for common utils * chore: added common module to CI * refactor: moved used types to common package * tests: removed nft utils * tests: fixed nft tests on txProcessor * tests: mocking network on getconfig * tests: fixed nft tests on txProcessor * refactor: passing logger to invoke nft handler * refactor: no need to ignore ts * chore: removed jest script, instead using only test * chore: added hathor header * refactor: using common utils on txProcessor * tests: nft utils using old syntax * tests: skipped txProcessor tests * tests: fixed txProcessor tests * refactor: using isAuthority from common utils * refactor: using isAuthority from common types * refactor: using assertEnvVariablesExistance from common project * refactor: getting CREATE_NFT_MAX_RETRIES from env * docs: updated docstrings on nft utils * chore: removed events/nftCreationTx.ts * refactor: invalid import locations * refactor: remove unused lambdas (#155) * tests: fixed nft tests on txProcessor * refactor: removed all methods related to the old wallet-service txProcessor
* feat: added nft utils * tests: added tests for common utils * chore: added common module to CI * refactor: moved used types to common package * tests: removed nft utils * tests: fixed nft tests on txProcessor * tests: mocking network on getconfig * tests: fixed nft tests on txProcessor * refactor: passing logger to invoke nft handler * refactor: no need to ignore ts * chore: removed jest script, instead using only test * chore: added hathor header * refactor: using common utils on txProcessor * tests: nft utils using old syntax * tests: skipped txProcessor tests * tests: fixed txProcessor tests * refactor: using isAuthority from common utils * refactor: using isAuthority from common types * refactor: using assertEnvVariablesExistance from common project * refactor: getting CREATE_NFT_MAX_RETRIES from env * docs: updated docstrings on nft utils * chore: removed events/nftCreationTx.ts * refactor: invalid import locations * refactor: remove unused lambdas (#155) * tests: fixed nft tests on txProcessor * refactor: removed all methods related to the old wallet-service txProcessor
* feat: added nft utils * tests: added tests for common utils * chore: added common module to CI * refactor: moved used types to common package * tests: removed nft utils * tests: fixed nft tests on txProcessor * tests: mocking network on getconfig * tests: fixed nft tests on txProcessor * refactor: passing logger to invoke nft handler * refactor: no need to ignore ts * chore: removed jest script, instead using only test * chore: added hathor header * refactor: using common utils on txProcessor * tests: nft utils using old syntax * tests: skipped txProcessor tests * tests: fixed txProcessor tests * refactor: using isAuthority from common utils * refactor: using isAuthority from common types * refactor: using assertEnvVariablesExistance from common project * refactor: getting CREATE_NFT_MAX_RETRIES from env * docs: updated docstrings on nft utils * chore: removed events/nftCreationTx.ts * refactor: invalid import locations * refactor: remove unused lambdas (#155) * tests: fixed nft tests on txProcessor * refactor: removed all methods related to the old wallet-service txProcessor
* feat: added nft utils * tests: added tests for common utils * chore: added common module to CI * refactor: moved used types to common package * tests: removed nft utils * tests: fixed nft tests on txProcessor * tests: mocking network on getconfig * tests: fixed nft tests on txProcessor * refactor: passing logger to invoke nft handler * refactor: no need to ignore ts * chore: removed jest script, instead using only test * chore: added hathor header * refactor: using common utils on txProcessor * tests: nft utils using old syntax * tests: skipped txProcessor tests * tests: fixed txProcessor tests * refactor: using isAuthority from common utils * refactor: using isAuthority from common types * refactor: using assertEnvVariablesExistance from common project * refactor: getting CREATE_NFT_MAX_RETRIES from env * docs: updated docstrings on nft utils * chore: removed events/nftCreationTx.ts * refactor: invalid import locations * refactor: remove unused lambdas (#155) * tests: fixed nft tests on txProcessor * refactor: removed all methods related to the old wallet-service txProcessor
* chore: added common package * chore: using wallet-lib from daemon resolution * chore: installed shared dependencies on root project, using peerDependencies * refactor: using addAlert method from common utils * chore: updated package.json with missing deps * refactor: using types from commons on wallet-service * chore: re-added sequelize to root * refactor: removed isNftAutoReviewEnabled from services * tests: mocked assertEnv * tests: mocked assertEnv on integration tests * chore: removed nft utils * refactor: removed old addAlerts from the wallet-service package * chore: wallet-lib is now a peerDependency in wallet-service package * refactor: logger is now a required param in addAlert, refactored all methods in wallet-service package * docs: added missing hathor header * refactor: invalid type for metadata on addAlert * tests: passing mocked logger * chore: updated gitignore to ignore env files * chore: revert eslint package updates * refactor: using types from commons on wallet-service * refactor: removed unused commented line * chore: missing package in daemon * refactor: using transaction type from common * refactor: bitcoinjs is not a shared dep * chore: added a comment explaining that logger is a param temporarily * refactor: removed default from metadata * chore: lint fixes and package ordering * feat: call onNewNftEvent when a new NFT tx is received (#150) * feat: added nft utils * tests: added tests for common utils * chore: added common module to CI * refactor: moved used types to common package * tests: removed nft utils * tests: fixed nft tests on txProcessor * tests: mocking network on getconfig * tests: fixed nft tests on txProcessor * refactor: passing logger to invoke nft handler * refactor: no need to ignore ts * chore: removed jest script, instead using only test * chore: added hathor header * refactor: using common utils on txProcessor * tests: nft utils using old syntax * tests: skipped txProcessor tests * tests: fixed txProcessor tests * refactor: using isAuthority from common utils * refactor: using isAuthority from common types * refactor: using assertEnvVariablesExistance from common project * refactor: getting CREATE_NFT_MAX_RETRIES from env * docs: updated docstrings on nft utils * chore: removed events/nftCreationTx.ts * refactor: invalid import locations * refactor: remove unused lambdas (#155) * tests: fixed nft tests on txProcessor * refactor: removed all methods related to the old wallet-service txProcessor * tests: fixed failing test * fix: serverless failing (#162) * refactor: logger is now a required param in addAlert, refactored all methods in wallet-service package * chore: changed module resolution and several package locks * chore: added common library to externals whitelist and whitelisted it in tsloader * chore: wallet-service common package moved from direct path to workspace * chore: added common as a peer dependency and restored peer dependencies * chore: removed peer dependencies as they were not working with serverless-monorepo * chore: added comment on hoisting limits * chore: added comment explaining externals in webpack
Motivation
Acceptance Criteria
Checklist
master
, confirm this code is production-ready and can be included in future releases as soon as it gets merged