2021-11-23 22:56:34 -03:00
|
|
|
package monitor
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/prysmaticlabs/go-bitfield"
|
2024-02-14 21:46:47 -08:00
|
|
|
"github.com/prysmaticlabs/prysm/v5/consensus-types/blocks"
|
|
|
|
ethpb "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1"
|
|
|
|
"github.com/prysmaticlabs/prysm/v5/testing/require"
|
|
|
|
"github.com/prysmaticlabs/prysm/v5/testing/util"
|
2021-11-23 22:56:34 -03:00
|
|
|
logTest "github.com/sirupsen/logrus/hooks/test"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestProcessSyncCommitteeContribution(t *testing.T) {
|
|
|
|
hook := logTest.NewGlobal()
|
|
|
|
s := setupService(t)
|
|
|
|
|
|
|
|
contrib := ðpb.SignedContributionAndProof{
|
|
|
|
Message: ðpb.ContributionAndProof{
|
|
|
|
AggregatorIndex: 1,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
s.processSyncCommitteeContribution(contrib)
|
2024-02-22 23:40:36 +01:00
|
|
|
require.LogsContain(t, hook, "\"Sync committee aggregation processed\" prefix=monitor validatorIndex=1")
|
|
|
|
require.LogsDoNotContain(t, hook, "validatorIndex=2")
|
2021-11-23 22:56:34 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestProcessSyncAggregate(t *testing.T) {
|
|
|
|
hook := logTest.NewGlobal()
|
|
|
|
s := setupService(t)
|
|
|
|
beaconState, _ := util.DeterministicGenesisStateAltair(t, 256)
|
|
|
|
|
|
|
|
block := ðpb.BeaconBlockAltair{
|
|
|
|
Slot: 2,
|
|
|
|
Body: ðpb.BeaconBlockBodyAltair{
|
|
|
|
SyncAggregate: ðpb.SyncAggregate{
|
|
|
|
SyncCommitteeBits: bitfield.Bitvector512{
|
|
|
|
0x31, 0xff, 0xff, 0xff, 0xff, 0x3f, 0xff, 0xff,
|
|
|
|
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
|
|
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
|
|
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
|
|
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
|
|
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
|
|
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
|
|
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2022-08-02 17:30:46 +02:00
|
|
|
wrappedBlock, err := blocks.NewBeaconBlock(block)
|
2021-11-23 22:56:34 -03:00
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
s.processSyncAggregate(beaconState, wrappedBlock)
|
2024-02-22 23:40:36 +01:00
|
|
|
require.LogsContain(t, hook, "\"Sync committee contribution included\" balanceChange=0 contribCount=1 expectedContribCount=4 newBalance=32000000000 prefix=monitor validatorIndex=1")
|
|
|
|
require.LogsContain(t, hook, "\"Sync committee contribution included\" balanceChange=100000000 contribCount=2 expectedContribCount=2 newBalance=32000000000 prefix=monitor validatorIndex=12")
|
|
|
|
require.LogsDoNotContain(t, hook, "validatorIndex=2")
|
2021-11-23 22:56:34 -03:00
|
|
|
}
|