Exemplo n.º 1
0
 def mine(self, block : Block):
     while True:
         index = self.__index_generator.next()
         block_object = str(index) + str(block.time_stamp) + str(block.data) + str(block.pre_hash)
         block_hash = self.__hash_generator.generate(block_object)
         if self.__policy.check(block_hash):
             block.index = index
             block.block_hash = block_hash
             return block
Exemplo n.º 2
0
 def test_CreateABlockWhenSetAPropertyThenItCouldNotBeSetAgain(self):
     block = Block(0, 0, "hello", "123", "456")
     block.index = 1
     block.time_stamp = 1
     block.data = "bye"
     block.pre_hash = "789"
     block.block_hash = "100"
     assert_that(block.index, equal_to(0))
     assert_that(block.time_stamp, equal_to(0))
     assert_that(block.data, equal_to("hello"))
     assert_that(block.pre_hash, equal_to("123"))
     assert_that(block.block_hash, equal_to("456"))