コード例 #1
0
def test_shh_filter(web3, skip_if_testrpc):
    skip_if_testrpc(web3)
    recieved_messages = []
    topic = web3.toHex(text="test")
    shh_filter = web3.shh.filter({"topics": [topic]})
    shh_filter.watch(recieved_messages.append)

    payloads = []
    payloads.append(str.encode("payload1"))
    web3.shh.post({
        "topics": [topic],
        "payload": web3.toHex(text=payloads[-1]),
    })
    sleep(1)

    payloads.append(str.encode("payload2"))
    web3.shh.post({
        "topics": [topic],
        "payload": web3.toHex(text=payloads[-1]),
    })
    sleep(1)
    assert len(recieved_messages) > 1

    for message in recieved_messages:
        assert web3.toBytes(message["payload"]) in payloads
コード例 #2
0
ファイル: conftest.py プロジェクト: ytsheng/web3.py
 def _wait_for_block(web3, block_number=1, timeout=60 * 10):
     poll_delay_counter = PollDelayCounter()
     with Timeout(timeout) as timeout:
         while True:
             if web3.eth.blockNumber >= block_number:
                 break
             if is_all_testrpc_providers(web3.providers):
                 web3.manager.request_blocking("evm_mine", [])
             sleep(poll_delay_counter())
             timeout.check()
コード例 #3
0
ファイル: conftest.py プロジェクト: JoyPlatform/web3.py
 def _wait_for_block(web3, block_number=1, timeout=60 * 10):
     poll_delay_counter = PollDelayCounter()
     with Timeout(timeout) as timeout:
         while True:
             if web3.eth.blockNumber >= block_number:
                 break
             if isinstance(web3.currentProvider, (TestRPCProvider, EthereumTesterProvider)):
                 web3._requestManager.request_blocking("evm_mine", [])
             sleep(poll_delay_counter())
             timeout.check()
コード例 #4
0
    def _wait_for_transaction(web3, txn_hash, timeout=120):
        poll_delay_counter = PollDelayCounter()
        with Timeout(timeout) as timeout:
            while True:
                txn_receipt = web3.eth.getTransactionReceipt(txn_hash)
                if txn_receipt is not None:
                    break
                sleep(poll_delay_counter())
                timeout.check()

        return txn_receipt
コード例 #5
0
 def _wait_for_block(web3, block_number=1, timeout=60 * 10):
     poll_delay_counter = PollDelayCounter()
     with Timeout(timeout) as timeout:
         while True:
             if web3.eth.blockNumber >= block_number:
                 break
             if isinstance(web3.currentProvider,
                           (TestRPCProvider, EthereumTesterProvider)):
                 web3._requestManager.request_blocking("evm_mine", [])
             sleep(poll_delay_counter())
             timeout.check()
コード例 #6
0
ファイル: conftest.py プロジェクト: JoyPlatform/web3.py
    def _wait_for_transaction(web3, txn_hash, timeout=120):
        poll_delay_counter = PollDelayCounter()
        with Timeout(timeout) as timeout:
            while True:
                txn_receipt = web3.eth.getTransactionReceipt(txn_hash)
                if txn_receipt is not None:
                    break
                sleep(poll_delay_counter())
                timeout.check()

        return txn_receipt
コード例 #7
0
def test_shh_filter(web3, skip_if_testrpc):
    skip_if_testrpc(web3)
    recieved_messages = []
    shh_filter = web3.shh.filter({"topics":[web3.fromAscii("test")]})
    shh_filter.watch(recieved_messages.append)

    payloads = []
    payloads.append(str.encode("payload1"))
    web3.shh.post({"topics":[web3.fromAscii("test")], "payload":web3.fromAscii(payloads[len(payloads)-1])})
    sleep(1)

    payloads.append(str.encode("payload2"))
    web3.shh.post({"topics":[web3.fromAscii("test")], "payload":web3.fromAscii(payloads[len(payloads)-1])})
    sleep(1)
    assert len(recieved_messages) > 1

    for message in recieved_messages:
        assert web3.toAscii(message["payload"]) in payloads
コード例 #8
0
def test_shh_filter(web3, skip_if_testrpc):
    skip_if_testrpc(web3)
    recieved_messages = []
    shh_filter = web3.shh.filter({"topics": [web3.fromAscii("test")]})
    shh_filter.watch(recieved_messages.append)

    payloads = []
    payloads.append(str.encode("payload1"))
    web3.shh.post({
        "topics": [web3.fromAscii("test")],
        "payload": web3.fromAscii(payloads[len(payloads) - 1]),
    })
    sleep(1)

    payloads.append(str.encode("payload2"))
    web3.shh.post({
        "topics": [web3.fromAscii("test")],
        "payload": web3.fromAscii(payloads[len(payloads) - 1]),
    })
    sleep(1)
    assert len(recieved_messages) > 1

    for message in recieved_messages:
        assert web3.toAscii(message["payload"]) in payloads
コード例 #9
0
ファイル: test_shh_filter.py プロジェクト: wip727/web3.py
def test_shh_sync_filter(web3, skip_if_testrpc):
    skip_if_testrpc(web3)
    topic = web3.toHex(text="test")
    shh_filter = web3.shh.filter({"topics": [topic]})

    payloads = []
    payloads.append(str.encode("payload1"))
    web3.shh.post({
        "topics": [topic],
        "payload": web3.toHex(text=payloads[-1]),
    })
    sleep(1)

    payloads.append(str.encode("payload2"))
    web3.shh.post({
        "topics": [topic],
        "payload": web3.toHex(text=payloads[-1]),
    })
    sleep(1)
    received_messages = shh_filter.get_new_entries()
    assert len(received_messages) > 1

    for message in received_messages:
        assert message["payload"] in payloads
コード例 #10
0
 def _wait_for_miner_start(web3, timeout=60):
     poll_delay_counter = PollDelayCounter()
     with Timeout(timeout) as timeout:
         while not web3.eth.mining or not web3.eth.hashrate:
             sleep(poll_delay_counter())
             timeout.check()
コード例 #11
0
ファイル: conftest.py プロジェクト: JoyPlatform/web3.py
 def _wait_for_miner_start(web3, timeout=60):
     poll_delay_counter = PollDelayCounter()
     with Timeout(timeout) as timeout:
         while not web3.eth.mining or not web3.eth.hashrate:
             sleep(poll_delay_counter())
             timeout.check()