Skip to content

Commit

Permalink
sanity check tests fix
Browse files Browse the repository at this point in the history
  • Loading branch information
goran-ethernal committed Jun 24, 2024
1 parent ee48c82 commit 296545c
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 9 deletions.
2 changes: 1 addition & 1 deletion loadtest/sanitycheck/sanity_check_register_validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func (t *RegisterValidatorTest) runTest() (*wallet.Account, error) {
return nil, fmt.Errorf("failed to register new validator: %w", err)
}

if blockNum%t.config.EpochSize != 0 {
if blockNum%t.config.EpochSize == 0 {
// if validator was registered on the epoch ending block, it will become active on the next epoch
blockNum++
}
Expand Down
8 changes: 5 additions & 3 deletions loadtest/sanitycheck/sanity_check_stake.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func (t *StakeTest) Run() error {
return fmt.Errorf("stake amount is incorrect. Expected: %s, Actual: %s", expectedStake, currentStake)
}

if blockNum%t.config.EpochSize != 0 {
if blockNum%t.config.EpochSize == 0 {
// if validator staked on the epoch ending block, it will be added on the next epoch
blockNum++
}
Expand All @@ -103,11 +103,13 @@ func (t *StakeTest) Run() error {
fmt.Println("Checking if correct validator stake is in validator set delta")

if extra.Validators == nil || extra.Validators.IsEmpty() {
return fmt.Errorf("validator set delta is empty on an epoch ending block")
return fmt.Errorf("validator set delta is empty on an epoch ending block. Block: %d. EpochSize: %d",
epochEndingBlock.Number, t.config.EpochSize)
}

if !extra.Validators.Updated.ContainsAddress(validatorKey.Address()) {
return fmt.Errorf("validator %s is not in the updated validator set", validatorKey.Address())
return fmt.Errorf("validator %s is not in the updated validator set. Block: %d. EpochSize: %d",
validatorKey.Address(), epochEndingBlock.Number, t.config.EpochSize)
}

validatorMetaData := extra.Validators.Updated.GetValidatorMetadata(validatorKey.Address())
Expand Down
15 changes: 11 additions & 4 deletions loadtest/sanitycheck/sanity_check_unstake.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,12 @@ func (t *UnstakeTest) Run() error {
fmt.Println("Running", t.Name())
defer fmt.Println("Finished", t.Name())

validatorKey, err := t.decodePrivateKey(t.config.ValidatorKeys[0])
validatorIndex := 0
if len(t.config.ValidatorKeys) > 1 {
validatorIndex = 1
}

validatorKey, err := t.decodePrivateKey(t.config.ValidatorKeys[validatorIndex])
if err != nil {
return err
}
Expand Down Expand Up @@ -84,7 +89,7 @@ func (t *UnstakeTest) Run() error {
return fmt.Errorf("stake amount is incorrect. Expected: %s, Actual: %s", expectedStake, currentStake)
}

if blockNum%t.config.EpochSize != 0 {
if blockNum%t.config.EpochSize == 0 {
// if validator unstaked on the epoch ending block, it will be added on the next epoch
blockNum++
}
Expand All @@ -102,11 +107,13 @@ func (t *UnstakeTest) Run() error {
fmt.Println("Checking if correct validator stake is in validator set delta")

if extra.Validators == nil || extra.Validators.IsEmpty() {
return fmt.Errorf("validator set delta is empty on an epoch ending block")
return fmt.Errorf("validator set delta is empty on an epoch ending block. Block: %d. EpochSize: %d",
epochEndingBlock.Number, t.config.EpochSize)
}

if !extra.Validators.Updated.ContainsAddress(validatorKey.Address()) {
return fmt.Errorf("validator %s is not in the updated validator set", validatorKey.Address())
return fmt.Errorf("validator %s is not in the updated validator set. Block: %d. EpochSize: %d",
validatorKey.Address(), epochEndingBlock.Number, t.config.EpochSize)
}

validatorMetaData := extra.Validators.Updated.GetValidatorMetadata(validatorKey.Address())
Expand Down
2 changes: 1 addition & 1 deletion loadtest/sanitycheck/sanity_check_unstake_all.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func (t *UnstakeAllTest) Run() error {
return err
}

if blockNum%t.config.EpochSize != 0 {
if blockNum%t.config.EpochSize == 0 {
// if validator unstaked all on the epoch ending block, it will be removed on the next epoch
blockNum++
}
Expand Down

0 comments on commit 296545c

Please sign in to comment.