forked from Chia-Network/chia-blockchain
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
6 changed files
with
81 additions
and
69 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 |
---|---|---|
@@ -1 +1 @@ | ||
ffff05ffff01ffffff05ff08ffff05ff02ffff05ffffff05ff03ffff01ff80808080ffff01ffff8080808080808080ffff05ffff01ffffffffff05ffff04ff05ffff01ffffff05ff08ffff05ff02ffff05ff0dffff05ffff05ffffff05ff0affff05ff02ffff05ff09ffff01ff808080808080ff0b80ffff01ff8080808080808080ffff01ff0b8080ff018080ffff05ffff04ff05ffff01ffffff05ff0cffff05ff02ffff05ff0dffff05ffff0cff0bffff01ff018080ffff01ff8080808080808080ffff01ff0b8080ff018080ffffff05ffff04ffffff05ffff04ffff0affffff05ff0cffff05ff02ffff05ff05ffff01ffff80808080808080ffff01ff028080ffff01ffffff05ffff04ffff0affffff05ff0cffff05ff02ffff05ff15ffff01ffff80808080808080ffff01ff028080ffff01ffffff05ffff04ffff0affff11ff0980ffff01ff208080ffff01ffff01ff018080ffff01ffff01ff80808080ff01808080ffff01ffff01ff80808080ff01808080ffff01ffff01ff80808080ff018080ffff01ffff05ff09ffff05ffffff05ff0effff05ff02ffff05ff25ffff01ff808080808080ffff05ffffff05ff25ff558080ffff01ff808080808080ffff01ffff09808080ff018080ffff05ffff04ffff08ff0580ffff01ffff0bffff01ff0280ffffff05ff0effff05ff02ffff05ff09ffff01ff808080808080ffffff05ff0effff05ff02ffff05ff0dffff01ff8080808080808080ffff01ffff0bffff01ff0180ff05808080ff01808080ff01808080 | ||
ffff05ffff01ffffff05ff04ffff05ff02ffff05ffffff05ff03ffff01ff80808080ffff01ffff8080808080808080ffff05ffff01ffffffff05ffff04ff05ffff01ffffff05ff04ffff05ff02ffff05ff0dffff05ffff05ffffff05ff0affff05ff02ffff05ff09ffff01ff808080808080ff0b80ffff01ff8080808080808080ffff01ff0b8080ff018080ffffff05ffff04ffffff05ffff04ffff0aff1dffff01ff808080ffff01ffffff05ffff04ffff0aff75ffff01ff808080ffff01ffffff05ffff04ffff0affff11ff0980ffff01ff208080ffff01ffff01ff018080ffff01ffff01ff80808080ff01808080ffff01ffff01ff80808080ff01808080ffff01ffff01ff80808080ff018080ffff01ffff05ff09ffff05ffffff05ff0effff05ff02ffff05ff25ffff01ff808080808080ffff05ffffff05ff25ff558080ffff01ff808080808080ffff01ffff09808080ff018080ffff05ffff04ffff08ff0580ffff01ffff0bffff01ff0280ffffff05ff0effff05ff02ffff05ff09ffff01ff808080808080ffffff05ff0effff05ff02ffff05ff0dffff01ff8080808080808080ffff01ffff0bffff01ff0180ff05808080ff01808080ff01808080 |
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 |
---|---|---|
@@ -1,47 +1,49 @@ | ||
# import asyncio | ||
# | ||
# import pytest | ||
# | ||
# from src.full_node.bundle_tools import best_solution_program | ||
# from src.consensus.cost_calculator import calculate_cost_of_program | ||
# from src.full_node.mempool_check_conditions import get_name_puzzle_conditions | ||
# from tests.setup_nodes import test_constants, bt | ||
# | ||
# BURN_PUZZLE_HASH = b"0" * 32 | ||
# | ||
# | ||
# @pytest.fixture(scope="module") | ||
# def event_loop(): | ||
# loop = asyncio.get_event_loop() | ||
# yield loop | ||
# | ||
# | ||
# class TestCostCalculation: | ||
# @pytest.mark.asyncio | ||
# async def test_basics(self): | ||
# wallet_tool = bt.get_pool_wallet_tool() | ||
# | ||
# num_blocks = 2 | ||
# blocks = bt.get_consecutive_blocks( | ||
# test_constants, | ||
# num_blocks, | ||
# [], | ||
# 10, | ||
# ) | ||
# | ||
# spend_bundle = wallet_tool.generate_signed_transaction( | ||
# blocks[1].get_coinbase().amount, | ||
# BURN_PUZZLE_HASH, | ||
# blocks[1].get_coinbase(), | ||
# ) | ||
# assert spend_bundle is not None | ||
# program = best_solution_program(spend_bundle) | ||
# | ||
# ratio = test_constants.CLVM_COST_RATIO_CONSTANT | ||
# | ||
# error, npc_list, clvm_cost = calculate_cost_of_program(program, ratio) | ||
# | ||
# error, npc_list, cost = get_name_puzzle_conditions(program) | ||
# | ||
# # Create condition + agg_sig_condition + length + cpu_cost | ||
# assert clvm_cost == 200 * ratio + 20 * ratio + len(bytes(program)) * ratio + cost | ||
import asyncio | ||
|
||
import pytest | ||
|
||
from src.full_node.bundle_tools import best_solution_program | ||
from src.full_node.cost_calculator import calculate_cost_of_program | ||
from src.full_node.mempool_check_conditions import get_name_puzzle_conditions | ||
from tests.setup_nodes import test_constants, bt | ||
|
||
BURN_PUZZLE_HASH = b"0" * 32 | ||
|
||
|
||
@pytest.fixture(scope="module") | ||
def event_loop(): | ||
loop = asyncio.get_event_loop() | ||
yield loop | ||
|
||
|
||
class TestCostCalculation: | ||
@pytest.mark.asyncio | ||
async def test_basics(self): | ||
wallet_tool = bt.get_pool_wallet_tool() | ||
|
||
num_blocks = 2 | ||
blocks = bt.get_consecutive_blocks( | ||
test_constants, | ||
num_blocks, | ||
[], | ||
10, | ||
) | ||
|
||
spend_bundle = wallet_tool.generate_signed_transaction( | ||
blocks[1].get_coinbase().amount, | ||
BURN_PUZZLE_HASH, | ||
blocks[1].get_coinbase(), | ||
) | ||
assert spend_bundle is not None | ||
program = best_solution_program(spend_bundle) | ||
|
||
ratio = test_constants.CLVM_COST_RATIO_CONSTANT | ||
|
||
error, npc_list, clvm_cost = calculate_cost_of_program(program, ratio) | ||
|
||
error, npc_list, cost = get_name_puzzle_conditions(program, False) | ||
|
||
# Create condition + agg_sig_condition + length + cpu_cost | ||
assert ( | ||
clvm_cost == 200 * ratio + 20 * ratio + len(bytes(program)) * ratio + cost | ||
) |