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.
* reenable * lint
- Loading branch information
Showing
1 changed file
with
50 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,50 @@ | ||
# import asyncio | ||
# from typing import List | ||
# | ||
# import pytest | ||
# from chiabip158 import PyBIP158 | ||
# | ||
# from tests.setup_nodes import test_constants, setup_simulators_and_wallets, bt | ||
# | ||
# | ||
# @pytest.fixture(scope="module") | ||
# def event_loop(): | ||
# loop = asyncio.get_event_loop() | ||
# yield loop | ||
# | ||
# | ||
# class TestFilter: | ||
# @pytest.fixture(scope="function") | ||
# async def wallet_and_node(self): | ||
# async for _ in setup_simulators_and_wallets(1, 1, {}): | ||
# yield _ | ||
# | ||
# @pytest.mark.asyncio | ||
# async def test_basic_filter_test(self, wallet_and_node): | ||
# full_nodes, wallets = wallet_and_node | ||
# wallet_node, server_2 = wallets[0] | ||
# wallet = wallet_node.wallet_state_manager.main_wallet | ||
# | ||
# num_blocks = 2 | ||
# await wallet.get_new_puzzlehash() | ||
# blocks = bt.get_consecutive_blocks(test_constants, num_blocks, [], 10) | ||
# | ||
# for i in range(1, num_blocks): | ||
# byte_array_tx: List[bytes] = [] | ||
# block = blocks[i] | ||
# coinbase = bytearray(block.get_coinbase().puzzle_hash) | ||
# fee = bytearray(block.get_fees_coin().puzzle_hash) | ||
# byte_array_tx.append(coinbase) | ||
# byte_array_tx.append(fee) | ||
# | ||
# pl = PyBIP158(byte_array_tx) | ||
# present = pl.Match(coinbase) | ||
# fee_present = pl.Match(fee) | ||
# | ||
# assert present | ||
# assert fee_present | ||
import asyncio | ||
from typing import List | ||
|
||
import pytest | ||
from chiabip158 import PyBIP158 | ||
|
||
from tests.setup_nodes import setup_simulators_and_wallets, bt | ||
|
||
|
||
@pytest.fixture(scope="module") | ||
def event_loop(): | ||
loop = asyncio.get_event_loop() | ||
yield loop | ||
|
||
|
||
class TestFilter: | ||
@pytest.fixture(scope="function") | ||
async def wallet_and_node(self): | ||
async for _ in setup_simulators_and_wallets(1, 1, {}): | ||
yield _ | ||
|
||
@pytest.mark.asyncio | ||
async def test_basic_filter_test(self, wallet_and_node): | ||
full_nodes, wallets = wallet_and_node | ||
wallet_node, server_2 = wallets[0] | ||
wallet = wallet_node.wallet_state_manager.main_wallet | ||
|
||
num_blocks = 2 | ||
ph = await wallet.get_new_puzzlehash() | ||
blocks = bt.get_consecutive_blocks( | ||
10, | ||
guarantee_transaction_block=True, | ||
farmer_reward_puzzle_hash=ph, | ||
pool_reward_puzzle_hash=ph, | ||
) | ||
for i in range(1, num_blocks): | ||
byte_array_tx: List[bytes] = [] | ||
block = blocks[i] | ||
coins = list(block.get_included_reward_coins()) | ||
coin_0 = bytearray(coins[0].puzzle_hash) | ||
coin_1 = bytearray(coins[1].puzzle_hash) | ||
byte_array_tx.append(coin_0) | ||
byte_array_tx.append(coin_1) | ||
|
||
pl = PyBIP158(byte_array_tx) | ||
present = pl.Match(coin_0) | ||
fee_present = pl.Match(coin_1) | ||
|
||
assert present | ||
assert fee_present |