mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2025-01-12 04:30:04 +00:00
60 lines
2.1 KiB
Go
60 lines
2.1 KiB
Go
|
package monitor
|
||
|
|
||
|
import (
|
||
|
"testing"
|
||
|
|
||
|
"github.com/prysmaticlabs/go-bitfield"
|
||
|
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
||
|
"github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper"
|
||
|
"github.com/prysmaticlabs/prysm/testing/require"
|
||
|
"github.com/prysmaticlabs/prysm/testing/util"
|
||
|
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,
|
||
|
},
|
||
|
},
|
||
|
},
|
||
|
}
|
||
|
|
||
|
wrappedBlock, err := wrapper.WrappedAltairBeaconBlock(block)
|
||
|
require.NoError(t, err)
|
||
|
|
||
|
s.processSyncAggregate(beaconState, wrappedBlock)
|
||
|
require.LogsContain(t, hook, "\"Sync committee contribution included\" BalanceChange=0 Contributions=1 ExpectedContrib=4 NewBalance=32000000000 ValidatorIndex=1 prefix=monitor")
|
||
|
require.LogsContain(t, hook, "\"Sync committee contribution included\" BalanceChange=100000000 Contributions=2 ExpectedContrib=2 NewBalance=32000000000 ValidatorIndex=12 prefix=monitor")
|
||
|
require.LogsDoNotContain(t, hook, "ValidatorIndex=2")
|
||
|
}
|