Ejemplo n.º 1
0
    def test_return_true_if_transaction_in(self):

        # Arrange
        tx0 = Transaction(VERSION, Transaction.GUZI_CREATE, KEY_POOL[0]["pub"],
                          0)
        tx1 = Transaction(VERSION, Transaction.GUZI_CREATE, KEY_POOL[1]["pub"],
                          0)
        b = Block()

        # Act
        b.add_transactions([tx0, tx1])

        # Assert
        assert b._containUser(KEY_POOL[2]["pub"]) is False
Ejemplo n.º 2
0
    def test_transaction_not_found(self):

        # Arrange
        tx0 = Transaction(VERSION, Transaction.GUZI_CREATE, NEW_USER_PUB_KEY,
                          0)
        tx1 = Transaction(VERSION, Transaction.GUZIBOX_CREATE,
                          NEW_USER_PUB_KEY, 0)
        tx2 = Transaction(VERSION, Transaction.PAYMENT, NEW_USER_PUB_KEY, 0)
        b = Block()

        # Act
        b.add_transactions([tx1, tx2])

        # Assert
        assert b._contain_tx(tx0) is False
Ejemplo n.º 3
0
    def test_unfound_transaction(self):
        block = Block()
        tx1 = Transaction(VERSION, Transaction.GUZI_CREATE, NEW_USER_PUB_KEY,
                          0)
        tx1.date = date(2011, 12, 13)
        tx2 = Transaction(VERSION, Transaction.GUZI_CREATE, NEW_USER_PUB_KEY,
                          0)
        tx2.date = date(2012, 11, 14)
        tx3 = Transaction(VERSION, Transaction.GUZI_CREATE, NEW_USER_PUB_KEY,
                          0)
        tx3.date = date(2013, 10, 15)

        # Act
        block.add_transactions([tx1, tx2, tx3])
        result = block.find_transaction(Transaction.GUZI_CREATE,
                                        date(2014, 11, 14))

        # Assert
        assert result is None
Ejemplo n.º 4
0
    def test_compute_merkle_root_2_tx(self):
        """
        If there are 2 transactions, merkle root should be :
        hash(hash0 + hash1)
        """
        # Arrange
        tx0 = Transaction(VERSION, Transaction.GUZI_CREATE, NEW_USER_PUB_KEY,
                          0)
        tx1 = Transaction(VERSION, Transaction.GUZI_CREATE, NEW_USER_PUB_KEY,
                          0)
        block = Block()
        block.add_transactions([tx0, tx1])

        expected_merkle_root = guzi_hash(tx0.to_hash() + tx1.to_hash())

        # Act
        result = block.compute_merkle_root()

        # Assert
        assert result == expected_merkle_root