mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-25 12:57:18 +00:00
42 lines
1.6 KiB
Go
42 lines
1.6 KiB
Go
|
package blocks_test
|
||
|
|
||
|
import (
|
||
|
"testing"
|
||
|
|
||
|
"github.com/prysmaticlabs/prysm/beacon-chain/core/blocks"
|
||
|
"github.com/prysmaticlabs/prysm/beacon-chain/core/helpers"
|
||
|
ethpb "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
||
|
wrapperv2 "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1/wrapper"
|
||
|
"github.com/prysmaticlabs/prysm/shared/bytesutil"
|
||
|
"github.com/prysmaticlabs/prysm/shared/params"
|
||
|
"github.com/prysmaticlabs/prysm/shared/testutil"
|
||
|
"github.com/prysmaticlabs/prysm/shared/testutil/assert"
|
||
|
"github.com/prysmaticlabs/prysm/shared/testutil/require"
|
||
|
)
|
||
|
|
||
|
func TestVerifyBlockSignatureUsingCurrentFork(t *testing.T) {
|
||
|
params.SetupTestConfigCleanup(t)
|
||
|
bCfg := params.BeaconConfig()
|
||
|
bCfg.AltairForkEpoch = 100
|
||
|
bCfg.ForkVersionSchedule[bytesutil.ToBytes4(bCfg.AltairForkVersion)] = 100
|
||
|
params.OverrideBeaconConfig(bCfg)
|
||
|
bState, keys := testutil.DeterministicGenesisState(t, 100)
|
||
|
altairBlk := testutil.NewBeaconBlockAltair()
|
||
|
altairBlk.Block.ProposerIndex = 0
|
||
|
altairBlk.Block.Slot = params.BeaconConfig().SlotsPerEpoch * 100
|
||
|
fData := ðpb.Fork{
|
||
|
Epoch: 100,
|
||
|
CurrentVersion: params.BeaconConfig().AltairForkVersion,
|
||
|
PreviousVersion: params.BeaconConfig().GenesisForkVersion,
|
||
|
}
|
||
|
domain, err := helpers.Domain(fData, 100, params.BeaconConfig().DomainBeaconProposer, bState.GenesisValidatorRoot())
|
||
|
assert.NoError(t, err)
|
||
|
rt, err := helpers.ComputeSigningRoot(altairBlk.Block, domain)
|
||
|
assert.NoError(t, err)
|
||
|
sig := keys[0].Sign(rt[:]).Marshal()
|
||
|
altairBlk.Signature = sig
|
||
|
wsb, err := wrapperv2.WrappedAltairSignedBeaconBlock(altairBlk)
|
||
|
require.NoError(t, err)
|
||
|
assert.NoError(t, blocks.VerifyBlockSignatureUsingCurrentFork(bState, wsb))
|
||
|
}
|