2021-11-24 01:56:34 +00:00
|
|
|
package monitor
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/prysmaticlabs/go-bitfield"
|
2022-08-16 12:20:13 +00:00
|
|
|
"github.com/prysmaticlabs/prysm/v3/consensus-types/blocks"
|
|
|
|
ethpb "github.com/prysmaticlabs/prysm/v3/proto/prysm/v1alpha1"
|
|
|
|
"github.com/prysmaticlabs/prysm/v3/testing/require"
|
|
|
|
"github.com/prysmaticlabs/prysm/v3/testing/util"
|
2021-11-24 01:56:34 +00: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)
|
|
|
|
require.LogsContain(t, hook, "\"Sync committee aggregation processed\" ValidatorIndex=1")
|
|
|
|
require.LogsDoNotContain(t, hook, "ValidatorIndex=2")
|
|
|
|
}
|
|
|
|
|
|
|
|
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 15:30:46 +00:00
|
|
|
wrappedBlock, err := blocks.NewBeaconBlock(block)
|
2021-11-24 01:56:34 +00:00
|
|
|
require.NoError(t, err)
|
|
|
|
|
|
|
|
s.processSyncAggregate(beaconState, wrappedBlock)
|
2021-12-15 20:42:20 +00:00
|
|
|
require.LogsContain(t, hook, "\"Sync committee contribution included\" BalanceChange=0 ContribCount=1 ExpectedContribCount=4 NewBalance=32000000000 ValidatorIndex=1 prefix=monitor")
|
|
|
|
require.LogsContain(t, hook, "\"Sync committee contribution included\" BalanceChange=100000000 ContribCount=2 ExpectedContribCount=2 NewBalance=32000000000 ValidatorIndex=12 prefix=monitor")
|
2021-11-24 01:56:34 +00:00
|
|
|
require.LogsDoNotContain(t, hook, "ValidatorIndex=2")
|
|
|
|
}
|