-
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.
add tests for beacon-chain/state/state-native/getters_balance_deposit…
…s.go
- Loading branch information
1 parent
477c9cb
commit 3f4df33
Showing
2 changed files
with
49 additions
and
0 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
48 changes: 48 additions & 0 deletions
48
beacon-chain/state/state-native/getters_balance_deposits_test.go
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 |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package state_native_test | ||
|
||
import ( | ||
"testing" | ||
|
||
state_native "github.com/prysmaticlabs/prysm/v5/beacon-chain/state/state-native" | ||
eth "github.com/prysmaticlabs/prysm/v5/proto/prysm/v1alpha1" | ||
"github.com/prysmaticlabs/prysm/v5/testing/require" | ||
) | ||
|
||
func TestDepositBalanceToConsume(t *testing.T) { | ||
s, err := state_native.InitializeFromProtoElectra(ð.BeaconStateElectra{ | ||
DepositBalanceToConsume: 44, | ||
}) | ||
require.NoError(t, err) | ||
dbtc, err := s.DepositBalanceToConsume() | ||
require.NoError(t, err) | ||
require.Equal(t, uint64(44), dbtc) | ||
|
||
// Fails for older than electra state | ||
s, err = state_native.InitializeFromProtoDeneb(ð.BeaconStateDeneb{}) | ||
require.NoError(t, err) | ||
_, err = s.DepositBalanceToConsume() | ||
require.ErrorContains(t, "not supported", err) | ||
} | ||
|
||
func TestPendingBalanceDeposits(t *testing.T) { | ||
s, err := state_native.InitializeFromProtoElectra(ð.BeaconStateElectra{ | ||
PendingBalanceDeposits: []*eth.PendingBalanceDeposit{ | ||
{Index: 1, Amount: 2}, | ||
{Index: 3, Amount: 4}, | ||
}, | ||
}) | ||
require.NoError(t, err) | ||
pbd, err := s.PendingBalanceDeposits() | ||
require.NoError(t, err) | ||
require.Equal(t, 2, len(pbd)) | ||
require.Equal(t, 1, pbd[0].Index) | ||
require.Equal(t, 2, pbd[0].Amount) | ||
require.Equal(t, 3, pbd[1].Index) | ||
require.Equal(t, 4, pbd[1].Amount) | ||
|
||
// Fails for older than electra state | ||
s, err = state_native.InitializeFromProtoDeneb(ð.BeaconStateDeneb{}) | ||
require.NoError(t, err) | ||
_, err = s.DepositBalanceToConsume() | ||
require.ErrorContains(t, "not supported", err) | ||
} |