Skip to content

Commit

Permalink
Remove unused BuildGenesisTest function (#2503)
Browse files Browse the repository at this point in the history
  • Loading branch information
dhrubabasu authored Dec 19, 2023
1 parent 44d71db commit 7a9bdad
Showing 1 changed file with 0 additions and 72 deletions.
72 changes: 0 additions & 72 deletions vms/platformvm/vm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,78 +243,6 @@ func defaultGenesis(t *testing.T) (*api.BuildGenesisArgs, []byte) {
return &buildGenesisArgs, genesisBytes
}

// Returns:
// 1) The genesis state
// 2) The byte representation of the default genesis for tests
func BuildGenesisTest(t *testing.T) (*api.BuildGenesisArgs, []byte) {
return BuildGenesisTestWithArgs(t, nil)
}

// Returns:
// 1) The genesis state
// 2) The byte representation of the default genesis for tests
func BuildGenesisTestWithArgs(t *testing.T, args *api.BuildGenesisArgs) (*api.BuildGenesisArgs, []byte) {
require := require.New(t)
genesisUTXOs := make([]api.UTXO, len(keys))
for i, key := range keys {
id := key.PublicKey().Address()
addr, err := address.FormatBech32(constants.UnitTestHRP, id.Bytes())
require.NoError(err)

genesisUTXOs[i] = api.UTXO{
Amount: json.Uint64(defaultBalance),
Address: addr,
}
}

genesisValidators := make([]api.GenesisPermissionlessValidator, len(genesisNodeIDs))
for i, nodeID := range genesisNodeIDs {
addr, err := address.FormatBech32(constants.UnitTestHRP, nodeID.Bytes())
require.NoError(err)

genesisValidators[i] = api.GenesisPermissionlessValidator{
GenesisValidator: api.GenesisValidator{
StartTime: json.Uint64(defaultValidateStartTime.Unix()),
EndTime: json.Uint64(defaultValidateEndTime.Unix()),
NodeID: nodeID,
},
RewardOwner: &api.Owner{
Threshold: 1,
Addresses: []string{addr},
},
Staked: []api.UTXO{{
Amount: json.Uint64(defaultWeight),
Address: addr,
}},
DelegationFee: reward.PercentDenominator,
}
}

buildGenesisArgs := api.BuildGenesisArgs{
NetworkID: json.Uint32(constants.UnitTestID),
AvaxAssetID: avaxAssetID,
UTXOs: genesisUTXOs,
Validators: genesisValidators,
Chains: nil,
Time: json.Uint64(defaultGenesisTime.Unix()),
InitialSupply: json.Uint64(360 * units.MegaAvax),
Encoding: formatting.Hex,
}

if args != nil {
buildGenesisArgs = *args
}

buildGenesisResponse := api.BuildGenesisReply{}
platformvmSS := api.StaticService{}
require.NoError(platformvmSS.BuildGenesis(nil, &buildGenesisArgs, &buildGenesisResponse))

genesisBytes, err := formatting.Decode(buildGenesisResponse.Encoding, buildGenesisResponse.Bytes)
require.NoError(err)

return &buildGenesisArgs, genesisBytes
}

func defaultVM(t *testing.T, fork activeFork) (*VM, database.Database, *mutableSharedMemory) {
require := require.New(t)
var (
Expand Down

0 comments on commit 7a9bdad

Please sign in to comment.