Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(ci): tidy and lint #1540

Merged
merged 2 commits into from
Jun 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion mod/cli/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ require (
github.com/berachain/beacon-kit/mod/consensus-types v0.0.0-20240614154006-a5defa6198f5
github.com/berachain/beacon-kit/mod/engine-primitives v0.0.0-20240614170830-558fac144a58
github.com/berachain/beacon-kit/mod/errors v0.0.0-20240618214413-d5ec0e66b3dd
github.com/berachain/beacon-kit/mod/log v0.0.0-20240619005002-353d4c2f8179
github.com/berachain/beacon-kit/mod/log v0.0.0-20240619234034-fe96d94eafef
github.com/berachain/beacon-kit/mod/node-core v0.0.0-20240617204505-1abdb4095d50
github.com/berachain/beacon-kit/mod/primitives v0.0.0-20240618214413-d5ec0e66b3dd
github.com/cometbft/cometbft v1.0.0-alpha.2.0.20240613135100-716d8f8c592d
Expand Down
4 changes: 2 additions & 2 deletions mod/cli/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ github.com/berachain/beacon-kit/mod/execution v0.0.0-20240617185735-42326b5546a8
github.com/berachain/beacon-kit/mod/execution v0.0.0-20240617185735-42326b5546a8/go.mod h1:QiaIGIPh5htIO+CDatTHARMwKwAfoTL8eg2SBpyHbxQ=
github.com/berachain/beacon-kit/mod/interfaces v0.0.0-20240610210054-bfdc14c4013c h1:/4ch1BvnPODBW0NSekJetlOsN1ezi10eoT5z/QqYGL4=
github.com/berachain/beacon-kit/mod/interfaces v0.0.0-20240610210054-bfdc14c4013c/go.mod h1:DzF1FpA1mYOLRJkdRUAchd+nhgzbtaaVTO7TfzBzLA8=
github.com/berachain/beacon-kit/mod/log v0.0.0-20240619005002-353d4c2f8179 h1:e3O6oQLGRRV198wI1Td6cbHOzZTdfk0YHyawxS+5AvQ=
github.com/berachain/beacon-kit/mod/log v0.0.0-20240619005002-353d4c2f8179/go.mod h1:xP5KcG56VfbPgz2ZRHerxm90MkjXMSDaGZNOOO5yfH4=
github.com/berachain/beacon-kit/mod/log v0.0.0-20240619234034-fe96d94eafef h1:KYnx+uPEKHax/OOcIfkzELEvgkBOy+I3LhZk1p6rtwU=
github.com/berachain/beacon-kit/mod/log v0.0.0-20240619234034-fe96d94eafef/go.mod h1:xP5KcG56VfbPgz2ZRHerxm90MkjXMSDaGZNOOO5yfH4=
github.com/berachain/beacon-kit/mod/node-core v0.0.0-20240617204505-1abdb4095d50 h1:0610JbaXUEr8PfcWmSaAKaK1iWPd32fh5hl93T9I7VI=
github.com/berachain/beacon-kit/mod/node-core v0.0.0-20240617204505-1abdb4095d50/go.mod h1:p/lNxCFnUC4toU5vtEK9QWhCukCFHUHfNy63OoIK9/Y=
github.com/berachain/beacon-kit/mod/p2p v0.0.0-20240610210054-bfdc14c4013c h1:1ZTBC0BEdkOZ52WVIPdAXc+hr+zRcvrM0XsXz7TAlwA=
Expand Down
57 changes: 32 additions & 25 deletions mod/primitives/pkg/chain/helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,39 +18,42 @@
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND
// TITLE.

package chain
package chain_test

import (
"testing"

"github.com/berachain/beacon-kit/mod/primitives/pkg/chain"
"github.com/berachain/beacon-kit/mod/primitives/pkg/version"
"github.com/stretchr/testify/require"
)

// Define concrete types for the generic parameters
type domainTypeT [4]byte
type epochT uint64
type executionAddressT [20]byte
type slotT uint64
type cometBFTConfigT struct{}
// Define concrete types for the generic parameters.
type (
domainType [4]byte
epoch uint64
executionAddress [20]byte
slot uint64
cometBFTConfig struct{}
)

// Create an instance of chainSpec with test data
var spec = chainSpec[domainTypeT, epochT, executionAddressT, slotT, cometBFTConfigT]{
Data: SpecData[
domainTypeT, epochT, executionAddressT, slotT, cometBFTConfigT,
// Create an instance of chainSpec with test data.
var spec = chain.NewChainSpec(
chain.SpecData[
domainType, epoch, executionAddress, slot, cometBFTConfig,
]{
ElectraForkEpoch: 10,
SlotsPerEpoch: 32,
ElectraForkEpoch: 10,
SlotsPerEpoch: 32,
MinEpochsForBlobsSidecarsRequest: 5,
},
}
)

// TestActiveForkVersionForEpoch tests the ActiveForkVersionForEpoch method
// TestActiveForkVersionForEpoch tests the ActiveForkVersionForEpoch method.
func TestActiveForkVersionForEpoch(t *testing.T) {
// Define test cases
tests := []struct {
name string
epoch epochT
epoch epoch
expected uint32
}{
{name: "Before Electra Fork", epoch: 9, expected: version.Deneb},
Expand All @@ -72,8 +75,8 @@ func TestSlotToEpoch(t *testing.T) {
// Define test cases
tests := []struct {
name string
slot slotT
expected epochT
slot slot
expected epoch
}{
{name: "Epoch 0, Slot 0", slot: 0, expected: 0},
{name: "Epoch 0, Slot 31", slot: 31, expected: 0},
Expand All @@ -97,7 +100,7 @@ func TestActiveForkVersionForSlot(t *testing.T) {
// Define test cases
tests := []struct {
name string
slot slotT
slot slot
expected uint32
}{
{name: "Before Electra Fork", slot: 0, expected: version.Deneb},
Expand All @@ -120,14 +123,18 @@ func TestWithinDAPeriod(t *testing.T) {
// Define test cases
tests := []struct {
name string
block slotT
current slotT
block slot
current slot
expected bool
}{
{name: "Within DA Period", block: 0, current: 160, expected: true}, // Block is within DA period (5 epochs)
{name: "Outside DA Period", block: 0, current: 192, expected: false}, // Block is outside DA period (>5 epochs)
{name: "Within DA Period 2", block: 160, current: 320, expected: true}, // Block is within DA period
{name: "Outside DA Period 2", block: 160, current: 352, expected: false}, // Block is outside DA period
// Block is within DA period (5 epochs).
{name: "Within DA Period", block: 0, current: 160, expected: true},
// Block is outside DA period (>5 epochs).
{name: "Outside DA Period", block: 0, current: 192, expected: false},
// Block is within DA period.
{name: "Within DA Period 2", block: 160, current: 320, expected: true},
// Block is outside DA period.
{name: "Outside DA Period 2", block: 160, current: 352, expected: false},
}

// Run test cases
Expand Down
2 changes: 1 addition & 1 deletion testing/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ require (
cosmossdk.io/log v1.3.2-0.20240530141513-465410c75bce
github.com/berachain/beacon-kit/mod/errors v0.0.0-20240619160923-72a9b26aa13d
github.com/berachain/beacon-kit/mod/execution v0.0.0-20240619160923-72a9b26aa13d
github.com/berachain/beacon-kit/mod/log v0.0.0-20240619152304-c7f6759c3dc8
github.com/berachain/beacon-kit/mod/log v0.0.0-20240619234034-fe96d94eafef
github.com/berachain/beacon-kit/mod/primitives v0.0.0-20240619160923-72a9b26aa13d
github.com/cometbft/cometbft v1.0.0-alpha.2.0.20240613135100-716d8f8c592d
github.com/cosmos/cosmos-sdk v0.51.0
Expand Down
4 changes: 2 additions & 2 deletions testing/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ github.com/berachain/beacon-kit/mod/errors v0.0.0-20240619160923-72a9b26aa13d h1
github.com/berachain/beacon-kit/mod/errors v0.0.0-20240619160923-72a9b26aa13d/go.mod h1:iXa+Q+i0q+GCpLzkusulO57K5vlkDgM77jtfMr3QdFA=
github.com/berachain/beacon-kit/mod/execution v0.0.0-20240619160923-72a9b26aa13d h1:p8UdOD33FkAi4UtwfJijoV5enaZCqpgwg8xmhke9G5s=
github.com/berachain/beacon-kit/mod/execution v0.0.0-20240619160923-72a9b26aa13d/go.mod h1:pIDybEe5C7rDX3zPa9ykZUB7hs/hx3w5sMaWSzetm3I=
github.com/berachain/beacon-kit/mod/log v0.0.0-20240619152304-c7f6759c3dc8 h1:8z7sx/LqegoryVRn4WLJl4pxLbbPC3B8KCnU0kyL3ww=
github.com/berachain/beacon-kit/mod/log v0.0.0-20240619152304-c7f6759c3dc8/go.mod h1:Udmk/ZBCg+3vJM8XPP2dTeKJpC8q/7uW8JlMjihLXZ8=
github.com/berachain/beacon-kit/mod/log v0.0.0-20240619234034-fe96d94eafef h1:KYnx+uPEKHax/OOcIfkzELEvgkBOy+I3LhZk1p6rtwU=
github.com/berachain/beacon-kit/mod/log v0.0.0-20240619234034-fe96d94eafef/go.mod h1:xP5KcG56VfbPgz2ZRHerxm90MkjXMSDaGZNOOO5yfH4=
github.com/berachain/beacon-kit/mod/primitives v0.0.0-20240619160923-72a9b26aa13d h1:QenZm/U8SSnkS4o2WyoVMz20jIPw4dCzqkj1+jOdA40=
github.com/berachain/beacon-kit/mod/primitives v0.0.0-20240619160923-72a9b26aa13d/go.mod h1:xg8BworJAcrzTzbTgP/637Be89xAtrRzGkXKSzuRMkQ=
github.com/berachain/cosmos-sdk v0.46.0-beta2.0.20240529213909-58c32d695e1a h1:6RjerNG6Syl/vagTaQKbyZqxaKPSuehoAUMj2m5+89U=
Expand Down
Loading