-
Notifications
You must be signed in to change notification settings - Fork 95
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
Refactoring integration tests #830
Refactoring integration tests #830
Conversation
aea4982
to
0c0e0b5
Compare
50edd30
to
2c4223a
Compare
eebddfe
to
e05c34a
Compare
e05c34a
to
74a966e
Compare
fix require outputs
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.
some high level comments. was curious about code changes outside of integration test directory, if they are needed/intended to be in this PR
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 fix linting errors
Co-authored-by: aaron-blox <123868031+aaron-blox@users.noreply.github.com>
|
||
duty := createDuty(getKeySet(s.Committee).ValidatorPK.Serialize(), dutyProp.Slot, dutyProp.ValidatorIndex, role) | ||
require.NoError(t, s.validators[id].StartDuty(duty)) | ||
}(id, dutyProp) |
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.
why not add to queue? in order to mock real behaviour
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.
@egorka-sereda @aaron-blox this is 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.
is resolved
// logging stored instance | ||
jsonInstance, err := json.Marshal(storedInstance) | ||
require.NoError(t, err) | ||
fmt.Println(string(jsonInstance)) |
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.
need to print 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.
yeah, for debugging purposes
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.
@egorka-sereda @aaron-blox not sure we need to print the instance.
maybe we can print just the state, or add some debug logging to tests for debug
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.
is resolved
panic(err) | ||
} | ||
|
||
store := qbftstorage.New(db, logger, "integration-tests", protocolforks.GenesisForkVersion) |
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 prefix should be based on the role type and not "integration-tests"
so need to have different instance for each role type
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.
resolved
// logging stored instance | ||
jsonInstance, err := json.Marshal(storedInstance) | ||
require.NoError(t, err) | ||
fmt.Println(string(jsonInstance)) |
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.
@egorka-sereda @aaron-blox not sure we need to print the instance.
maybe we can print just the state, or add some debug logging to tests for debug
} | ||
|
||
func getKeySet(committee int) *spectestingutils.TestKeySet { | ||
switch committee { |
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.
@aaron-blox lets use here just the 3f+1 rule. and max to 13
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.
sometimes we need different number of participants than 4, 7, 10, 13
for example in f+1 decided we want to launch only 3 validators, but we need keysets for them as for 4 validators-committee
} | ||
|
||
func quorum(committee int) int { | ||
return (committee*2 + 1) / 3 // committee = 3f+1; quorum = 2f+1 // https://drive.google.com/file/d/1bP_MLq0MM7ZBSR0Ddh7HUPcc42vVUKwz/view?usp=share_link |
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.
lets remove google drive links.
If we feel we need it then add readme and resource folder in the integration folder
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.
resolved
@@ -0,0 +1,111 @@ | |||
package tests |
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.
@aaron-blox while this is still WIP, lets remove from the github actions to run integration tests until they are stable.
you can create a regex rule to run it if the branch starts/ends with integration-test
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.
resolved
fixed all comments |
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 added a suggestion to change the comment but LGTM otherwise
Co-authored-by: aaron-blox <123868031+aaron-blox@users.noreply.github.com>
require.Fail(t, "no commit qourum") | ||
} | ||
|
||
require.Equal(t, int(spectypes.OperatorID(2)), int(actual.State.ProposeContainer.Msgs[2][0].Signers[0])) //on second round proposer is 2, |
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.
you should add checks before doing slice access for everything here
actual.State.ProposeContainer.Msgs[2][0].Signers[0]
Each of these can cause a panic if you are trying to access something that does not exist, which can happen when the test fails
…nto refactoring-integration-tests
branches: | ||
- "main" | ||
- "stage" | ||
# push: |
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.
if no need, let's remove
require.Equal(t, int(qbft.FirstRound), int(actual.State.Round), "round not matching") | ||
|
||
require.NotNil(t, actual.DecidedMessage, "no decided message") | ||
if quorum(committee) > len(actual.DecidedMessage.Signers) { |
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.
you can use require.Greater() instead
require.Equal(t, int(qbft.Round(2)), int(actual.State.Round), "round not matching") | ||
|
||
require.NotNil(t, actual.DecidedMessage, "no decided message") | ||
if quorum(committee) > len(actual.DecidedMessage.Signers) { |
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.
you can use require.Greater() instead
panic(err) | ||
} | ||
|
||
store := qbftstorage.New(db, logger, role.String(), protocolforks.GenesisForkVersion) |
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.
need to create store for each role.
reference - operator/node.go:91
integration/qbft/tests/setup_test.go
Outdated
} | ||
|
||
func GetSharedData(t *testing.T) SharedData { //singleton B-) | ||
if sharedData == nil { |
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.
let's use require.NotNil
@@ -17,6 +17,7 @@ func (c *Controller) UponFutureMsg(msg *specqbft.SignedMessage) (*specqbft.Signe | |||
} | |||
if c.f1SyncTrigger() { | |||
c.logger.Debug("triggered f+1 sync", | |||
zap.Any("operator-id", c.Share.OperatorID), |
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's not a place for this log. please revert. we can open a issue to add this if needed
@@ -52,7 +52,7 @@ func NewInstance( | |||
config: config, | |||
processMsgF: spectypes.NewThreadSafeF(), | |||
metrics: newMetrics(msgId), | |||
logger: logger.With(zap.String("publicKey", hex.EncodeToString(msgId.GetPubKey())), zap.String("role", msgId.GetRoleType().String()), | |||
logger: logger.With(zap.Int("operator-id", int(share.OperatorID)), zap.String("publicKey", hex.EncodeToString(msgId.GetPubKey())), zap.String("role", msgId.GetRoleType().String()), |
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 revert it as it not needed in this scope
@@ -102,7 +102,7 @@ func (v *Validator) ConsumeQueue(msgID spectypes.MessageID, handler MessageHandl | |||
|
|||
// Handle the message. | |||
if err := handler(msg); err != nil { | |||
v.logMsg(msg, "could not handle message", zap.Any("type", msg.SSVMessage.MsgType), zap.Error(err)) | |||
v.logMsg(msg, "could not handle message", zap.Int("operator-id", int(v.Share.OperatorID)), zap.Any("type", msg.SSVMessage.MsgType), zap.Error(err)) |
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.
let's remove
protocol/v2/ssv/validator/startup.go
Outdated
@@ -20,6 +20,7 @@ func (v *Validator) Start() error { | |||
for role, r := range v.DutyRunners { | |||
share := r.GetBaseRunner().Share | |||
if share == nil { // TODO: handle missing share? | |||
v.logger.Warn("share is missing") |
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.
let's add the runner role type to the log
refactor integration tests
remove F+1 test scenario