Exemplo n.º 1
0
        public void ExecuteThrowShopItemExpiredError()
        {
            var sellerAvatarAddress = new PrivateKey().ToAddress();
            var sellerAgentAddress  = new PrivateKey().ToAddress();

            var(avatarState, agentState) = CreateAvatarState(sellerAgentAddress, sellerAvatarAddress);

            IAccountStateDelta previousStates = _initialState;
            var shopState = previousStates.GetShopState();

            var productId = Guid.NewGuid();
            var equipment = ItemFactory.CreateItemUsable(
                _tableSheets.EquipmentItemSheet.First,
                Guid.NewGuid(),
                10);

            shopState.Register(new ShopItem(
                                   sellerAgentAddress,
                                   sellerAvatarAddress,
                                   productId,
                                   new FungibleAssetValue(_goldCurrencyState.Currency, 100, 0),
                                   10,
                                   equipment));

            previousStates = previousStates
                             .SetState(Addresses.Shop, shopState.Serialize());
            shopState = previousStates.GetShopState();

            Assert.True(shopState.Products.ContainsKey(productId));
            var products = shopState.Products.Values
                           .Select(p => new BuyMultiple.PurchaseInfo(
                                       p.ProductId,
                                       p.SellerAgentAddress,
                                       p.SellerAvatarAddress))
                           .ToList();

            var action = new BuyMultiple
            {
                buyerAvatarAddress = _buyerAvatarAddress,
                purchaseInfos      = products,
            };

            action.Execute(new ActionContext()
            {
                BlockIndex     = 11,
                PreviousStates = previousStates,
                Random         = new TestRandom(),
                Signer         = _buyerAgentAddress,
            });

            var results     = action.buyerResult.purchaseResults;
            var isAllFailed = results.Any(r => r.errorCode == BuyMultiple.ERROR_CODE_SHOPITEM_EXPIRED);

            Assert.True(isAllFailed);
        }
