public void LoadInDescendingEndBlockOrder() { string fixturePath = CreateFixtureCsvFile(); GoldDistribution[] records = GoldDistribution.LoadInDescendingEndBlockOrder(fixturePath); Assert.Equal(Fixture, records); }
public void Create( [Option("private-key", new[] { 'p' }, Description = "Hex encoded private key for gensis block")] string privateKeyHex, [Option('g', Description = "/path/to/nekoyume-unity/nekoyume/Assets/AddressableAssets/TableCSV")] string gameConfigDir, [Option('d', Description = "/path/to/nekoyume-unity/nekoyume/Assets/StreamingAssets/GoldDistribution.csv")] string goldDistributedPath, [Option('a', Description = "Number of activation keys to generate")] uint activationKeyCount, [Option("adminStateConfig", Description = "Config path to create AdminState")] string adminStateConfigPath, [Option("activatedAccountsList", Description = "List of accounts to be activated")] string activatedAccountsListPath = null, [Option('m', Description = "Config path to create AuthorizedMinersState")] string authorizedMinerConfigPath = null, [Option('c', Description = "Path of a plain text file containing names for credits.")] string creditsPath = null ) { Dictionary <string, string> tableSheets = Utils.ImportSheets(gameConfigDir); Utils.CreateActivationKey( out List <PendingActivationState> pendingActivationStates, out List <ActivationKey> activationKeys, activationKeyCount); GoldDistribution[] goldDistributions = GoldDistribution .LoadInDescendingEndBlockOrder(goldDistributedPath); AdminState adminState = Utils.GetAdminState(adminStateConfigPath); AuthorizedMinersState authorizedMinersState = null; if (!(authorizedMinerConfigPath is null)) { authorizedMinersState = Utils.GetAuthorizedMinersState(authorizedMinerConfigPath); } var activatedAccounts = activatedAccountsListPath is null ? ImmutableHashSet <Address> .Empty : Utils.GetActivatedAccounts(activatedAccountsListPath); Block <PolymorphicAction <ActionBase> > block = BlockHelper.MineGenesisBlock( tableSheets, goldDistributions, pendingActivationStates.ToArray(), adminState, authorizedMinersState: authorizedMinersState, activatedAccounts: activatedAccounts, isActivateAdminAddress: activationKeyCount != 0, credits: creditsPath is null ? null : File.ReadLines(creditsPath), privateKey: new PrivateKey(ByteUtil.ParseHex(privateKeyHex)) ); ExportBlock(block, "genesis-block"); ExportKeys(activationKeys, "keys.txt"); }
public static Block <PolymorphicAction <ActionBase> > MineGenesisBlock( PendingActivationState[] pendingActivationStates) { var tableSheets = Game.Game.GetTableCsvAssets(); string goldDistributionCsvPath = Path.Combine(Application.streamingAssetsPath, "GoldDistribution.csv"); GoldDistribution[] goldDistributions = GoldDistribution.LoadInDescendingEndBlockOrder(goldDistributionCsvPath); return(Nekoyume.BlockHelper.MineGenesisBlock( tableSheets, goldDistributions, pendingActivationStates, new AdminState(new Address("F9A15F870701268Bd7bBeA6502eB15F4997f32f9"), 1500000), isActivateAdminAddress: false)); }
public void Execute() { var gameConfigState = new GameConfigState(_sheets[nameof(GameConfigSheet)]); var redeemCodeListSheet = new RedeemCodeListSheet(); redeemCodeListSheet.Set(_sheets[nameof(RedeemCodeListSheet)]); var goldDistributionCsvPath = GoldDistributionTest.CreateFixtureCsvFile(); var goldDistributions = GoldDistribution.LoadInDescendingEndBlockOrder(goldDistributionCsvPath); var minterKey = new PrivateKey(); var ncg = new Currency("NCG", 2, minterKey.ToAddress()); var nonce = new byte[] { 0x00, 0x01, 0x02, 0x03 }; var privateKey = new PrivateKey(); (ActivationKey activationKey, PendingActivationState pendingActivation) = ActivationKey.Create(privateKey, nonce); var action = new InitializeStates( rankingState: new RankingState(), shopState: new ShopState(), tableSheets: _sheets, gameConfigState: gameConfigState, redeemCodeState: new RedeemCodeState(redeemCodeListSheet), adminAddressState: new AdminState( new Address("F9A15F870701268Bd7bBeA6502eB15F4997f32f9"), 1500000 ), activatedAccountsState: new ActivatedAccountsState(), goldCurrencyState: new GoldCurrencyState(ncg), goldDistributions: goldDistributions, pendingActivationStates: new[] { pendingActivation } ); var genesisState = action.Execute(new ActionContext() { BlockIndex = 0, Miner = default,