Skip to content

Commit

Permalink
More fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefan-Ethernal committed Feb 13, 2024
1 parent 73fb7b8 commit 4007f61
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions consensus/polybft/state_store_exit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ func insertTestExitEvents(t *testing.T, state *State,
}
index++
}

block++
}
}
Expand Down
9 changes: 9 additions & 0 deletions consensus/polybft/validator/validator_set_delta_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ func TestValidatorSetDelta_UnmarshalRLPWith_NegativeCases(t *testing.T) {
t.Parallel()

ar := &fastrlp.Arena{}

delta := &ValidatorSetDelta{}
require.NoError(t, delta.UnmarshalRLPWith(ar.NewArray()))
})
Expand All @@ -84,6 +85,7 @@ func TestValidatorSetDelta_UnmarshalRLPWith_NegativeCases(t *testing.T) {
deltaMarshalled.Set(ar.NewBytes([]byte{0x33}))
deltaMarshalled.Set(ar.NewBytes([]byte{0x26}))
deltaMarshalled.Set(ar.NewBytes([]byte{0x74}))

delta := &ValidatorSetDelta{}
require.ErrorContains(t, delta.UnmarshalRLPWith(deltaMarshalled), "incorrect elements count to decode validator set delta, expected 3 but found 4")
})
Expand All @@ -93,9 +95,11 @@ func TestValidatorSetDelta_UnmarshalRLPWith_NegativeCases(t *testing.T) {

ar := &fastrlp.Arena{}
deltaMarshalled := ar.NewArray()

deltaMarshalled.Set(ar.NewBytes([]byte{0x59}))
deltaMarshalled.Set(ar.NewBytes([]byte{0x33}))
deltaMarshalled.Set(ar.NewBytes([]byte{0x27}))

delta := &ValidatorSetDelta{}
require.ErrorContains(t, delta.UnmarshalRLPWith(deltaMarshalled), "array expected for added validators")
})
Expand All @@ -110,6 +114,7 @@ func TestValidatorSetDelta_UnmarshalRLPWith_NegativeCases(t *testing.T) {
deltaMarshalled.Set(addedArray)
deltaMarshalled.Set(ar.NewNullArray())
deltaMarshalled.Set(ar.NewNull())

delta := &ValidatorSetDelta{}
require.ErrorContains(t, delta.UnmarshalRLPWith(deltaMarshalled), "value is not of type array")
})
Expand All @@ -136,6 +141,7 @@ func TestValidatorSetDelta_UnmarshalRLPWith_NegativeCases(t *testing.T) {
deltaMarshalled.Set(addedArray)
deltaMarshalled.Set(updatedArray)
deltaMarshalled.Set(ar.NewNull())

delta := &ValidatorSetDelta{}
require.ErrorContains(t, delta.UnmarshalRLPWith(deltaMarshalled), "value is not of type bytes")
})
Expand All @@ -158,7 +164,9 @@ func TestValidatorSetDelta_UnmarshalRLPWith_NegativeCases(t *testing.T) {

ar := &fastrlp.Arena{}
deltaMarshalled := ar.NewArray()

updatedArray := ar.NewArray()

updatedArray.Set(ar.NewNull())
deltaMarshalled.Set(ar.NewArray())
deltaMarshalled.Set(updatedArray)
Expand Down Expand Up @@ -216,6 +224,7 @@ func TestExtra_CreateValidatorSetDelta_Cases(t *testing.T) {
// make sure generated voting power is different than the original one
v.VotingPower += vp.Uint64() + 1
}

newValidatorSet := vals.GetPublicIdentities(c.newSet...)

delta, err := CreateValidatorSetDelta(oldValidatorSet, newValidatorSet)
Expand Down
1 change: 1 addition & 0 deletions consensus/polybft/validators_snapshot_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ func TestValidatorsSnapshotCache_Cleanup(t *testing.T) {

for i := uint64(0); i < validatorSnapshotLimit; i++ {
require.NoError(cache.storeSnapshot(&validatorSnapshot{i, i * 10, snapshot}, nil))

maxEpoch++
}

Expand Down
5 changes: 5 additions & 0 deletions e2e/discovery_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,22 @@ func TestDiscovery(t *testing.T) {
srvs := framework.NewTestServers(t, tt.numNodes, conf)

p2pAddrs := make([]string, tt.numNodes)

for i, s := range srvs {
status, err := s.Operator().GetStatus(context.Background(), &empty.Empty{})
if err != nil {
t.Fatal(err)
}

p2pAddrs[i] = strings.Split(status.P2PAddr, ",")[0]
}

for i := 0; i < tt.numInitConnectNodes-1; i++ {
srv, dest := srvs[i], p2pAddrs[i+1]

ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()

_, err := srv.Operator().PeersAdd(ctx, &proto.PeersAddRequest{
Id: dest,
})
Expand All @@ -63,6 +67,7 @@ func TestDiscovery(t *testing.T) {
for i, srv := range srvs {
shouldKnowPeers := true
subTestName := fmt.Sprintf("node %d should know other peers", i)

if i >= tt.numInitConnectNodes {
shouldKnowPeers = false
subTestName = fmt.Sprintf("node %d shouldn't know other peers", i)
Expand Down
1 change: 1 addition & 0 deletions e2e/txpool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ func TestTxPool_ErrorCodes(t *testing.T) {

convertedHash := types.StringToHash(addResponse.TxHash)
_, receiptErr := tests.WaitForReceipt(receiptCtx, srv.JSONRPC().Eth(), ethgo.Hash(convertedHash))

if receiptErr != nil {
t.Fatalf("Unable to get receipt, %v", receiptErr)
}
Expand Down

0 comments on commit 4007f61

Please sign in to comment.