[KMS-ETH]- Fixes ursula selection; modifies wait_time blockchain method and it's test.

pull/195/head^2
Kieran R Prasch 2018-02-08 01:06:54 -08:00 committed by Kieran Prasch
parent 81c3ab00a6
commit 511812d2ed
2 changed files with 9 additions and 4 deletions

View File

@ -64,9 +64,8 @@ class Blockchain:
def wait_time(self, wait_hours, step=50):
end_timestamp = self.web3.eth.getBlock(self.web3.eth.blockNumber).timestamp + wait_hours * 60 * 60
time_yet = self.web3.eth.getBlock(self.web3.eth.blockNumber).timestamp < end_timestamp
while not time_yet:
self.chain.wait.for_block(self.web3.eth.blockNumber+step)
while self.web3.eth.getBlock(self.web3.eth.blockNumber).timestamp < end_timestamp:
self.chain.wait.for_block(self.web3.eth.blockNumber + step)
class TesterBlockchain(Blockchain):

View File

@ -15,12 +15,18 @@ def test_deposit(testerchain, miner, token):
def test_select_ursulas(testerchain, token, escrow, miner):
def wait_time(chain, wait_hours):
web3 = chain.web3
step = 50
end_timestamp = web3.eth.getBlock(web3.eth.blockNumber).timestamp + wait_hours * 60 * 60
while web3.eth.getBlock(web3.eth.blockNumber).timestamp < end_timestamp:
chain.wait.for_block(web3.eth.blockNumber + step)
token._airdrop()
# Create a random set of miners (we have 9 in total)
for u in testerchain.web3.eth.accounts[1:]:
miner.lock((10 + random.randrange(9000))*M, 100, u)
testerchain.chain.wait.for_block(testerchain.web3.eth.blockNumber+escrow.hours_per_period)
testerchain.wait_time(escrow.hours_per_period)
miners = escrow.sample(quantity=3)
assert len(miners) == 3