mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2025-01-08 18:51:19 +00:00
parent
597b21c40a
commit
47bb927029
@ -46,5 +46,6 @@ go_test(
|
||||
"//shared/stateutil:go_default_library",
|
||||
"@com_github_gogo_protobuf//proto:go_default_library",
|
||||
"@com_github_prysmaticlabs_ethereumapis//eth/v1alpha1:go_default_library",
|
||||
"@com_github_prysmaticlabs_go_ssz//:go_default_library",
|
||||
],
|
||||
)
|
||||
|
@ -135,8 +135,8 @@ func (b *BeaconState) Fork() *pbp2p.Fork {
|
||||
|
||||
prevVersion := make([]byte, len(b.state.Fork.PreviousVersion))
|
||||
copy(prevVersion, b.state.Fork.PreviousVersion)
|
||||
currVersion := make([]byte, len(b.state.Fork.PreviousVersion))
|
||||
copy(currVersion, b.state.Fork.PreviousVersion)
|
||||
currVersion := make([]byte, len(b.state.Fork.CurrentVersion))
|
||||
copy(currVersion, b.state.Fork.CurrentVersion)
|
||||
return &pbp2p.Fork{
|
||||
PreviousVersion: prevVersion,
|
||||
CurrentVersion: currVersion,
|
||||
|
@ -7,6 +7,7 @@ import (
|
||||
|
||||
"github.com/gogo/protobuf/proto"
|
||||
ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
|
||||
"github.com/prysmaticlabs/go-ssz"
|
||||
stateTrie "github.com/prysmaticlabs/prysm/beacon-chain/state"
|
||||
pb "github.com/prysmaticlabs/prysm/proto/beacon/p2p/v1"
|
||||
"github.com/prysmaticlabs/prysm/shared/bytesutil"
|
||||
@ -226,3 +227,24 @@ func TestBeaconState_ImmutabilityWithSharedResources(t *testing.T) {
|
||||
t.Fatal("Expected a.BlockRoots() to be different from b.BlockRoots()")
|
||||
}
|
||||
}
|
||||
|
||||
func TestForkManualCopy_OK(t *testing.T) {
|
||||
params.UseMinimalConfig()
|
||||
genesis := setupGenesisState(t, 64)
|
||||
a, err := stateTrie.InitializeFromProto(genesis)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
wantedFork := &pb.Fork{
|
||||
PreviousVersion: []byte{'a', 'b', 'c'},
|
||||
CurrentVersion: []byte{'d', 'e', 'f'},
|
||||
Epoch: 0,
|
||||
}
|
||||
a.SetFork(wantedFork)
|
||||
|
||||
newState := a.CloneInnerState()
|
||||
if !ssz.DeepEqual(newState.Fork, wantedFork) {
|
||||
t.Errorf("Wanted %v but got %v", wantedFork, newState.Fork)
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user