-
Notifications
You must be signed in to change notification settings - Fork 702
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
Remove snow.DefaultContextTest
#2518
Changes from 10 commits
6bf4918
8e55ce7
82736a8
149131c
837fa3c
810b95f
20b6a11
6af8ad8
cc63c56
74c070a
915a353
89d5200
e8bb2c6
5ee452e
3f6194d
1057700
cfba900
64f69d5
c65f28a
1d66446
215d615
f9c5742
ceede08
dfb4917
19f0e49
6fba171
7d26115
bfe0130
476a2b8
8545f74
82d3404
71bebdf
4ed8ae9
c29a4a0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,10 +12,13 @@ import ( | |
|
||
"github.com/stretchr/testify/require" | ||
|
||
"github.com/ava-labs/avalanchego/api/metrics" | ||
"github.com/ava-labs/avalanchego/ids" | ||
"github.com/ava-labs/avalanchego/snow" | ||
"github.com/ava-labs/avalanchego/snow/validators" | ||
"github.com/ava-labs/avalanchego/utils/constants" | ||
"github.com/ava-labs/avalanchego/utils/crypto/bls" | ||
"github.com/ava-labs/avalanchego/utils/logging" | ||
) | ||
|
||
var ( | ||
|
@@ -35,9 +38,28 @@ func (noOpAcceptor) Accept(*snow.ConsensusContext, ids.ID, []byte) error { | |
return nil | ||
} | ||
|
||
func EmptyContext() *snow.Context { | ||
sk, err := bls.NewSecretKey() | ||
if err != nil { | ||
panic(err) | ||
} | ||
pk := bls.PublicFromSecretKey(sk) | ||
return &snow.Context{ | ||
NetworkID: 0, | ||
SubnetID: ids.Empty, | ||
ChainID: ids.Empty, | ||
NodeID: ids.EmptyNodeID, | ||
PublicKey: pk, | ||
Log: logging.NoLog{}, | ||
BCLookup: ids.NewAliaser(), | ||
Metrics: metrics.NewOptionalGatherer(), | ||
ChainDataDir: "", | ||
} | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I know this is what we had before... but I still hate this... Are there places that we currently use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removed |
||
|
||
func ConsensusContext() *snow.ConsensusContext { | ||
return &snow.ConsensusContext{ | ||
Context: snow.DefaultContextTest(), | ||
Context: EmptyContext(), | ||
Registerer: prometheus.NewRegistry(), | ||
AvalancheRegisterer: prometheus.NewRegistry(), | ||
BlockAcceptor: noOpAcceptor{}, | ||
|
@@ -49,7 +71,7 @@ func ConsensusContext() *snow.ConsensusContext { | |
func Context(tb testing.TB, chainID ids.ID) *snow.Context { | ||
require := require.New(tb) | ||
|
||
ctx := snow.DefaultContextTest() | ||
ctx := EmptyContext() | ||
|
||
ctx.NetworkID = constants.UnitTestID | ||
ctx.SubnetID = constants.PrimaryNetworkID | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❤️