From df495fbd876f3b6fe8c598c0db77b0337f4460c5 Mon Sep 17 00:00:00 2001 From: Andrei Smirnov Date: Tue, 20 Aug 2024 16:29:49 +0300 Subject: [PATCH] Added unit tests --- core/parsigex/parsigex_test.go | 8 ++++++++ core/sigagg/sigagg_test.go | 15 +++++++++++++++ core/validatorapi/validatorapi_test.go | 12 +++++++++++- 3 files changed, 34 insertions(+), 1 deletion(-) diff --git a/core/parsigex/parsigex_test.go b/core/parsigex/parsigex_test.go index 3c7fa39b8..391abb2f2 100644 --- a/core/parsigex/parsigex_test.go +++ b/core/parsigex/parsigex_test.go @@ -16,6 +16,7 @@ import ( "github.com/libp2p/go-libp2p/core/peerstore" "github.com/stretchr/testify/require" + "github.com/obolnetwork/charon/app/featureset" "github.com/obolnetwork/charon/core" "github.com/obolnetwork/charon/core/parsigex" "github.com/obolnetwork/charon/eth2util" @@ -324,6 +325,13 @@ func TestParSigExVerifier(t *testing.T) { require.NoError(t, verifyFunc(ctx, core.NewPrepareSyncContributionDuty(slot), pubkey, parSigData)) }) + + t.Run("with disable_parsig_checks", func(t *testing.T) { + featureset.EnableForT(t, featureset.DisableParSigChecks) + + err := verifyFunc(ctx, core.NewProposerDuty(1), pubkey, core.ParSignedData{}) + require.NoError(t, err) + }) } func versionedSignedProposalRoot(t *testing.T, p *eth2api.VersionedSignedProposal) (eth2p0.Root, error) { diff --git a/core/sigagg/sigagg_test.go b/core/sigagg/sigagg_test.go index c522800ce..e251623b1 100644 --- a/core/sigagg/sigagg_test.go +++ b/core/sigagg/sigagg_test.go @@ -18,6 +18,7 @@ import ( eth2p0 "github.com/attestantio/go-eth2-client/spec/phase0" "github.com/stretchr/testify/require" + "github.com/obolnetwork/charon/app/featureset" "github.com/obolnetwork/charon/core" "github.com/obolnetwork/charon/core/sigagg" "github.com/obolnetwork/charon/eth2util/signing" @@ -27,6 +28,20 @@ import ( "github.com/obolnetwork/charon/testutil/beaconmock" ) +func TestNewVerifier(t *testing.T) { + ctx := context.Background() + bmock, err := beaconmock.New() + require.NoError(t, err) + + t.Run("with disable_parsig_checks", func(t *testing.T) { + featureset.EnableForT(t, featureset.DisableParSigChecks) + + vf := sigagg.NewVerifier(bmock) + err := vf(ctx, "", nil) + require.NoError(t, err) + }) +} + func TestSigAgg(t *testing.T) { ctx := context.Background() diff --git a/core/validatorapi/validatorapi_test.go b/core/validatorapi/validatorapi_test.go index a6199366e..a303d6dae 100644 --- a/core/validatorapi/validatorapi_test.go +++ b/core/validatorapi/validatorapi_test.go @@ -27,6 +27,7 @@ import ( "github.com/obolnetwork/charon/app/errors" "github.com/obolnetwork/charon/app/eth2wrap" + "github.com/obolnetwork/charon/app/featureset" "github.com/obolnetwork/charon/core" "github.com/obolnetwork/charon/core/validatorapi" "github.com/obolnetwork/charon/eth2util" @@ -550,7 +551,7 @@ func TestComponent_SubmitProposalInvalidSignature(t *testing.T) { vapi.Subscribe(func(ctx context.Context, duty core.Duty, set core.ParSignedDataSet) error { block, ok := set[corePubKey].SignedData.(core.VersionedSignedProposal) require.True(t, ok) - require.Equal(t, signedBlock, block) + require.Equal(t, *signedBlock, block.VersionedSignedProposal) return nil }) @@ -559,6 +560,15 @@ func TestComponent_SubmitProposalInvalidSignature(t *testing.T) { Proposal: signedBlock, }) require.ErrorContains(t, err, "signature not verified") + + t.Run("with disable_parsig_checks", func(t *testing.T) { + featureset.EnableForT(t, featureset.DisableParSigChecks) + + err = vapi.SubmitProposal(ctx, ð2api.SubmitProposalOpts{ + Proposal: signedBlock, + }) + require.NoError(t, err) + }) } func TestComponent_SubmitProposalInvalidBlock(t *testing.T) {