-
Notifications
You must be signed in to change notification settings - Fork 204
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
sovereign chain block unit tests #6675
base: feat/chain-go-sdk
Are you sure you want to change the base?
sovereign chain block unit tests #6675
Conversation
coreComponents, dataComponents, bootstrapComponents, statusComponents := createComponentHolderMocks() | ||
arguments := createSovereignMockArguments(coreComponents, dataComponents, bootstrapComponents, statusComponents) | ||
sovArgs := createArgsSovereignChainBlockProcessor(arguments) |
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.
- Please make a simple func that creates all args for sovereign, which doesn't require any input, like it was before.
- Compress these 3 lines into that function from abive and use it in these tests
return arguments | ||
} | ||
|
||
func createSovereignMockArguments( |
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.
func createSovereignMockArguments( | |
func createShardBlockProcesorArgsForSovereign( |
|
||
headerHandler, err := scbp.CreateNewHeader(round, 1) | ||
require.Nil(t, err) | ||
require.NotNil(t, headerHandler) |
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.
Can we actually check the header with a full &block.Sovereign...
?
|
||
h, err := scbp.CreateNewHeader(round, nonce) | ||
require.Nil(t, err) | ||
require.IsType(t, &block.SovereignChainHeader{}, h) |
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 remark as above, better to check directly with a header
coreComponents, dataComponents, bootstrapComponents, statusComponents := createComponentHolderMocks() | ||
arguments := createSovereignMockArguments(coreComponents, dataComponents, bootstrapComponents, statusComponents) | ||
sovArgs := createArgsSovereignChainBlockProcessor(arguments) | ||
scbp, err := blproc.NewSovereignChainBlockProcessor(sovArgs) |
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 remark regarding only 1 func to create everything
- You can move
scbp, err := blproc.NewSovereignChainBlockProcessor(sovArgs)
outside these tests and reuse that instance
require.Equal(t, process.ErrAccountStateDirty, err) | ||
require.Equal(t, expectedBusyIdleSequencePerCall, busyIdleCalled) | ||
}) | ||
t.Run("create block started should error", func(t *testing.T) { |
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.
Please also mention why you make it fail (e.g. tx coordinator fails bcz...)
scbp, err := blproc.NewSovereignChainBlockProcessor(sovArgs) | ||
require.Nil(t, err) | ||
|
||
doesHaveTime := func() bool { |
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 func can be moved outside these funcs.
} | ||
|
||
hdr, bodyHandler, err := scbp.CreateBlock(sovHeader, doesHaveTime) | ||
require.False(t, check.IfNil(bodyHandler)) |
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.
Check directly with miniblocks and skip using these False.Nil.
Applies also for expected header. If you require it to be equal to your expected object, there is no need to also check it is not nil
require.Equal(t, expectedErr, err) | ||
require.Equal(t, expectedBusyIdleSequencePerCall, busyIdleCalled) | ||
}) | ||
t.Run("should work with sovereign header and epoch start rewriting the epoch value", func(t *testing.T) { |
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.
Please rename this func name, we do not rewrite, I think you mean we change epoch
return true | ||
} | ||
|
||
hdr, bodyHandler, err := scbp.CreateBlock(expectedSovHeader, doesHaveTime) |
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 remarks as above
Reasoning behind the pull request
Proposed changes
CreateNewHeader
fullCreateBlock
partialTesting procedure
Pre-requisites
Based on the Contributing Guidelines the PR author and the reviewers must check the following requirements are met:
feat
branch created?feat
branch merging, do all satellite projects have a proper tag insidego.mod
?