enumatech / sprites-python

Sprites state channels with a bit of python code to test them
MIT License
6 stars 4 forks source link

Intermittent failure in tests (branch fea/sprite-eth) #6

Open philippecamacho opened 6 years ago

philippecamacho commented 6 years ago

When running several times the tests in branch origin/fea/sprite-eth sometimes some error appear:

========= ERRORS ======================= ___ ERROR at setup of test_trigger_trigger_sets_pending[alice] ____

web3 = <web3.main.Web3 object at 0x7faf39c58dd8>, eth_registry = <src.contracts.SpritesEthRegistry.SpritesEthRegistry object at 0x7faf33c826a0>
preimage_manager = <src.contracts.PreimageManager.PreimageManager object at 0x7faf33c68ef0>
acting_party = Account(address='0xa49AAd37c34e92236690b93E291Ae5f10DaF7CBE', privateKey='0xd8ae722d3a6876fd27907c434968e7373c6fbb985242e545a427531132ef3a71')
other_party = Account(address='0xb357fc3DBD4CDb7cBD96AA0A0bD905dBE56CaB77', privateKey='0x28e58f2f6a924d381e243ec1ca4a2239d2b35ebd9a44cec11aead6848a52630b')

    @pytest.fixture
    def eth_channel(
        web3,
        eth_registry: SpritesEthRegistry,
        preimage_manager: PreimageManager,
        acting_party,
        other_party,
    ):
        tx_hash = eth_registry.createChannel(
            other_party.address
        ).transact(
            {"from": acting_party.address, "gas": GAS}
        )

        receipt = web3.eth.getTransactionReceipt(tx_hash)
>       channel_id = web3.toInt(hexstr=receipt.logs[0].data)
E       AttributeError: 'NoneType' object has no attribute 'logs'

src/tests/conftest.py:207: AttributeError
---------------------------------------------------------------------------------------- Captured log setup ----------------------------------------------------------------------------------------
2018-08-08 06:53:08 DEBUG Making request. Method: eth_sendTransaction
2018-08-08 06:53:08 DEBUG Making request HTTP. URI: http://localhost:8545, Method: eth_sendTransaction
2018-08-08 06:53:08 DEBUG http://localhost:8545 "POST / HTTP/1.1" 200 105
2018-08-08 06:53:08 DEBUG Getting response HTTP. URI: http://localhost:8545, Method: eth_sendTransaction, Response: {'jsonrpc': '2.0', 'id': 250, 'result': '0x7bab7b4b5e08fb0b8e6df36719c2aad1554d837a6facf5eb0e2f9c0c6777c742'}
2018-08-08 06:53:08 DEBUG Making request. Method: eth_getTransactionReceipt
2018-08-08 06:53:08 DEBUG Making request HTTP. URI: http://localhost:8545, Method: eth_getTransactionReceipt
2018-08-08 06:53:08 DEBUG http://localhost:8545 "POST / HTTP/1.1" 200 41
2018-08-08 06:53:08 DEBUG Getting response HTTP. URI: http://localhost:8545, Method: eth_getTransactionReceipt, Response: {'jsonrpc': '2.0', 'id': 251, 'result': None}
____________________________________________________________ ERROR at setup of test_finalize_unauthorized_party_cannot_finalize[alice] _____________________________________________________________

web3 = <web3.main.Web3 object at 0x7faf39c58dd8>, token = <src.contracts.dappsys.DSToken object at 0x7faf33a0f5c0>
registry = <src.contracts.SpritesRegistry.SpritesRegistry object at 0x7faf33b4d198>, preimage_manager = <src.contracts.PreimageManager.PreimageManager object at 0x7faf33c68ef0>
acting_party = Account(address='0xa49AAd37c34e92236690b93E291Ae5f10DaF7CBE', privateKey='0xd8ae722d3a6876fd27907c434968e7373c6fbb985242e545a427531132ef3a71')
other_party = Account(address='0xb357fc3DBD4CDb7cBD96AA0A0bD905dBE56CaB77', privateKey='0x28e58f2f6a924d381e243ec1ca4a2239d2b35ebd9a44cec11aead6848a52630b')

    @pytest.fixture
    def channel(
        web3,
        token: DSToken,
        registry: SpritesRegistry,
        preimage_manager: PreimageManager,
        acting_party,
        other_party,
    ):
        tx_hash = registry.createChannel(
            other_party.address, token._contract.address
        ).transact(
            {"from": acting_party.address, "gas": GAS}
        )

        receipt = web3.eth.getTransactionReceipt(tx_hash)
>       channel_id = web3.toInt(hexstr=receipt.logs[0].data)
E       AttributeError: 'NoneType' object has no attribute 'logs'

src/tests/conftest.py:185: AttributeError

Other error (after another execution)

========================= ERRORS ============ _ ERROR at setup of test_finalize_dispute_payment_cancels_off_chain[bob]_____

web3 = <web3.main.Web3 object at 0x7f7250538dd8>, eth_registry = <src.contracts.SpritesEthRegistry.SpritesEthRegistry object at 0x7f724a5636a0>
preimage_manager = <src.contracts.PreimageManager.PreimageManager object at 0x7f724a54aef0>
acting_party = Account(address='0xb357fc3DBD4CDb7cBD96AA0A0bD905dBE56CaB77', privateKey='0x28e58f2f6a924d381e243ec1ca4a2239d2b35ebd9a44cec11aead6848a52630b')
other_party = Account(address='0xa49AAd37c34e92236690b93E291Ae5f10DaF7CBE', privateKey='0xd8ae722d3a6876fd27907c434968e7373c6fbb985242e545a427531132ef3a71')

    @pytest.fixture
    def eth_channel(
        web3,
        eth_registry: SpritesEthRegistry,
        preimage_manager: PreimageManager,
        acting_party,
        other_party,
    ):
        tx_hash = eth_registry.createChannel(
            other_party.address
        ).transact(
            {"from": acting_party.address, "gas": GAS}
        )

        receipt = web3.eth.getTransactionReceipt(tx_hash)
>       channel_id = web3.toInt(hexstr=receipt.logs[0].data)
E       AttributeError: 'NoneType' object has no attribute 'logs'

src/tests/conftest.py:207: AttributeError
sveitser commented 6 years ago

@philippecamacho Thanks for reporting this. This should be fixed on master (and on the branch in 0f6dd15). We weren't waiting/retrying for the tx receipts so there was a race condition.