示例#1
0
        public void CreateKittyChainTest()
        {
            var blockchain = new KittyChain();

            blockchain.InitializeChain();

            Assert.Single(blockchain.Chain);

            var blockchain2 = new KittyChain(GetBlocks(), new List <Transfer>());

            Assert.True(blockchain2.IsValid());
        }
示例#2
0
        public void GetBalanceTest()
        {
            var blockchain2 = new KittyChain(GetBlocks(), new List <Transfer>());

            var user1 = new User("a");
            var user2 = new User("b");
            var user3 = new User("c");

            Assert.Equal(30, blockchain2.GetBalance(user1.PublicAddress, blockchain2.Chain.ToArray(), blockchain2.PendingTransfers.ToArray()));
            Assert.Equal(-65, blockchain2.GetBalance(user2.PublicAddress, blockchain2.Chain.ToArray(), blockchain2.PendingTransfers.ToArray()));
            Assert.Equal(10, blockchain2.GetBalance(user3.PublicAddress, blockchain2.Chain.ToArray(), blockchain2.PendingTransfers.ToArray()));
        }
示例#3
0
        public MainViewModel()
        {
            #region Set the Commands

            RegisterCommand = new DelegateCommand(RegisterMethod);

            #endregion

            BlockChainWaitingList = new List <Guid>();

            Client             = new Client();
            Client.NewMessage += NewMessage;

            try
            {
                BlockChain = JsonConvert.DeserializeObject <KittyChain>(File.ReadAllText(Constants.SAVE_FILENAME));
            }
            catch (Exception)
            {
                BlockChain.InitializeChain();
            }
        }