-
Notifications
You must be signed in to change notification settings - Fork 686
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add API for incrementally building blocks
- Loading branch information
1 parent
e053e03
commit cda3fee
Showing
11 changed files
with
142 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import pytest | ||
|
||
from evm.utils.address import force_bytes_to_address | ||
|
||
from tests.core.helpers import ( | ||
new_transaction, | ||
) | ||
|
||
|
||
ADDRESS_1010 = force_bytes_to_address(b'\x10\x10') | ||
|
||
|
||
@pytest.fixture | ||
def chain(chain_without_block_validation): | ||
return chain_without_block_validation | ||
|
||
|
||
def test_building_block_incrementally_with_single_transaction(chain, | ||
funded_address, | ||
funded_address_private_key): | ||
tx = new_transaction( | ||
chain.get_vm(), | ||
from_=funded_address, | ||
to=ADDRESS_1010, | ||
private_key=funded_address_private_key, | ||
) | ||
_, _, computation = chain.apply_transaction(tx) | ||
assert computation.is_success | ||
|
||
mined_block = chain.mine_block() | ||
assert len(mined_block.transactions) == 1 | ||
|
||
actual_tx = mined_block.transactions[0] | ||
assert actual_tx == tx | ||
|
||
|
||
def test_building_block_incrementally_with_multiple_transactions(chain, | ||
funded_address, | ||
funded_address_private_key): | ||
txns = [] | ||
for _ in range(3): | ||
tx = new_transaction( | ||
chain.get_vm(), | ||
from_=funded_address, | ||
to=ADDRESS_1010, | ||
private_key=funded_address_private_key, | ||
) | ||
txns.append(tx) | ||
_, _, computation = chain.apply_transaction(tx) | ||
assert computation.is_success | ||
|
||
mined_block = chain.mine_block() | ||
assert len(mined_block.transactions) == 3 | ||
|
||
for left, right in zip(txns, mined_block.transactions): | ||
assert left == right |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters