コード例 #1
0
        public void AssignPool()
        {
            TransactionPoolRepository poolRepo = new TransactionPoolRepository();

            Pool = poolRepo.Get(PoolId);
            Pool.QueueUp();
        }
コード例 #2
0
        public void RepositoriesFullInsert()
        {
            DigitalSignatureUtils.AssignKeyPair("addr3");

            TransactionPoolRepository tpr = new TransactionPoolRepository();

            TransactionPool tp = new TransactionPool
            {
                Timestamp = DateTime.Now
            };

            int poolId = tpr.Add(tp);

            Assert.AreEqual(poolId, tpr.Get(poolId).Id);

            TransactionRepository tr = new TransactionRepository();

            Transaction t = new Transaction
            {
                PoolId      = poolId,
                SenderId    = 6,
                RecipientId = 1,
                Amount      = 10,
                Status      = TransactionStatus.confirmed.ToString(),
                Timestamp   = DateTime.Now
            };

            int transactionId = tr.Add(t);

            Assert.AreEqual(transactionId, tr.Get(transactionId).Id);

            BlockRepository br = new BlockRepository();

            Block b = new Block
            {
                PoolId       = poolId,
                PreviousHash = br.Get().Last().Hash,
                Timestamp    = DateTime.Now
            };

            b.AssignPool();

            b.ComputeHash();

            b.Signature = Convert.ToBase64String(
                DigitalSignatureUtils.SignData(
                    Convert.FromBase64String(
                        b.Hash
                        )
                    )
                );

            int blockId = br.Add(b);

            Assert.AreEqual(blockId, br.Get(blockId).Id);
        }