Exemplo n.º 2
0
        public void Execute(ItemType itemType, string guid, bool contain)
        {
            var avatarState = _initialState.GetAvatarState(_avatarAddress);
            INonFungibleItem nonFungibleItem;
            Guid             itemId    = new Guid(guid);
            Guid             productId = itemId;
            ItemSubType      itemSubType;
            const long       requiredBlockIndex = 0;
            ShopState        legacyShopState    = _initialState.GetShopState();

            if (itemType == ItemType.Equipment)
            {
                var itemUsable = ItemFactory.CreateItemUsable(
                    _tableSheets.EquipmentItemSheet.First,
                    itemId,
                    requiredBlockIndex);
                nonFungibleItem = itemUsable;
                itemSubType     = itemUsable.ItemSubType;
            }
            else
            {
                var costume = ItemFactory.CreateCostume(_tableSheets.CostumeItemSheet.First, itemId);
                costume.Update(requiredBlockIndex);
                nonFungibleItem = costume;
                itemSubType     = costume.ItemSubType;
            }

            var result = new DailyReward2.DailyRewardResult()
            {
                id        = default,
Exemplo n.º 3
0
        public void Execute()
        {
            var shopState = _initialState.GetShopState();

            Assert.NotEmpty(shopState.Products);

            var(productId, shopItem) = shopState.Products.FirstOrDefault();
            Assert.NotNull(shopItem);

            var tax        = shopItem.Price.DivRem(100, out _) * Buy.TaxRate;
            var taxedPrice = shopItem.Price - tax;

            var buyAction = new Buy
            {
                buyerAvatarAddress  = _buyerAvatarAddress,
                productId           = productId,
                sellerAgentAddress  = _sellerAgentAddress,
                sellerAvatarAddress = _sellerAvatarAddress,
            };
            var nextState = buyAction.Execute(new ActionContext()
            {
                BlockIndex     = 0,
                PreviousStates = _initialState,
                Random         = new TestRandom(),
                Rehearsal      = false,
                Signer         = _buyerAgentAddress,
            });

            var nextShopState = nextState.GetShopState();

            Assert.Empty(nextShopState.Products);

            var nextBuyerAvatarState = nextState.GetAvatarState(_buyerAvatarAddress);

            Assert.True(
                nextBuyerAvatarState.inventory.TryGetNonFungibleItem(shopItem.ItemUsable.ItemId, out ItemUsable _));

            var goldCurrencyState = nextState.GetGoldCurrency();
            var goldCurrencyGold  = nextState.GetBalance(Addresses.GoldCurrency, goldCurrencyState);

            Assert.Equal(tax, goldCurrencyGold);
            var sellerGold = nextState.GetBalance(_sellerAgentAddress, goldCurrencyState);

            Assert.Equal(taxedPrice, sellerGold);
            var buyerGold = nextState.GetBalance(_buyerAgentAddress, goldCurrencyState);

            Assert.Equal(new FungibleAssetValue(goldCurrencyState, 0, 0), buyerGold);
        }
Exemplo n.º 4
0
        public void Execute(params ShopItemData[] shopItemMembers)
        {
            AvatarState          buyerAvatarState = _initialState.GetAvatarState(_buyerAvatarAddress);
            List <PurchaseInfo0> purchaseInfos    = new List <PurchaseInfo0>();
            Dictionary <Address, ShardedShopState> shardedShopStates = new Dictionary <Address, ShardedShopState>();
            ShopState legacyShopState = _initialState.GetShopState();

            foreach (var shopItemData in shopItemMembers)
            {
                (AvatarState sellerAvatarState, AgentState sellerAgentState) = CreateAvatarState(
                    shopItemData.SellerAgentAddress,
                    shopItemData.SellerAvatarAddress
                    );
                ITradableItem tradableItem;
                Guid          productId          = shopItemData.ProductId;
                Guid          itemId             = shopItemData.ItemId;
                long          requiredBlockIndex = shopItemData.RequiredBlockIndex;
                ItemSubType   itemSubType;
                if (shopItemData.ItemType == ItemType.Equipment)
                {
                    var itemUsable = ItemFactory.CreateItemUsable(
                        _tableSheets.EquipmentItemSheet.First,
                        itemId,
                        requiredBlockIndex);
                    tradableItem = itemUsable;
                    itemSubType  = itemUsable.ItemSubType;
                }
                else if (shopItemData.ItemType == ItemType.Costume)
                {
                    var costume = ItemFactory.CreateCostume(_tableSheets.CostumeItemSheet.First, itemId);
                    costume.Update(requiredBlockIndex);
                    tradableItem = costume;
                    itemSubType  = costume.ItemSubType;
                }
                else
                {
                    var material = ItemFactory.CreateTradableMaterial(
                        _tableSheets.MaterialItemSheet.OrderedList.First(r => r.ItemSubType == ItemSubType.Hourglass));
                    material.RequiredBlockIndex = requiredBlockIndex;
                    tradableItem = material;
                    itemSubType  = ItemSubType.Hourglass;
                }

                var result = new DailyReward2.DailyRewardResult()
                {
                    id        = default,
Exemplo n.º 5
0
        public void Execute()
        {
            var shopState = _initialState.GetShopState();

            Assert.Empty(shopState.Products);

            var avatarState = _initialState.GetAvatarState(_avatarAddress);

            Assert.Single(avatarState.inventory.Equipments);

            var equipment = avatarState.inventory.Equipments.FirstOrDefault();

            Assert.NotNull(equipment);

            var currencyState = _initialState.GetGoldCurrency();
            var price         = new FungibleAssetValue(currencyState, 100, 0);
            var sellAction    = new Sell0
            {
                itemId = equipment.ItemId,
                price  = price,
                sellerAvatarAddress = _avatarAddress,
            };
            var nextState = sellAction.Execute(new ActionContext
            {
                BlockIndex     = 0,
                PreviousStates = _initialState,
                Rehearsal      = false,
                Signer         = _agentAddress,
                Random         = new TestRandom(),
            });

            var nextAvatarState = nextState.GetAvatarState(_avatarAddress);

            Assert.Empty(nextAvatarState.inventory.Equipments);

            var nextShopState = nextState.GetShopState();

            Assert.Single(nextShopState.Products);

            var(_, shopItem) = nextShopState.Products.FirstOrDefault();
            Assert.NotNull(shopItem);
            Assert.Equal(equipment.ItemId, shopItem.ItemUsable.ItemId);
            Assert.Equal(price, shopItem.Price);
            Assert.Equal(_agentAddress, shopItem.SellerAgentAddress);
            Assert.Equal(_avatarAddress, shopItem.SellerAvatarAddress);
        }
Exemplo n.º 6
0
        public void ExecuteThrowInvalidAddressException()
        {
            var shopState = _initialState.GetShopState();
            var costume   = ItemFactory.CreateCostume(
                _tableSheets.CostumeItemSheet.First,
                Guid.NewGuid());

            shopState.Register(new ShopItem(
                                   _buyerAgentAddress,
                                   _buyerAvatarAddress,
                                   Guid.NewGuid(),
                                   new FungibleAssetValue(_goldCurrencyState.Currency, 100, 0),
                                   100,
                                   costume));

            _initialState = _initialState
                            .SetState(Addresses.Shop, shopState.Serialize());

            shopState = _initialState.GetShopState();
            var products = shopState.Products.Values
                           .Select(p => new BuyMultiple.PurchaseInfo(
                                       p.ProductId,
                                       p.SellerAgentAddress,
                                       p.SellerAvatarAddress))
                           .ToList();

            Assert.NotEmpty(products);

            var action = new BuyMultiple
            {
                buyerAvatarAddress = _buyerAvatarAddress,
                purchaseInfos      = products,
            };

            Assert.Throws <InvalidAddressException>(() => action.Execute(new ActionContext()
            {
                BlockIndex     = 0,
                PreviousStates = new State(),
                Random         = new TestRandom(),
                Signer         = _buyerAgentAddress,
            })
                                                    );
        }
Exemplo n.º 7
0
        public void Execute(params OrderData[] orderDataList)
        {
            AvatarState         buyerAvatarState = _initialState.GetAvatarState(_buyerAvatarAddress);
            List <PurchaseInfo> purchaseInfos    = new List <PurchaseInfo>();
            ShopState           legacyShopState  = _initialState.GetShopState();

            foreach (var orderData in orderDataList)
            {
                (AvatarState sellerAvatarState, AgentState sellerAgentState) = CreateAvatarState(
                    orderData.SellerAgentAddress,
                    orderData.SellerAvatarAddress
                    );
                ITradableItem tradableItem;
                Guid          orderId = orderData.OrderId;
                Guid          itemId  = orderData.TradableId;
                ItemSubType   itemSubType;
                if (orderData.ItemType == ItemType.Equipment)
                {
                    var itemUsable = ItemFactory.CreateItemUsable(
                        _tableSheets.EquipmentItemSheet.First,
                        itemId,
                        0);
                    tradableItem = itemUsable;
                    itemSubType  = itemUsable.ItemSubType;
                }
                else if (orderData.ItemType == ItemType.Costume)
                {
                    var costume = ItemFactory.CreateCostume(_tableSheets.CostumeItemSheet.First, itemId);
                    tradableItem = costume;
                    itemSubType  = costume.ItemSubType;
                }
                else
                {
                    var material = ItemFactory.CreateTradableMaterial(
                        _tableSheets.MaterialItemSheet.OrderedList.First(r => r.ItemSubType == ItemSubType.Hourglass));
                    tradableItem = material;
                    itemSubType  = ItemSubType.Hourglass;
                }

                var result = new DailyReward2.DailyRewardResult()
                {
                    id        = default,
Exemplo n.º 8
0
        public void Execute()
        {
            var shopState = _initialState.GetShopState();

            Assert.Single(shopState.Products);

            var(_, shopItem) = shopState.Products.FirstOrDefault();
            Assert.NotNull(shopItem);

            var avatarState = _initialState.GetAvatarState(_avatarAddress);

            Assert.False(avatarState.inventory.TryGetNonFungibleItem(
                             shopItem.ItemUsable.ItemId,
                             out ItemUsable _));

            var sellCancellationAction = new SellCancellation
            {
                productId           = shopItem.ProductId,
                sellerAvatarAddress = _avatarAddress,
            };
            var nextState = sellCancellationAction.Execute(new ActionContext
            {
                BlockIndex     = 0,
                PreviousStates = _initialState,
                Random         = new ItemEnhancementTest.TestRandom(),
                Rehearsal      = false,
                Signer         = _agentAddress,
            });

            var nextShopState = nextState.GetShopState();

            Assert.Empty(nextShopState.Products);

            var nextAvatarState = nextState.GetAvatarState(_avatarAddress);

            Assert.True(nextAvatarState.inventory.TryGetNonFungibleItem(
                            shopItem.ItemUsable.ItemId,
                            out ItemUsable _));
        }
Exemplo n.º 9
0
        public void Execute(ItemType itemType, string guid, bool contain, int itemCount, int inventoryCount, int prevCount, int expectedCount)
        {
            var           avatarState = _initialState.GetAvatarState(_avatarAddress);
            ITradableItem tradableItem;
            Guid          itemId    = new Guid(guid);
            Guid          productId = itemId;
            ItemSubType   itemSubType;
            const long    requiredBlockIndex = Sell6.ExpiredBlockIndex;
            ShopState     legacyShopState    = _initialState.GetShopState();

            if (itemType == ItemType.Equipment)
            {
                var itemUsable = ItemFactory.CreateItemUsable(
                    _tableSheets.EquipmentItemSheet.First,
                    itemId,
                    requiredBlockIndex);
                tradableItem = itemUsable;
                itemSubType  = itemUsable.ItemSubType;
            }
            else if (itemType == ItemType.Costume)
            {
                var costume = ItemFactory.CreateCostume(_tableSheets.CostumeItemSheet.First, itemId);
                costume.Update(requiredBlockIndex);
                tradableItem = costume;
                itemSubType  = costume.ItemSubType;
            }
            else
            {
                var material = ItemFactory.CreateTradableMaterial(
                    _tableSheets.MaterialItemSheet.OrderedList.First(r => r.ItemSubType == ItemSubType.Hourglass));
                itemSubType = material.ItemSubType;
                material.RequiredBlockIndex = requiredBlockIndex;
                tradableItem = material;
            }

            var result = new DailyReward2.DailyRewardResult()
            {
                id        = default,
Exemplo n.º 10
0
        public void Execute()
        {
            var shopState = _initialState.GetShopState();

            Assert.Empty(shopState.Products);

            var avatarState = _initialState.GetAvatarState(_avatarAddress);

            Assert.Single(avatarState.inventory.Equipments);

            var equipment = avatarState.inventory.Equipments.FirstOrDefault();

            Assert.NotNull(equipment);

            var consumable = avatarState.inventory.Consumables.FirstOrDefault();

            Assert.NotNull(equipment);

            var costume = avatarState.inventory.Costumes.FirstOrDefault();

            Assert.NotNull(costume);

            var items = new INonFungibleItem[] { equipment, consumable, costume };

            var previousStates = _initialState;
            var currencyState  = previousStates.GetGoldCurrency();
            var price          = new FungibleAssetValue(currencyState, ProductPrice, 0);

            var productCount = 0;
            var random       = new TestRandom();

            foreach (var nonFungibleItem in items)
            {
                var sellAction = new Sell3
                {
                    itemId = nonFungibleItem.ItemId,
                    price  = price,
                    sellerAvatarAddress = _avatarAddress,
                };

                var nextState = sellAction.Execute(new ActionContext
                {
                    BlockIndex     = 0,
                    PreviousStates = previousStates,
                    Rehearsal      = false,
                    Signer         = _agentAddress,
                    Random         = random,
                });

                productCount++;

                var nextAvatarState = nextState.GetAvatarState(_avatarAddress);
                Assert.Empty(nextAvatarState.inventory.Equipments);

                var nextShopState = nextState.GetShopState();

                Assert.Equal(productCount, nextShopState.Products.Count);

                var products = nextShopState.Products.Values;
                Assert.NotNull(products);

                var shopItem = nonFungibleItem is Costume?
                               products.First(x => x.Costume != null) :
                                   products.First(x => x.ItemUsable != null);

                Assert.Equal(price, shopItem.Price);
                Assert.Equal(_agentAddress, shopItem.SellerAgentAddress);
                Assert.Equal(_avatarAddress, shopItem.SellerAvatarAddress);

                previousStates = nextState;
            }
        }
Exemplo n.º 11
0
        public void Execute()
        {
            var shopState     = _initialState.GetShopState();
            var productsCount = shopState.Products.Count;
            var shopItems     = shopState.Products.Values.ToList();

            Assert.NotNull(shopItems);
            var previousStates = _initialState;
            var avatarState    = previousStates.GetAvatarState(_avatarAddress);

            foreach (var shopItem in shopItems)
            {
                if (shopItem.ItemUsable != null)
                {
                    Assert.False(avatarState.inventory.TryGetNonFungibleItem <ItemUsable>(
                                     shopItem.ItemUsable.ItemId, out _));

                    var sellCancellationAction = new SellCancellation4
                    {
                        productId           = shopItem.ProductId,
                        sellerAvatarAddress = _avatarAddress,
                    };
                    var nextState = sellCancellationAction.Execute(new ActionContext
                    {
                        BlockIndex     = 0,
                        PreviousStates = previousStates,
                        Random         = new TestRandom(),
                        Rehearsal      = false,
                        Signer         = _agentAddress,
                    });
                    productsCount--;

                    var nextShopState = nextState.GetShopState();
                    Assert.Equal(productsCount, nextShopState.Products.Count);

                    var nextAvatarState = nextState.GetAvatarState(_avatarAddress);
                    Assert.True(nextAvatarState.inventory.TryGetNonFungibleItem <ItemUsable>(
                                    shopItem.ItemUsable.ItemId, out _));

                    previousStates = nextState;
                }

                if (shopItem.Costume != null)
                {
                    Assert.False(avatarState.inventory.TryGetNonFungibleItem <Costume>(
                                     shopItem.Costume.ItemId, out var _));

                    var sellCancellationAction = new SellCancellation4
                    {
                        productId           = shopItem.ProductId,
                        sellerAvatarAddress = _avatarAddress,
                    };
                    var nextState = sellCancellationAction.Execute(new ActionContext
                    {
                        BlockIndex     = 0,
                        PreviousStates = previousStates,
                        Random         = new TestRandom(),
                        Rehearsal      = false,
                        Signer         = _agentAddress,
                    });
                    productsCount--;

                    var nextShopState = nextState.GetShopState();
                    Assert.Equal(productsCount, nextShopState.Products.Count);

                    var nextAvatarState = nextState.GetAvatarState(_avatarAddress);
                    Assert.True(nextAvatarState.inventory.TryGetNonFungibleItem <Costume>(
                                    shopItem.Costume.ItemId, out _));

                    previousStates = nextState;
                }
            }
        }
Exemplo n.º 12
0
        public void Execute(ItemType itemType, bool shopItemExist, int blockIndex)
        {
            var shopState = _initialState.GetShopState();

            Assert.Empty(shopState.Products);

            var avatarState = _initialState.GetAvatarState(_avatarAddress);
            List <Inventory.Item> inventoryItem = avatarState.inventory.Items.Where(i => i.item.ItemType == itemType).ToList();

            Assert.Single(inventoryItem);
            var previousStates = _initialState;
            var currencyState  = previousStates.GetGoldCurrency();
            var price          = new FungibleAssetValue(currencyState, ProductPrice, 0);
            INonFungibleItem nonFungibleItem = (INonFungibleItem)inventoryItem.First().item;

            nonFungibleItem.Update(blockIndex);
            Assert.Equal(blockIndex, nonFungibleItem.RequiredBlockIndex);

            if (shopItemExist)
            {
                var si = new ShopItem(
                    _agentAddress,
                    _avatarAddress,
                    Guid.NewGuid(),
                    new FungibleAssetValue(currencyState, 100, 0),
                    blockIndex,
                    nonFungibleItem);
                shopState.Register(si);
                previousStates = previousStates.SetState(Addresses.Shop, shopState.Serialize());
                Assert.Single(shopState.Products);
            }
            else
            {
                Assert.Empty(shopState.Products);
            }

            var sellAction = new Sell
            {
                itemId = nonFungibleItem.ItemId,
                price  = price,
                sellerAvatarAddress = _avatarAddress,
            };

            var nextState = sellAction.Execute(new ActionContext
            {
                BlockIndex     = 1,
                PreviousStates = previousStates,
                Rehearsal      = false,
                Signer         = _agentAddress,
                Random         = new TestRandom(),
            });

            const long expiredBlockIndex = Sell.ExpiredBlockIndex + 1;
            var        nextAvatarState   = nextState.GetAvatarState(_avatarAddress);

            Assert.True(nextAvatarState.inventory.TryGetNonFungibleItem(nonFungibleItem.ItemId, out var nextItem));
            INonFungibleItem nextNonFungibleItem = (INonFungibleItem)nextItem.item;

            Assert.Equal(expiredBlockIndex, nextNonFungibleItem.RequiredBlockIndex);

            var nextShopState = nextState.GetShopState();

            Assert.Single(nextShopState.Products);

            var products = nextShopState.Products.Values;

            var shopItem          = products.First();
            INonFungibleItem item = itemType == ItemType.Costume ? (INonFungibleItem)shopItem.Costume : shopItem.ItemUsable;

            Assert.Equal(price, shopItem.Price);
            Assert.Equal(expiredBlockIndex, shopItem.ExpiredBlockIndex);
            Assert.Equal(expiredBlockIndex, item.RequiredBlockIndex);
            Assert.Equal(_agentAddress, shopItem.SellerAgentAddress);
            Assert.Equal(_avatarAddress, shopItem.SellerAvatarAddress);

            var mailList = nextAvatarState.mailBox.Where(m => m is SellCancelMail).ToList();

            Assert.Single(mailList);

            Assert.Equal(expiredBlockIndex, mailList.First().requiredBlockIndex);
        }
Exemplo n.º 13
0
        public void SerializeWithDotnetAPI()
        {
            var sellerAvatarAddress = new PrivateKey().ToAddress();
            var sellerAgentAddress  = new PrivateKey().ToAddress();

            CreateAvatarState(sellerAgentAddress, sellerAvatarAddress);

            IAccountStateDelta previousStates = _initialState;
            var shopState = previousStates.GetShopState();

            var productId = Guid.NewGuid();
            var equipment = ItemFactory.CreateItemUsable(
                _tableSheets.EquipmentItemSheet.First,
                Guid.NewGuid(),
                0);

            shopState.Register(new ShopItem(
                                   sellerAgentAddress,
                                   sellerAvatarAddress,
                                   productId,
                                   new FungibleAssetValue(_goldCurrencyState.Currency, 100, 0),
                                   100,
                                   equipment));
            shopState.Register(new ShopItem(
                                   sellerAgentAddress,
                                   sellerAvatarAddress,
                                   Guid.NewGuid(),
                                   new FungibleAssetValue(_goldCurrencyState.Currency, 100, 0),
                                   100,
                                   equipment));
            var products = shopState.Products.Values
                           .Select(p => new BuyMultiple.PurchaseInfo(
                                       p.ProductId,
                                       p.SellerAgentAddress,
                                       p.SellerAvatarAddress))
                           .ToList();

            previousStates = previousStates
                             .SetState(Addresses.Shop, shopState.Serialize());

            var action = new BuyMultiple
            {
                buyerAvatarAddress = _buyerAvatarAddress,
                purchaseInfos      = products,
            };

            action.Execute(new ActionContext()
            {
                BlockIndex     = 1,
                PreviousStates = previousStates,
                Random         = new TestRandom(),
                Signer         = _buyerAgentAddress,
            });

            var formatter = new BinaryFormatter();

            using var ms = new MemoryStream();
            formatter.Serialize(ms, action);
            ms.Seek(0, SeekOrigin.Begin);

            var deserialized = (BuyMultiple)formatter.Deserialize(ms);

            Assert.Equal(action.PlainValue, deserialized.PlainValue);
        }
Exemplo n.º 14
0
        public void ExecuteInsufficientBalanceError()
        {
            var shopState = _initialState.GetShopState();

            var sellerAvatarAddress = new PrivateKey().ToAddress();
            var sellerAgentAddress  = new PrivateKey().ToAddress();

            var(avatarState, agentState) = CreateAvatarState(sellerAgentAddress, sellerAvatarAddress);

            var equipment = ItemFactory.CreateItemUsable(
                _tableSheets.EquipmentItemSheet.First,
                Guid.NewGuid(),
                1);

            shopState.Register(new ShopItem(
                                   sellerAgentAddress,
                                   sellerAvatarAddress,
                                   Guid.NewGuid(),
                                   new FungibleAssetValue(_goldCurrencyState.Currency, 1, 0),
                                   100,
                                   equipment));

            var costume = ItemFactory.CreateCostume(
                _tableSheets.CostumeItemSheet.First,
                Guid.NewGuid());

            shopState.Register(new ShopItem(
                                   sellerAgentAddress,
                                   sellerAvatarAddress,
                                   Guid.NewGuid(),
                                   new FungibleAssetValue(_goldCurrencyState.Currency, 100, 0),
                                   100,
                                   costume));

            _initialState = _initialState
                            .SetState(Addresses.Shop, shopState.Serialize());
            shopState = _initialState.GetShopState();
            Assert.NotEmpty(shopState.Products);

            var products = shopState.Products.Values
                           .Select(p => new BuyMultiple.PurchaseInfo(
                                       p.ProductId,
                                       p.SellerAgentAddress,
                                       p.SellerAvatarAddress))
                           .ToList();

            Assert.NotEmpty(products);

            var balance = _initialState.GetBalance(_buyerAgentAddress, _goldCurrencyState.Currency);

            _initialState = _initialState.BurnAsset(_buyerAgentAddress, balance);

            var action = new BuyMultiple
            {
                buyerAvatarAddress = _buyerAvatarAddress,
                purchaseInfos      = products,
            };

            action.Execute(new ActionContext()
            {
                BlockIndex     = 0,
                PreviousStates = _initialState,
                Random         = new TestRandom(),
                Signer         = _buyerAgentAddress,
            });

            var results     = action.buyerResult.purchaseResults;
            var isAllFailed = results.Any(r => r.errorCode == BuyMultiple.ERROR_CODE_INSUFFICIENT_BALANCE);

            Assert.True(isAllFailed);
        }