mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-22 19:40:37 +00:00
a2c1185032
* Add sync committeee contributions to monitor * gaz * Raul's review * Added lock around TrackedValidators * add comment to trackedIndex * add missing locks because of trackedIndex * Terence fixes 2 * moved TrackedValidator to service from config * Terence comment fix Co-authored-by: Raul Jordan <raul@prysmaticlabs.com>
46 lines
1.3 KiB
Go
46 lines
1.3 KiB
Go
package monitor
|
|
|
|
import (
|
|
"testing"
|
|
|
|
types "github.com/prysmaticlabs/eth2-types"
|
|
"github.com/prysmaticlabs/prysm/testing/require"
|
|
"github.com/prysmaticlabs/prysm/testing/util"
|
|
logTest "github.com/sirupsen/logrus/hooks/test"
|
|
)
|
|
|
|
func TestTrackedIndex(t *testing.T) {
|
|
s := &Service{
|
|
TrackedValidators: map[types.ValidatorIndex]interface{}{
|
|
1: nil,
|
|
2: nil,
|
|
},
|
|
}
|
|
require.Equal(t, s.trackedIndex(types.ValidatorIndex(1)), true)
|
|
require.Equal(t, s.trackedIndex(types.ValidatorIndex(3)), false)
|
|
}
|
|
|
|
func TestUpdateSyncCommitteeTrackedVals(t *testing.T) {
|
|
hook := logTest.NewGlobal()
|
|
s := setupService(t)
|
|
state, _ := util.DeterministicGenesisStateAltair(t, 1024)
|
|
|
|
pubKeys := make([][]byte, 3)
|
|
pubKeys[0] = state.Validators()[0].PublicKey
|
|
pubKeys[1] = state.Validators()[1].PublicKey
|
|
pubKeys[2] = state.Validators()[2].PublicKey
|
|
|
|
currentSyncCommittee := util.ConvertToCommittee([][]byte{
|
|
pubKeys[0], pubKeys[1], pubKeys[2], pubKeys[1], pubKeys[1],
|
|
})
|
|
require.NoError(t, state.SetCurrentSyncCommittee(currentSyncCommittee))
|
|
|
|
s.updateSyncCommitteeTrackedVals(state)
|
|
require.LogsDoNotContain(t, hook, "Sync committee assignments will not be reported")
|
|
newTrackedSyncIndices := map[types.ValidatorIndex][]types.CommitteeIndex{
|
|
1: {1, 3, 4},
|
|
2: {2},
|
|
}
|
|
require.DeepEqual(t, s.trackedSyncCommitteeIndices, newTrackedSyncIndices)
|
|
}
|