Skip to content

Commit

Permalink
Move snow.DefaultConsensusContextTest to snowtest.ConsensusContext (
Browse files Browse the repository at this point in the history
  • Loading branch information
dhrubabasu authored Dec 19, 2023
1 parent fa21d78 commit 7140a84
Show file tree
Hide file tree
Showing 20 changed files with 139 additions and 119 deletions.
8 changes: 4 additions & 4 deletions indexer/index_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import (
"github.com/ava-labs/avalanchego/database/memdb"
"github.com/ava-labs/avalanchego/database/versiondb"
"github.com/ava-labs/avalanchego/ids"
"github.com/ava-labs/avalanchego/snow"
"github.com/ava-labs/avalanchego/snow/snowtest"
"github.com/ava-labs/avalanchego/utils"
"github.com/ava-labs/avalanchego/utils/logging"
"github.com/ava-labs/avalanchego/utils/set"
Expand All @@ -28,7 +28,7 @@ func TestIndex(t *testing.T) {
require.NoError(codec.RegisterCodec(codecVersion, linearcodec.NewDefault()))
baseDB := memdb.New()
db := versiondb.New(baseDB)
ctx := snow.DefaultConsensusContextTest()
ctx := snowtest.ConsensusContext()

indexIntf, err := newIndex(db, logging.NoLog{}, codec, mockable.Clock{})
require.NoError(err)
Expand Down Expand Up @@ -116,7 +116,7 @@ func TestIndexGetContainerByRangeMaxPageSize(t *testing.T) {
codec := codec.NewDefaultManager()
require.NoError(codec.RegisterCodec(codecVersion, linearcodec.NewDefault()))
db := memdb.New()
ctx := snow.DefaultConsensusContextTest()
ctx := snowtest.ConsensusContext()
indexIntf, err := newIndex(db, logging.NoLog{}, codec, mockable.Clock{})
require.NoError(err)
idx := indexIntf.(*index)
Expand Down Expand Up @@ -156,7 +156,7 @@ func TestDontIndexSameContainerTwice(t *testing.T) {
codec := codec.NewDefaultManager()
require.NoError(codec.RegisterCodec(codecVersion, linearcodec.NewDefault()))
db := memdb.New()
ctx := snow.DefaultConsensusContextTest()
ctx := snowtest.ConsensusContext()
idx, err := newIndex(db, logging.NoLog{}, codec, mockable.Clock{})
require.NoError(err)

Expand Down
9 changes: 5 additions & 4 deletions indexer/indexer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"github.com/ava-labs/avalanchego/snow"
"github.com/ava-labs/avalanchego/snow/engine/avalanche/vertex"
"github.com/ava-labs/avalanchego/snow/engine/snowman/block/mocks"
"github.com/ava-labs/avalanchego/snow/snowtest"
"github.com/ava-labs/avalanchego/utils"
"github.com/ava-labs/avalanchego/utils/logging"
)
Expand Down Expand Up @@ -153,7 +154,7 @@ func TestIndexer(t *testing.T) {
idxr.clock.Set(now)

// Assert state is right
chain1Ctx := snow.DefaultConsensusContextTest()
chain1Ctx := snowtest.ConsensusContext()
chain1Ctx.ChainID = ids.GenerateTestID()
isIncomplete, err := idxr.isIncomplete(chain1Ctx.ChainID)
require.NoError(err)
Expand Down Expand Up @@ -258,7 +259,7 @@ func TestIndexer(t *testing.T) {
require.Contains(server.endpoints, "/block")

// Register a DAG chain
chain2Ctx := snow.DefaultConsensusContextTest()
chain2Ctx := snowtest.ConsensusContext()
chain2Ctx.ChainID = ids.GenerateTestID()
isIncomplete, err = idxr.isIncomplete(chain2Ctx.ChainID)
require.NoError(err)
Expand Down Expand Up @@ -418,7 +419,7 @@ func TestIncompleteIndex(t *testing.T) {
require.False(idxr.indexingEnabled)

// Register a chain
chain1Ctx := snow.DefaultConsensusContextTest()
chain1Ctx := snowtest.ConsensusContext()
chain1Ctx.ChainID = ids.GenerateTestID()
isIncomplete, err := idxr.isIncomplete(chain1Ctx.ChainID)
require.NoError(err)
Expand Down Expand Up @@ -501,7 +502,7 @@ func TestIgnoreNonDefaultChains(t *testing.T) {
idxr := idxrIntf.(*indexer)

// Assert state is right
chain1Ctx := snow.DefaultConsensusContextTest()
chain1Ctx := snowtest.ConsensusContext()
chain1Ctx.ChainID = ids.GenerateTestID()
chain1Ctx.SubnetID = ids.GenerateTestID()

Expand Down
4 changes: 2 additions & 2 deletions network/test_network.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ import (
"github.com/ava-labs/avalanchego/network/dialer"
"github.com/ava-labs/avalanchego/network/peer"
"github.com/ava-labs/avalanchego/network/throttling"
"github.com/ava-labs/avalanchego/snow"
"github.com/ava-labs/avalanchego/snow/networking/router"
"github.com/ava-labs/avalanchego/snow/networking/tracker"
"github.com/ava-labs/avalanchego/snow/snowtest"
"github.com/ava-labs/avalanchego/snow/uptime"
"github.com/ava-labs/avalanchego/snow/validators"
"github.com/ava-labs/avalanchego/staking"
Expand Down Expand Up @@ -187,7 +187,7 @@ func NewTestNetwork(
networkConfig.TLSConfig = tlsConfig
networkConfig.TLSKey = tlsCert.PrivateKey.(crypto.Signer)

ctx := snow.DefaultConsensusContextTest()
ctx := snowtest.ConsensusContext()
beacons := validators.NewManager()
networkConfig.Validators = currentValidators
networkConfig.Beacons = beacons
Expand Down
7 changes: 0 additions & 7 deletions snow/acceptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
)

var (
_ Acceptor = noOpAcceptor{}
_ Acceptor = acceptorWrapper{}

_ AcceptorGroup = (*acceptorGroup)(nil)
Expand All @@ -31,12 +30,6 @@ type Acceptor interface {
Accept(ctx *ConsensusContext, containerID ids.ID, container []byte) error
}

type noOpAcceptor struct{}

func (noOpAcceptor) Accept(*ConsensusContext, ids.ID, []byte) error {
return nil
}

type acceptorWrapper struct {
Acceptor

Expand Down
Loading

0 comments on commit 7140a84

Please sign in to comment.