-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
73 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
from chia_rs import Spend, CoinSpend, Coin, supports_fast_forward, fast_forward_singleton | ||
import pytest | ||
|
||
@pytest.mark.parametrize("file", ["bb13", "e3c0"]) | ||
def test_supports_fast_forward(file: str) -> None: | ||
with open(f"ff-tests/{file}.spend", "rb") as f: | ||
spend = CoinSpend.from_bytes(f.read()) | ||
assert supports_fast_forward(spend) | ||
|
||
@pytest.mark.parametrize("file", ["bb13", "e3c0"]) | ||
def test_fast_forward_singleton(file: str) -> None: | ||
with open(f"ff-tests/{file}.spend", "rb") as f: | ||
spend = CoinSpend.from_bytes(f.read()) | ||
|
||
parents_parent = bytes([0] * 32) | ||
new_parent = Coin(parents_parent, spend.coin.puzzle_hash, spend.coin.amount) | ||
new_coin = Coin(new_parent.name(), new_parent.puzzle_hash, new_parent.amount) | ||
new_solution = fast_forward_singleton(spend, new_coin, new_parent) | ||
|
||
expected = bytearray(bytes(spend.solution)) | ||
# this is where the parent's parent coin ID lives in the solution | ||
expected[3:35] = parents_parent | ||
assert expected == new_solution |
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