public void Execute() { var action = new CreateAvatar0() { avatarAddress = _avatarAddress, index = 0, hair = 0, ear = 0, lens = 0, tail = 0, name = "test", }; var gold = new GoldCurrencyState(new Currency("NCG", 2, minter: null)); var ranking = new RankingState0(); for (var i = 0; i < RankingState0.RankingMapCapacity; i++) { ranking.RankingMap[RankingState0.Derive(i)] = new HashSet <Address>().ToImmutableHashSet(); } var sheets = TableSheetsImporter.ImportSheets(); var state = new State() .SetState(GoldCurrencyState.Address, gold.Serialize()) .SetState( Addresses.GoldDistribution, GoldDistributionTest.Fixture.Select(v => v.Serialize()).Serialize() ) .SetState( Addresses.GameConfig, new GameConfigState(sheets[nameof(GameConfigSheet)]).Serialize() ) .SetState(Addresses.Ranking, ranking.Serialize()) .MintAsset(GoldCurrencyState.Address, gold.Currency * 100000000000); foreach (var(key, value) in sheets) { state = state.SetState(Addresses.TableSheet.Derive(key), value.Serialize()); } var nextState = action.Execute(new ActionContext() { PreviousStates = state, Signer = _agentAddress, BlockIndex = 0, }); Assert.Equal( 0, nextState.GetBalance(default, gold.Currency).MajorUnit
public InitializeStates( RankingState0 rankingState, ShopState shopState, Dictionary <string, string> tableSheets, GameConfigState gameConfigState, RedeemCodeState redeemCodeState, AdminState adminAddressState, ActivatedAccountsState activatedAccountsState, GoldCurrencyState goldCurrencyState, GoldDistribution[] goldDistributions, PendingActivationState[] pendingActivationStates, AuthorizedMinersState authorizedMinersState = null, CreditsState creditsState = null) { Ranking = (Bencodex.Types.Dictionary)rankingState.Serialize(); Shop = (Bencodex.Types.Dictionary)shopState.Serialize(); TableSheets = tableSheets; GameConfig = (Bencodex.Types.Dictionary)gameConfigState.Serialize(); RedeemCode = (Bencodex.Types.Dictionary)redeemCodeState.Serialize(); AdminAddress = (Bencodex.Types.Dictionary)adminAddressState.Serialize(); ActivatedAccounts = (Bencodex.Types.Dictionary)activatedAccountsState.Serialize(); GoldCurrency = (Bencodex.Types.Dictionary)goldCurrencyState.Serialize(); GoldDistributions = new Bencodex.Types.List( goldDistributions.Select(d => d.Serialize()).Cast <Bencodex.Types.IValue>() ); PendingActivations = new Bencodex.Types.List(pendingActivationStates.Select(p => p.Serialize())); if (!(authorizedMinersState is null)) { AuthorizedMiners = (Bencodex.Types.Dictionary)authorizedMinersState.Serialize(); } if (!(creditsState is null)) { Credits = (Bencodex.Types.Dictionary)creditsState.Serialize(); } }