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

Remove duplicate genesis creations in P-chain unit tests #3318

Merged
merged 29 commits into from
Aug 23, 2024
Merged
Changes from 1 commit
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
22 changes: 15 additions & 7 deletions vms/platformvm/genesis/genesistest/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ import (
"github.com/ava-labs/avalanchego/utils/constants"
"github.com/ava-labs/avalanchego/utils/units"
"github.com/ava-labs/avalanchego/vms/components/avax"
"github.com/ava-labs/avalanchego/vms/platformvm/genesis"
"github.com/ava-labs/avalanchego/vms/platformvm/reward"
"github.com/ava-labs/avalanchego/vms/platformvm/txs"
"github.com/ava-labs/avalanchego/vms/secp256k1fx"

avalanchegenesis "github.com/ava-labs/avalanchego/genesis"
platformvmgenesis "github.com/ava-labs/avalanchego/vms/platformvm/genesis"
)

var (
Expand All @@ -29,17 +31,17 @@ var (
ValidatorDuration = 28 * 24 * time.Hour
ValidatorEndTime = Time.Add(ValidatorDuration)
ValidatorEndTimeUnix = uint64(ValidatorEndTime.Unix())
ValidatorWeight = units.Avax
ValidatorWeight = units.MegaAvax
ValidatorRewardsOwner = &secp256k1fx.OutputOwners{}
ValidatorDelegationShares uint32 = reward.PercentDenominator

XChainName = "x"

InitialBalance = units.Schmeckle
InitialBalance = 30 * units.MegaAvax
InitialSupply = ValidatorWeight + InitialBalance
)

func New(t testing.TB) *genesis.Genesis {
func New(t testing.TB) *platformvmgenesis.Genesis {
require := require.New(t)

genesisValidator := &txs.AddValidatorTx{
Expand Down Expand Up @@ -72,8 +74,8 @@ func New(t testing.TB) *genesis.Genesis {
genesisChainTx := &txs.Tx{Unsigned: genesisChain}
require.NoError(genesisChainTx.Initialize(txs.Codec))

return &genesis.Genesis{
UTXOs: []*genesis.UTXO{
return &platformvmgenesis.Genesis{
UTXOs: []*platformvmgenesis.UTXO{
{
UTXO: avax.UTXO{
UTXOID: avax.UTXOID{
Expand All @@ -83,6 +85,12 @@ func New(t testing.TB) *genesis.Genesis {
Asset: AVAXAsset,
Out: &secp256k1fx.TransferOutput{
Amt: InitialBalance,
OutputOwners: secp256k1fx.OutputOwners{
Threshold: 1,
Addrs: []ids.ShortID{
avalanchegenesis.EWOQKey.Address(),
},
},
},
},
Message: nil,
Expand All @@ -101,7 +109,7 @@ func New(t testing.TB) *genesis.Genesis {

func NewBytes(t testing.TB) []byte {
g := New(t)
genesisBytes, err := genesis.Codec.Marshal(genesis.CodecVersion, g)
genesisBytes, err := platformvmgenesis.Codec.Marshal(platformvmgenesis.CodecVersion, g)
require.NoError(t, err)
return genesisBytes
}
Loading