mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-22 11:32:09 +00:00
5a66807989
* First take at updating everything to v5 * Patch gRPC gateway to use prysm v5 Fix patch * Update go ssz --------- Co-authored-by: Preston Van Loon <pvanloon@offchainlabs.com>
45 lines
1.5 KiB
Go
45 lines
1.5 KiB
Go
package blockchain
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/pkg/errors"
|
|
"github.com/prysmaticlabs/prysm/v5/testing/require"
|
|
)
|
|
|
|
func TestIsInvalidBlock(t *testing.T) {
|
|
require.Equal(t, true, IsInvalidBlock(ErrInvalidPayload)) // Already wrapped.
|
|
err := invalidBlock{error: ErrInvalidPayload}
|
|
require.Equal(t, true, IsInvalidBlock(err))
|
|
|
|
newErr := errors.Wrap(err, "wrap me")
|
|
require.Equal(t, true, IsInvalidBlock(newErr))
|
|
require.DeepEqual(t, [][32]byte(nil), InvalidAncestorRoots(err))
|
|
}
|
|
|
|
func TestInvalidBlockRoot(t *testing.T) {
|
|
require.Equal(t, [32]byte{}, InvalidBlockRoot(ErrUndefinedExecutionEngineError))
|
|
require.Equal(t, [32]byte{}, InvalidBlockRoot(ErrInvalidPayload))
|
|
|
|
err := invalidBlock{error: ErrInvalidPayload, root: [32]byte{'a'}}
|
|
require.Equal(t, [32]byte{'a'}, InvalidBlockRoot(err))
|
|
require.DeepEqual(t, [][32]byte(nil), InvalidAncestorRoots(err))
|
|
|
|
newErr := errors.Wrap(err, "wrap me")
|
|
require.Equal(t, [32]byte{'a'}, InvalidBlockRoot(newErr))
|
|
}
|
|
|
|
func TestInvalidRoots(t *testing.T) {
|
|
roots := [][32]byte{{'d'}, {'b'}, {'c'}}
|
|
err := invalidBlock{error: ErrInvalidPayload, root: [32]byte{'a'}, invalidAncestorRoots: roots}
|
|
|
|
require.Equal(t, true, IsInvalidBlock(err))
|
|
require.Equal(t, [32]byte{'a'}, InvalidBlockRoot(err))
|
|
require.DeepEqual(t, roots, InvalidAncestorRoots(err))
|
|
|
|
newErr := errors.Wrap(err, "wrap me")
|
|
require.Equal(t, true, IsInvalidBlock(err))
|
|
require.Equal(t, [32]byte{'a'}, InvalidBlockRoot(newErr))
|
|
require.DeepEqual(t, roots, InvalidAncestorRoots(newErr))
|
|
}
|