Skip to content

Commit

Permalink
Merge pull request #1005 from eth-brownie/fix-chain-mine
Browse files Browse the repository at this point in the history
Issue with chain.time timestamp
  • Loading branch information
iamdefinitelyahuman authored Mar 20, 2021
2 parents e210868 + 6acef35 commit 9096a1e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
4 changes: 2 additions & 2 deletions brownie/network/rpc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,8 @@ def sleep(self, seconds: int) -> int:
return self.backend.sleep(seconds)

@internal
def mine(self, blocks: int = 1) -> int:
self.backend.mine(blocks)
def mine(self, timestamp: int = None) -> int:
self.backend.mine(timestamp)
return web3.eth.blockNumber

@internal
Expand Down
11 changes: 11 additions & 0 deletions tests/network/state/test_blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,17 @@ def test_length_after_revert(devnetwork, chain):
assert len(chain) == 5


def test_timestamp(devnetwork, chain):
chain.mine()
assert chain[-2].timestamp <= chain[-1].timestamp


def test_timestamp_multiple_blocks(devnetwork, chain):
chain.mine(5)
for i in range(1, len(chain)):
assert chain[i - 1].timestamp <= chain[i].timestamp


def test_getitem_negative_index(devnetwork, accounts, chain, web3):
block = chain[-1]
assert block == web3.eth.getBlock("latest")
Expand Down

0 comments on commit 9096a1e

Please sign in to comment.