Esempio n. 1
0
    def test_if_old_blocks_get_should_return_old_block_first(self, b):
        # create two blocks
        block_1 = b.create_block([])
        block_2 = b.create_block([])

        # write the blocks
        b.write_block(block_1, durability='hard')
        b.write_block(block_2, durability='hard')

        new_blocks = mp.Queue()
        bs = BlockStream(new_blocks)

        # assert len(list(bs.old_blocks)) == 2
        # import pdb; pdb.set_trace()
        # from pprint import pprint as pp
        # pp(bs.old_blocks)
        # pp(block_1)
        # pp(block_2)

        # create two new blocks that will appear in the changefeed
        block_3 = b.create_block([])
        block_4 = b.create_block([])

        # simulate a changefeed
        new_blocks.put(block_3)
        new_blocks.put(block_4)

        assert len(bs.unvoted_blocks) == 2

        # and check if we get the old blocks first
        assert bs.get() == block_1
        assert bs.get() == block_2
        assert bs.get() == block_3
        assert bs.get() == block_4
Esempio n. 2
0
    def test_if_old_blocks_get_should_return_old_block_first(self, b):
        # create two blocks
        block_1 = b.create_block([])
        block_2 = b.create_block([])

        # write the blocks
        b.write_block(block_1, durability='hard')
        b.write_block(block_2, durability='hard')

        new_blocks = mp.Queue()
        bs = BlockStream(new_blocks)

        # assert len(list(bs.old_blocks)) == 2
        # import pdb; pdb.set_trace()
        # from pprint import pprint as pp
        # pp(bs.old_blocks)
        # pp(block_1)
        # pp(block_2)

        # create two new blocks that will appear in the changefeed
        block_3 = b.create_block([])
        block_4 = b.create_block([])

        # simulate a changefeed
        new_blocks.put(block_3)
        new_blocks.put(block_4)

        assert len(bs.unvoted_blocks) == 2

        # and check if we get the old blocks first
        assert bs.get() == block_1
        assert bs.get() == block_2
        assert bs.get() == block_3
        assert bs.get() == block_4
Esempio n. 3
0
 def test_if_federation_size_is_greater_than_one_ignore_past_blocks(self, b):
     for _ in range(5):
         b.federation_nodes.append(b.generate_keys()[1])
     new_blocks = mp.Queue()
     bs = BlockStream(new_blocks)
     block_1 = b.create_block([])
     new_blocks.put(block_1)
     assert block_1 == bs.get()
Esempio n. 4
0
 def test_if_federation_size_is_greater_than_one_ignore_past_blocks(self, b):
     for _ in range(5):
         b.federation_nodes.append(crypto.generate_key_pair()[1])
     new_blocks = mp.Queue()
     bs = BlockStream(new_blocks)
     block_1 = b.create_block([])
     new_blocks.put(block_1)
     assert block_1 == bs.get()
Esempio n. 5
0
    def test_if_no_old_blocks_get_should_return_new_blocks(self, b):
        new_blocks = mp.Queue()
        bs = BlockStream(new_blocks)

        # create two blocks
        block_1 = b.create_block([])
        block_2 = b.create_block([])

        # write the blocks
        b.write_block(block_1, durability='hard')
        b.write_block(block_2, durability='hard')

        # simulate a changefeed
        new_blocks.put(block_1)
        new_blocks.put(block_2)

        # and check if we get exactly these two blocks
        assert bs.get() == block_1
        assert bs.get() == block_2
Esempio n. 6
0
    def test_if_no_old_blocks_get_should_return_new_blocks(self, b):
        new_blocks = mp.Queue()
        bs = BlockStream(new_blocks)

        # create two blocks
        block_1 = b.create_block([])
        block_2 = b.create_block([])

        # write the blocks
        b.write_block(block_1, durability='hard')
        b.write_block(block_2, durability='hard')

        # simulate a changefeed
        new_blocks.put(block_1)
        new_blocks.put(block_2)

        # and check if we get exactly these two blocks
        assert bs.get() == block_1
        assert bs.get() == block_2