Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with chain.time timestamp #1005

Merged
merged 2 commits into from
Mar 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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