-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
63a18cb
commit d5f1ee4
Showing
5 changed files
with
47 additions
and
159 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,94 +1,33 @@ | ||
package helpers_test | ||
|
||
import ( | ||
"math" | ||
"testing" | ||
|
||
"github.com/prysmaticlabs/prysm/v5/beacon-chain/core/helpers" | ||
"github.com/prysmaticlabs/prysm/v5/beacon-chain/state" | ||
state_native "github.com/prysmaticlabs/prysm/v5/beacon-chain/state/state-native" | ||
ethpb "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1" | ||
"github.com/prysmaticlabs/prysm/v5/testing/util" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestIsLegacyDepositProcessPeriod(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
state state.BeaconState | ||
canonicalEth1Data *ethpb.Eth1Data | ||
want bool | ||
}{ | ||
{ | ||
name: "pre-electra", | ||
state: func() state.BeaconState { | ||
st, err := state_native.InitializeFromProtoDeneb(ðpb.BeaconStateDeneb{ | ||
Eth1Data: ðpb.Eth1Data{ | ||
BlockHash: []byte("0x0"), | ||
DepositRoot: make([]byte, 32), | ||
DepositCount: 5, | ||
}, | ||
Eth1DepositIndex: 1, | ||
}) | ||
require.NoError(t, err) | ||
return st | ||
}(), | ||
canonicalEth1Data: ðpb.Eth1Data{ | ||
BlockHash: []byte("0x0"), | ||
DepositRoot: make([]byte, 32), | ||
DepositCount: 5, | ||
}, | ||
want: true, | ||
}, | ||
{ | ||
name: "post-electra, pending deposits from pre-electra", | ||
state: func() state.BeaconState { | ||
st, err := state_native.InitializeFromProtoElectra(ðpb.BeaconStateElectra{ | ||
Eth1Data: ðpb.Eth1Data{ | ||
BlockHash: []byte("0x0"), | ||
DepositRoot: make([]byte, 32), | ||
DepositCount: 5, | ||
}, | ||
DepositRequestsStartIndex: math.MaxUint64, | ||
Eth1DepositIndex: 1, | ||
}) | ||
require.NoError(t, err) | ||
return st | ||
}(), | ||
canonicalEth1Data: ðpb.Eth1Data{ | ||
BlockHash: []byte("0x0"), | ||
DepositRoot: make([]byte, 32), | ||
DepositCount: 5, | ||
}, | ||
want: true, | ||
}, | ||
{ | ||
name: "post-electra, no pending deposits from pre-alpaca", | ||
state: func() state.BeaconState { | ||
st, err := state_native.InitializeFromProtoElectra(ðpb.BeaconStateElectra{ | ||
Eth1Data: ðpb.Eth1Data{ | ||
BlockHash: []byte("0x0"), | ||
DepositRoot: make([]byte, 32), | ||
DepositCount: 5, | ||
}, | ||
DepositRequestsStartIndex: 1, | ||
Eth1DepositIndex: 5, | ||
}) | ||
require.NoError(t, err) | ||
return st | ||
}(), | ||
canonicalEth1Data: ðpb.Eth1Data{ | ||
BlockHash: []byte("0x0"), | ||
DepositRoot: make([]byte, 32), | ||
DepositCount: 5, | ||
}, | ||
want: false, | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
if got := helpers.IsLegacyDepositProcessPeriod(tt.state, tt.canonicalEth1Data); got != tt.want { | ||
t.Errorf("isLegacyDepositProcessPeriod() = %v, want %v", got, tt.want) | ||
} | ||
}) | ||
} | ||
// TestDepositRequestHaveStarted contains several test cases for depositRequestHaveStarted. | ||
func TestDepositRequestHaveStarted(t *testing.T) { | ||
t.Run("Version below Electra returns false", func(t *testing.T) { | ||
st, _ := util.DeterministicGenesisStateBellatrix(t, 1) | ||
result := helpers.DepositRequestHaveStarted(st) | ||
require.False(t, result) | ||
}) | ||
|
||
t.Run("Version is Electra or higher, no error, but Eth1DepositIndex != requestsStartIndex returns false", func(t *testing.T) { | ||
st, _ := util.DeterministicGenesisStateElectra(t, 1) | ||
require.NoError(t, st.SetEth1DepositIndex(1)) | ||
result := helpers.DepositRequestHaveStarted(st) | ||
require.False(t, result) | ||
}) | ||
|
||
t.Run("Version is Electra or higher, no error, and Eth1DepositIndex == requestsStartIndex returns true", func(t *testing.T) { | ||
st, _ := util.DeterministicGenesisStateElectra(t, 1) | ||
require.NoError(t, st.SetEth1DepositIndex(33)) | ||
require.NoError(t, st.SetDepositRequestsStartIndex(33)) | ||
result := helpers.DepositRequestHaveStarted(st) | ||
require.True(t, result) | ||
}) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 0 additions & 32 deletions
32
beacon-chain/rpc/prysm/v1alpha1/validator/proposer_eth1data_test.go
This file was deleted.
Oops, something went wrong.