-
Notifications
You must be signed in to change notification settings - Fork 456
Restructure the integration tests for Jest - Closes #3986 #3985
Conversation
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.
This is quite a lot of effort. Thanks nazar.
I just have one concern, I highlighted. Let me know what you think @shuse2 @pablitovicente
@@ -0,0 +1,19 @@ | |||
'use strict'; |
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.
missing licence header
describe('exceptions for senderPublicKey transactions', () => { | ||
describe('send funds to account', () => { | ||
describe('details of the accounts', () => { | ||
describe('when forging block with transaction with collision publicKey', () => { |
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.
I'm just highlighting this line as an example. But In general, please avoid nested describe
blocks as much as possible. The 3 describe blocks above can be merged into one. We can always add more describe blocks when it's really needed.
If we don't do it in this PR, others will follow the same pattern and we'll end up having bunch of redundant describe blocks.
So would be great if we could improve test descriptions by following the rules below,
1 - Each describe
block (except the root one) should start with when.
2 - Each it
should start with should.
3 - We don't need describe blocks which contain only one test. We should add them when it's really needed.
@shuse2 there are 53 files in the PR. I think @nazarhussain mainly copied the testing structure from mocha and wasn't planning to spend more time on it. But I think these refactorings are important and maybe we can assign more people to split the files to write test cases properly.
Let me know what you think.
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.
@yatki I agree to all what you said and related to that I asked @shuse2 to decided on some practices e.g. nested level for describe etc and then individual person working on each tests will follow those.
In this PR, I just extracted the skeleton from existing tests and restructured the files a bit to follow current source structure.
@nazarhussain GJ on the PR. At the end, Im expecting to have the good standard for writing the test description for integration and above that we can follow. However, at the same time, I didn't want to loose the current test scenarios too. |
framework/test/jest/integration/specs/modules/chain/blocks/blocks/on_receive_block.spec.js
Outdated
Show resolved
Hide resolved
framework/test/jest/integration/specs/modules/chain/blocks/blocks/on_receive_block.spec.js
Outdated
Show resolved
Hide resolved
framework/test/jest/integration/specs/modules/chain/blocks/blocks/on_receive_block.spec.js
Outdated
Show resolved
Hide resolved
framework/test/jest/integration/specs/modules/chain/blocks/blocks/on_receive_block.spec.js
Outdated
Show resolved
Hide resolved
framework/test/jest/integration/specs/modules/chain/blocks/blocks/on_receive_block.spec.js
Outdated
Show resolved
Hide resolved
framework/test/jest/integration/specs/modules/chain/blocks/blocks/on_receive_block.spec.js
Outdated
Show resolved
Hide resolved
describe('applyBlock', () => { | ||
describe('applyConfirmedStep', () => { | ||
describe('after applying new block fails', () => { | ||
it.todo('should have pooled transactions in queued state'); |
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.
Maybe combine this in an it
with the describe
above it?
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.
There are multiple specs in this describe, so seems ok to not merge.
framework/test/jest/integration/specs/modules/chain/blocks/chain/delete_last_block.spec.js
Outdated
Show resolved
Hide resolved
'use strict'; | ||
|
||
describe('integration test (blocks) - chain/popLastBlock', () => { | ||
describe('popLastBlock', () => { |
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.
Maybe simplify the level of describes here so we have less levels?
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.
It follows the structure of the code, anyone who implement and refactor the code as well can improve it.
it.todo('should load block 3 from db: block with transactions'); | ||
}); | ||
|
||
describe('loadBlocksOffset() - block/transaction errors', () => { |
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.
Maybe split these into describe('loadBlocksOffset() - block errors')
and describe('loadBlocksOffset() - transaction errors')
?
|
||
it.todo('all blocks should have version = 0'); | ||
|
||
describe('increase block version = 1 and exceptions for height = 5', () => { |
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.
Maybe do not nest this cases and repeat setup for each of the three scenarios?
|
||
'use strict'; | ||
|
||
describe('validateOwnChain', () => { |
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.
Same comment as for framework/test/jest/integration/specs/modules/chain/loader/validate_own_chain/first_round.spec.js
|
||
'use strict'; | ||
|
||
describe('validateOwnChain', () => { |
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.
Same comment as for framework/test/jest/integration/specs/modules/chain/loader/validate_own_chain/first_round.spec.js
|
||
'use strict'; | ||
|
||
describe('validateOwnChain', () => { |
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.
Same comment as for framework/test/jest/integration/specs/modules/chain/loader/validate_own_chain/first_round.spec.js
|
||
'use strict'; | ||
|
||
describe('validateOwnChain', () => { |
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.
Same comment as for framework/test/jest/integration/specs/modules/chain/loader/validate_own_chain/first_round.spec.js
}); | ||
|
||
describe('when forging a new block', () => { | ||
describe('when transaction pool is full and current context (last block height) at forging time, no longer matches the transaction matcher', () => { |
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.
Maybe remove the extra describe? or split in two different describes?
'use strict'; | ||
|
||
describe('rebuilding', () => { | ||
describe('rebuilding to end of round 2 when blockchain contains 303 blocks', () => { |
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.
Maybe remove extra describe or add more scenarios if the idea was that there might be more?
@shuse2 There seems to be a lot of updates going on this PR from different point of view. We should rather first agree on some basic stuff then refactor and review the PR accordingly. e.g. How much nested levels these test should support, should we split tests to different files based on different describe blocks You want to make this refactoring a standard, although for me its vice versa. First we describe some standards or practices then refactor this PR accordingly. In any case, unless we have such coding practices documented anywhere, every individual person can't extract it from looking at test files. |
@pablitovicente @shuse2 @limiaspasdaniel @yatki Feel free to add your commits to the PR directly, so we can close it earliest possible. |
framework/test/jest/integration/specs/modules/chain/rounds.spec.js
Outdated
Show resolved
Hide resolved
framework/test/jest/integration/specs/modules/chain/rounds.spec.js
Outdated
Show resolved
Hide resolved
framework/test/jest/integration/specs/modules/chain/rounds.spec.js
Outdated
Show resolved
Hide resolved
framework/test/jest/integration/specs/modules/chain/rounds.spec.js
Outdated
Show resolved
Hide resolved
framework/test/jest/integration/specs/modules/chain/rounds.spec.js
Outdated
Show resolved
Hide resolved
framework/test/jest/integration/specs/modules/chain/rounds.spec.js
Outdated
Show resolved
Hide resolved
framework/test/jest/integration/specs/modules/chain/rounds.spec.js
Outdated
Show resolved
Hide resolved
framework/test/jest/integration/specs/modules/chain/rounds.spec.js
Outdated
Show resolved
Hide resolved
framework/test/jest/integration/specs/modules/chain/rounds.spec.js
Outdated
Show resolved
Hide resolved
framework/test/jest/integration/specs/modules/chain/rounds.spec.js
Outdated
Show resolved
Hide resolved
framework/test/jest/integration/specs/modules/chain/rounds.spec.js
Outdated
Show resolved
Hide resolved
framework/test/jest/integration/specs/modules/chain/rounds.spec.js
Outdated
Show resolved
Hide resolved
framework/test/jest/integration/specs/modules/chain/rounds.spec.js
Outdated
Show resolved
Hide resolved
framework/test/jest/integration/specs/modules/chain/rounds.spec.js
Outdated
Show resolved
Hide resolved
framework/test/jest/integration/specs/modules/chain/rounds.spec.js
Outdated
Show resolved
Hide resolved
framework/test/jest/integration/specs/modules/chain/rounds.spec.js
Outdated
Show resolved
Hide resolved
framework/test/jest/integration/specs/modules/chain/rounds.spec.js
Outdated
Show resolved
Hide resolved
framework/test/jest/integration/specs/modules/chain/rounds.spec.js
Outdated
Show resolved
Hide resolved
framework/test/jest/integration/specs/modules/chain/rounds.spec.js
Outdated
Show resolved
Hide resolved
framework/test/jest/integration/specs/modules/chain/rounds.spec.js
Outdated
Show resolved
Hide resolved
framework/test/jest/integration/specs/modules/chain/rounds.spec.js
Outdated
Show resolved
Hide resolved
framework/test/jest/integration/specs/modules/chain/rounds.spec.js
Outdated
Show resolved
Hide resolved
framework/test/jest/integration/specs/modules/chain/rounds.spec.js
Outdated
Show resolved
Hide resolved
framework/test/jest/integration/specs/modules/chain/rounds.spec.js
Outdated
Show resolved
Hide resolved
framework/test/jest/integration/specs/modules/chain/rounds.spec.js
Outdated
Show resolved
Hide resolved
framework/test/jest/integration/specs/modules/chain/rounds.spec.js
Outdated
Show resolved
Hide resolved
framework/test/jest/integration/specs/modules/chain/rounds.spec.js
Outdated
Show resolved
Hide resolved
framework/test/jest/integration/specs/modules/chain/rounds.spec.js
Outdated
Show resolved
Hide resolved
framework/test/jest/integration/specs/modules/chain/rounds.spec.js
Outdated
Show resolved
Hide resolved
framework/test/jest/integration/specs/modules/chain/rounds.spec.js
Outdated
Show resolved
Hide resolved
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.
I think we still can continue improving the descriptions. Once we start re-writing the tests we should check again the descriptions to make sure they work as very clear documentation.
What was the problem?
There were old integration tests in "Mocha" which are some what outdated. So instead of fixing those, we decided to rewrite these tests in the Jest, obviously using the much of the code possible from old test.
How did I fix it?
In this PR, we just added the empty skeleton for integration tests.
Review checklist