Skip to content

Commit

Permalink
made wait settings configurable (#464)
Browse files Browse the repository at this point in the history
  • Loading branch information
voith authored Oct 7, 2018
1 parent 56e3ba1 commit 448965a
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
2 changes: 1 addition & 1 deletion populus/chain/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def web3(self):

@property
def wait(self):
return Wait(self.web3)
return Wait(self.web3, **self.config.wait_settings)

#
# +--------------+
Expand Down
4 changes: 4 additions & 0 deletions populus/config/chain.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ def set_chain_class(self, chain_identifier):
else:
raise ValueError(UNSUPPORTED_CHAIN_IDENTIFIER_MSG.format(chain_identifier))

@property
def wait_settings(self):
return self.get('chain.wait.settings', {})

def get_web3_config(self):
return self.get_config('web3', config_class=Web3Config)

Expand Down
29 changes: 28 additions & 1 deletion tests/config-objects/test_chain_config_object.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import pytest
import random
import sys

import pytest
from web3.providers.ipc import IPCProvider

from populus.chain import (
Expand Down Expand Up @@ -100,3 +102,28 @@ def test_is_external_property():
assert chain_config.is_external is False
chain_config.set_chain_class('external')
assert chain_config.is_external is True


def test_chain_wait_settings(project):
timeout = random.randint(0, sys.maxsize)
poll_interval = random.randint(0, sys.maxsize)
chain_config = ChainConfig({
'chain': {
'class': 'populus.chain.external.ExternalChain',
'wait': {
'settings': {
'timeout': timeout,
'poll_interval': poll_interval
}
}
},
'web3': {
'provider': {
'class': 'web3.providers.ipc.IPCProvider'
}
},
})
chain = chain_config.get_chain(project, 'test-chain')
with chain as running_chain:
assert running_chain.wait.timeout == timeout
assert running_chain.wait.poll_interval == poll_interval

0 comments on commit 448965a

Please sign in to comment.