Ejemplo n.º 1
0
 public BlockHandler(IHashCalculation hashCalculation, ICallNumberRepository callNumberRepository, ILogger <BlockHandler> logger,
                     BlockchainMetadata blockchainMetadata)
 {
     _hashCalculation      = hashCalculation;
     _callNumberRepository = callNumberRepository;
     _logger             = logger;
     _blockchainMetadata = blockchainMetadata;
 }
Ejemplo n.º 2
0
        public void TestBlockchainMetadataEquality()
        {
            var randomBlockchainMetadata = RandomData.RandomBlockchainMetadata();

            var sameBlockchainMetadata = new BlockchainMetadata
                                         (
                guid: randomBlockchainMetadata.Guid,
                rootBlockHash: randomBlockchainMetadata.RootBlockHash,
                totalWork: randomBlockchainMetadata.TotalWork
                                         );

            var differentGuid = Guid.NewGuid();

            while (differentGuid == randomBlockchainMetadata.Guid)
            {
                differentGuid = Guid.NewGuid();
            }

            var differentBlockchainMetadataGuid = new BlockchainMetadata
                                                  (
                guid: differentGuid,
                rootBlockHash: randomBlockchainMetadata.RootBlockHash,
                totalWork: randomBlockchainMetadata.TotalWork
                                                  );

            var differentBlockchainMetadataRootBlockHash = new BlockchainMetadata
                                                           (
                guid: randomBlockchainMetadata.Guid,
                rootBlockHash: ~randomBlockchainMetadata.RootBlockHash,
                totalWork: randomBlockchainMetadata.TotalWork
                                                           );

            var differentBlockchainMetadataTotalWork = new BlockchainMetadata
                                                       (
                guid: randomBlockchainMetadata.Guid,
                rootBlockHash: randomBlockchainMetadata.RootBlockHash,
                totalWork: ~randomBlockchainMetadata.TotalWork
                                                       );

            Assert.IsTrue(randomBlockchainMetadata.Equals(sameBlockchainMetadata));
            Assert.IsTrue(randomBlockchainMetadata == sameBlockchainMetadata);
            Assert.IsFalse(randomBlockchainMetadata != sameBlockchainMetadata);

            Assert.IsFalse(randomBlockchainMetadata.Equals(differentBlockchainMetadataGuid));
            Assert.IsFalse(randomBlockchainMetadata == differentBlockchainMetadataGuid);
            Assert.IsTrue(randomBlockchainMetadata != differentBlockchainMetadataGuid);

            Assert.IsFalse(randomBlockchainMetadata.Equals(differentBlockchainMetadataRootBlockHash));
            Assert.IsFalse(randomBlockchainMetadata == differentBlockchainMetadataRootBlockHash);
            Assert.IsTrue(randomBlockchainMetadata != differentBlockchainMetadataRootBlockHash);

            Assert.IsFalse(randomBlockchainMetadata.Equals(differentBlockchainMetadataTotalWork));
            Assert.IsFalse(randomBlockchainMetadata == differentBlockchainMetadataTotalWork);
            Assert.IsTrue(randomBlockchainMetadata != differentBlockchainMetadataTotalWork);
        }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            BlockchainMetadata.Init();

            //scenarios.JoinTheCause();

            scenarios.GetContractTotalInfluence();
            scenarios.GetAccountBalance();
            scenarios.TransferEth();
            Console.ReadLine();
        }
Ejemplo n.º 4
0
        public void TestBlockchainMetadataEquality()
        {
            var randomBlockchainMetadata = RandomData.RandomBlockchainMetadata();

            var sameBlockchainMetadata = new BlockchainMetadata
            (
                guid: randomBlockchainMetadata.Guid,
                rootBlockHash: randomBlockchainMetadata.RootBlockHash,
                totalWork: randomBlockchainMetadata.TotalWork
            );

            var differentGuid = Guid.NewGuid();
            while (differentGuid == randomBlockchainMetadata.Guid)
                differentGuid = Guid.NewGuid();

            var differentBlockchainMetadataGuid = new BlockchainMetadata
            (
                guid: differentGuid,
                rootBlockHash: randomBlockchainMetadata.RootBlockHash,
                totalWork: randomBlockchainMetadata.TotalWork
            );

            var differentBlockchainMetadataRootBlockHash = new BlockchainMetadata
            (
                guid: randomBlockchainMetadata.Guid,
                rootBlockHash: ~randomBlockchainMetadata.RootBlockHash,
                totalWork: randomBlockchainMetadata.TotalWork
            );

            var differentBlockchainMetadataTotalWork = new BlockchainMetadata
            (
                guid: randomBlockchainMetadata.Guid,
                rootBlockHash: randomBlockchainMetadata.RootBlockHash,
                totalWork: ~randomBlockchainMetadata.TotalWork
            );

            Assert.IsTrue(randomBlockchainMetadata.Equals(sameBlockchainMetadata));
            Assert.IsTrue(randomBlockchainMetadata == sameBlockchainMetadata);
            Assert.IsFalse(randomBlockchainMetadata != sameBlockchainMetadata);

            Assert.IsFalse(randomBlockchainMetadata.Equals(differentBlockchainMetadataGuid));
            Assert.IsFalse(randomBlockchainMetadata == differentBlockchainMetadataGuid);
            Assert.IsTrue(randomBlockchainMetadata != differentBlockchainMetadataGuid);

            Assert.IsFalse(randomBlockchainMetadata.Equals(differentBlockchainMetadataRootBlockHash));
            Assert.IsFalse(randomBlockchainMetadata == differentBlockchainMetadataRootBlockHash);
            Assert.IsTrue(randomBlockchainMetadata != differentBlockchainMetadataRootBlockHash);

            Assert.IsFalse(randomBlockchainMetadata.Equals(differentBlockchainMetadataTotalWork));
            Assert.IsFalse(randomBlockchainMetadata == differentBlockchainMetadataTotalWork);
            Assert.IsTrue(randomBlockchainMetadata != differentBlockchainMetadataTotalWork);
        }
 public QueryProcessor(IEnumerable <IQueryHandler> queryHandlers, BlockchainMetadata blockchainMetadata)
 {
     _queryHandlers      = queryHandlers;
     _blockchainMetadata = blockchainMetadata;
 }