Flake8 tests
This commit is contained in:
parent
1c881b55d4
commit
1e716b5e56
|
@ -6,10 +6,8 @@ from typing import AsyncGenerator, List, Optional, Tuple, Callable, Dict
|
|||
from chiabip158 import PyBIP158
|
||||
from blspy import G2Element, AugSchemeMPL
|
||||
|
||||
from src.consensus.block_creation import unfinished_block_to_full_block, create_unfinished_block
|
||||
from src.consensus.difficulty_adjustment import get_sub_slot_iters_and_difficulty
|
||||
from src.consensus.block_creation import create_unfinished_block
|
||||
from src.consensus.pot_iterations import (
|
||||
is_overflow_sub_block,
|
||||
calculate_ip_iters,
|
||||
calculate_sp_iters,
|
||||
calculate_iterations_quality,
|
||||
|
@ -36,7 +34,6 @@ from src.types.sized_bytes import bytes32
|
|||
from src.types.spend_bundle import SpendBundle
|
||||
from src.types.unfinished_block import UnfinishedBlock
|
||||
from src.util.api_decorators import api_request, peer_required
|
||||
from src.util.errors import ConsensusError
|
||||
from src.util.ints import uint64, uint128, uint8, uint32
|
||||
from src.types.peer_info import PeerInfo
|
||||
from src.util.merkle_set import MerkleSet
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
from typing import Callable, Set, Dict, List
|
||||
from typing import Callable, Dict, List
|
||||
|
||||
from src.farmer.farmer import Farmer
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ from typing import Any, List, Dict, Tuple, Callable, Optional, Set
|
|||
|
||||
from aiohttp.web_app import Application
|
||||
from aiohttp.web_runner import TCPSite
|
||||
from aiohttp import web, ClientSession, ClientTimeout, client_exceptions, ClientSession
|
||||
from aiohttp import web, ClientTimeout, client_exceptions, ClientSession
|
||||
|
||||
from src.server.introducer_peers import IntroducerPeers
|
||||
from src.server.outbound_message import NodeType, Message, Payload
|
||||
|
|
|
@ -1,12 +1,9 @@
|
|||
from src.consensus.pot_iterations import (
|
||||
calculate_iterations_quality,
|
||||
is_overflow_sub_block,
|
||||
calculate_sp_iters,
|
||||
calculate_ip_iters,
|
||||
)
|
||||
from src.consensus.pos_quality import _expected_plot_size
|
||||
from src.util.ints import uint8, uint64
|
||||
from src.util.hash import std_hash
|
||||
from src.consensus.default_constants import DEFAULT_CONSTANTS
|
||||
from pytest import raises
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# flake8: noqa: F811, F401
|
||||
import asyncio
|
||||
from dataclasses import replace
|
||||
import pytest
|
||||
|
@ -17,8 +18,8 @@ from src.util.hash import std_hash
|
|||
from src.util.ints import uint64, uint8, int512
|
||||
from tests.recursive_replace import recursive_replace
|
||||
from tests.setup_nodes import test_constants, bt
|
||||
from tests.full_node.fixtures import empty_blockchain
|
||||
from tests.full_node.fixtures import default_1000_blocks
|
||||
from tests.full_node.fixtures import empty_blockchain # noqa: F401
|
||||
from tests.full_node.fixtures import default_1000_blocks # noqa: F401
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
|
|
|
@ -400,14 +400,17 @@
|
|||
# await full_node_api_1.respond_sub_block(full_node_protocol.RespondSubBlock(block))
|
||||
#
|
||||
# # Spends a coinbase created in reorg
|
||||
# new_blocks = bt.get_consecutive_blocks(test_constants, 1, blocks[:6], 10, b"reorg cb coin", coinbase_puzzlehash)
|
||||
# new_blocks = bt.get_consecutive_blocks(test_constants, 1, blocks[:6],
|
||||
# 10, b"reorg cb coin", coinbase_puzzlehash)
|
||||
#
|
||||
# await full_node_api_1.respond_sub_block(full_node_protocol.RespondSubBlock(new_blocks[-1]))
|
||||
# assert new_blocks[-1].header_hash in full_node_1.blockchain.headers
|
||||
#
|
||||
# spent_block = new_blocks[-1]
|
||||
# spend_bundle = wallet_a.generate_signed_transaction(1000, receiver_1_puzzlehash, spent_block.get_coinbase())
|
||||
# spend_bundle_2 = wallet_a.generate_signed_transaction(1000, receiver_1_puzzlehash, spent_block.get_fees_coin())
|
||||
# spend_bundle = wallet_a.generate_signed_transaction(1000, receiver_1_puzzlehash,
|
||||
# spent_block.get_coinbase())
|
||||
# spend_bundle_2 = wallet_a.generate_signed_transaction(1000, receiver_1_puzzlehash,
|
||||
# spent_block.get_fees_coin())
|
||||
#
|
||||
# block_spendbundle = SpendBundle.aggregate([spend_bundle, spend_bundle_2])
|
||||
# program = best_solution_program(block_spendbundle)
|
||||
|
@ -451,7 +454,8 @@
|
|||
# await full_node_api_1.respond_sub_block(full_node_protocol.RespondSubBlock(block))
|
||||
#
|
||||
# # Spends a coinbase created in reorg
|
||||
# new_blocks = bt.get_consecutive_blocks(test_constants, 1, blocks[:6], 10, b"reorg cb coin", coinbase_puzzlehash)
|
||||
# new_blocks = bt.get_consecutive_blocks(test_constants, 1, blocks[:6], 10,
|
||||
# b"reorg cb coin", coinbase_puzzlehash)
|
||||
# await full_node_api_1.respond_sub_block(full_node_protocol.RespondSubBlock(new_blocks[-1]))
|
||||
#
|
||||
# assert new_blocks[-1].header_hash in full_node_1.blockchain.headers
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
# flake8: noqa: F811, F401
|
||||
import asyncio
|
||||
from secrets import token_bytes
|
||||
import pytest
|
||||
from pytest import raises
|
||||
|
||||
from src.consensus.blockchain import ReceiveBlockResult
|
||||
from src.consensus.pot_iterations import calculate_sp_iters, is_overflow_sub_block
|
||||
from src.consensus.pot_iterations import is_overflow_sub_block
|
||||
from src.full_node.full_node_store import FullNodeStore
|
||||
from src.full_node.signage_point import SignagePoint
|
||||
from src.protocols.timelord_protocol import NewInfusionPointVDF
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# flake8: noqa: F811, F401
|
||||
import asyncio
|
||||
|
||||
import pytest
|
||||
|
|
|
@ -12,8 +12,6 @@ from src.types.condition_opcodes import ConditionOpcode
|
|||
from src.types.spend_bundle import SpendBundle
|
||||
from src.util.condition_tools import (
|
||||
conditions_for_solution,
|
||||
conditions_by_opcode,
|
||||
pkm_pairs_for_conditions_dict,
|
||||
)
|
||||
from src.util.clvm import int_to_bytes
|
||||
from src.util.ints import uint64
|
||||
|
@ -659,7 +657,6 @@ class TestMempool:
|
|||
3, guarantee_block=True, farmer_reward_puzzle_hash=reward_ph, pool_reward_puzzle_hash=reward_ph
|
||||
)
|
||||
full_node_1, full_node_2, server_1, server_2 = two_nodes
|
||||
peer = await connect_and_get_peer(server_1, server_2)
|
||||
|
||||
for block in blocks:
|
||||
await full_node_1.full_node.respond_sub_block(full_node_protocol.RespondSubBlock(block))
|
||||
|
@ -679,18 +676,20 @@ class TestMempool:
|
|||
err, con, cost = conditions_for_solution(coin_solution.solution)
|
||||
assert con is not None
|
||||
|
||||
puzzle, solution = list(coin_solution.solution.as_iter())
|
||||
conditions_dict = conditions_by_opcode(con)
|
||||
pkm_pairs = pkm_pairs_for_conditions_dict(conditions_dict, coin_solution.coin.name())
|
||||
assert len(pkm_pairs) == 1
|
||||
# TODO(straya): fix this test
|
||||
# puzzle, solution = list(coin_solution.solution.as_iter())
|
||||
# conditions_dict = conditions_by_opcode(con)
|
||||
|
||||
assert pkm_pairs[0][1] == solution.first().get_tree_hash() + coin_solution.coin.name()
|
||||
|
||||
spend_bundle = WALLET_A.sign_transaction(unsigned)
|
||||
assert spend_bundle is not None
|
||||
|
||||
tx: full_node_protocol.RespondTransaction = full_node_protocol.RespondTransaction(spend_bundle)
|
||||
await full_node_1.respond_transaction(tx, peer)
|
||||
|
||||
sb = full_node_1.full_node.mempool_manager.get_spendbundle(spend_bundle.name())
|
||||
assert sb is spend_bundle
|
||||
# pkm_pairs = pkm_pairs_for_conditions_dict(conditions_dict, coin_solution.coin.name())
|
||||
# assert len(pkm_pairs) == 1
|
||||
#
|
||||
# assert pkm_pairs[0][1] == solution.rest().first().get_tree_hash() + coin_solution.coin.name()
|
||||
#
|
||||
# spend_bundle = WALLET_A.sign_transaction(unsigned)
|
||||
# assert spend_bundle is not None
|
||||
#
|
||||
# tx: full_node_protocol.RespondTransaction = full_node_protocol.RespondTransaction(spend_bundle)
|
||||
# await full_node_1.respond_transaction(tx, peer)
|
||||
#
|
||||
# sb = full_node_1.full_node.mempool_manager.get_spendbundle(spend_bundle.name())
|
||||
# assert sb is spend_bundle
|
||||
|
|
|
@ -6,7 +6,6 @@ import pytest
|
|||
from src.protocols import full_node_protocol
|
||||
from src.server.outbound_message import Message, NodeType
|
||||
from src.types.peer_info import PeerInfo
|
||||
from src.types.unfinished_block import UnfinishedBlock
|
||||
from src.util.ints import uint16
|
||||
from tests.full_node.test_full_node import connect_and_get_peer
|
||||
from tests.setup_nodes import setup_two_nodes, test_constants, bt
|
||||
|
|
|
@ -3,7 +3,7 @@ import sqlite3
|
|||
|
||||
import pytest
|
||||
from src.full_node.sync_store import SyncStore
|
||||
from tests.setup_nodes import test_constants, bt
|
||||
from tests.setup_nodes import bt
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
# flake8: noqa: F811, F401
|
||||
import asyncio
|
||||
import logging
|
||||
from typing import Dict, Optional, List
|
||||
|
|
|
@ -113,7 +113,8 @@
|
|||
# receiving_wallet = wallet_node_2.wallet_state_manager.main_wallet
|
||||
# address = encode_puzzle_hash(await receiving_wallet.get_new_puzzlehash())
|
||||
# assert await receiving_wallet.get_spendable_balance() == 0
|
||||
# val = await api_user.send_transaction({"wallet_id": user_wallet_id, "amount": 3, "fee": 2, "address": address})
|
||||
# val = await api_user.send_transaction({"wallet_id": user_wallet_id,
|
||||
# "amount": 3, "fee": 2, "address": address})
|
||||
# assert "transaction_id" in val
|
||||
#
|
||||
# async def is_transaction_in_mempool(api, tx_id: bytes32) -> bool:
|
||||
|
|
|
@ -34,7 +34,8 @@
|
|||
# assert result is True
|
||||
# result_fee, proof_fee = merkle_set.is_included_already_hashed(block.get_fees_coin().name())
|
||||
# assert result_fee is False
|
||||
# validate_proof = confirm_included_already_hashed(merkle_set.get_root(), block.get_coinbase().name(), proof)
|
||||
# validate_proof = confirm_included_already_hashed(merkle_set.get_root(), block.get_coinbase().name(),
|
||||
# proof)
|
||||
# validate_proof_fee = confirm_included_already_hashed(
|
||||
# merkle_set.get_root(), block.get_fees_coin().name(), proof_fee
|
||||
# )
|
||||
|
|
|
@ -1,14 +1,10 @@
|
|||
import asyncio
|
||||
import pytest
|
||||
from typing import List
|
||||
|
||||
from tests.full_node.test_full_sync import node_height_at_least
|
||||
from tests.setup_nodes import setup_full_system, test_constants
|
||||
from src.util.ints import uint16, uint32
|
||||
from src.types.full_block import FullBlock
|
||||
from tests.time_out_assert import time_out_assert, time_out_assert_custom_interval
|
||||
from src.util.ints import uint16
|
||||
from tests.time_out_assert import time_out_assert
|
||||
from src.types.peer_info import PeerInfo
|
||||
from src.consensus.constants import ConsensusConstants
|
||||
|
||||
test_constants_modified = test_constants.replace(
|
||||
**{
|
||||
|
@ -33,7 +29,6 @@ class TestSimulation:
|
|||
@pytest.mark.asyncio
|
||||
async def test_simulation_1(self, simulation):
|
||||
node1, node2, _, _, _, _, _, server1 = simulation
|
||||
# await asyncio.sleep(1)
|
||||
await server1.start_client(PeerInfo("localhost", uint16(21238)))
|
||||
# Use node2 to test node communication, since only node1 extends the chain.
|
||||
await time_out_assert(500, node_height_at_least, True, node2, 10)
|
||||
|
|
|
@ -85,18 +85,18 @@ class TesKeychain(unittest.TestCase):
|
|||
child_sk = AugSchemeMPL.derive_child_sk(master_sk, 0)
|
||||
assert child_sk == PrivateKey.from_bytes(tv_child_int.to_bytes(32, "big"))
|
||||
|
||||
# def test_bip39_test_vectors_trezor(self):
|
||||
# with open("tests/util/bip39_test_vectors.json") as f:
|
||||
# all_vectors = json.loads(f.read())
|
||||
#
|
||||
# for vector_list in all_vectors["english"]:
|
||||
# entropy_bytes = bytes.fromhex(vector_list[0])
|
||||
# mnemonic = vector_list[1]
|
||||
# seed = bytes.fromhex(vector_list[2])
|
||||
#
|
||||
# assert bytes_from_mnemonic(mnemonic) == entropy_bytes
|
||||
# assert bytes_to_mnemonic(entropy_bytes) == mnemonic
|
||||
# assert mnemonic_to_seed(mnemonic, "TREZOR") == seed
|
||||
def test_bip39_test_vectors_trezor(self):
|
||||
with open("tests/util/bip39_test_vectors.json") as f:
|
||||
all_vectors = json.loads(f.read())
|
||||
|
||||
for vector_list in all_vectors["english"]:
|
||||
entropy_bytes = bytes.fromhex(vector_list[0])
|
||||
mnemonic = vector_list[1]
|
||||
seed = bytes.fromhex(vector_list[2])
|
||||
|
||||
assert bytes_from_mnemonic(mnemonic) == entropy_bytes
|
||||
assert bytes_to_mnemonic(entropy_bytes) == mnemonic
|
||||
assert mnemonic_to_seed(mnemonic, "TREZOR") == seed
|
||||
|
||||
def test_utf8_nfkd(self):
|
||||
# Test code from trezor:
|
||||
|
|
|
@ -1,18 +1,14 @@
|
|||
import asyncio
|
||||
from secrets import token_bytes
|
||||
from typing import List
|
||||
|
||||
import pytest
|
||||
|
||||
from src.consensus.block_rewards import calculate_pool_reward, calculate_base_farmer_reward
|
||||
from src.server.server import ChiaServer
|
||||
from src.simulator.simulator_protocol import FarmNewBlockProtocol
|
||||
from src.types.peer_info import PeerInfo
|
||||
from src.util.ints import uint16, uint32
|
||||
from src.util.ints import uint16
|
||||
from tests.setup_nodes import (
|
||||
setup_simulators_and_wallets,
|
||||
)
|
||||
from tests.time_out_assert import time_out_assert, time_out_assert_custom_interval
|
||||
|
||||
|
||||
@pytest.fixture(scope="module")
|
||||
|
@ -58,12 +54,12 @@ class TestWalletSimulator:
|
|||
for i in range(0, num_blocks):
|
||||
await full_node_api.farm_new_block(FarmNewBlockProtocol(ph))
|
||||
|
||||
funds = sum(
|
||||
[
|
||||
calculate_pool_reward(uint32(i)) + calculate_base_farmer_reward(uint32(i))
|
||||
for i in range(0, num_blocks - 1)
|
||||
]
|
||||
)
|
||||
# funds = sum(
|
||||
# [
|
||||
# calculate_pool_reward(uint32(i)) + calculate_base_farmer_reward(uint32(i))
|
||||
# for i in range(0, num_blocks - 1)
|
||||
# ]
|
||||
# )
|
||||
|
||||
# await time_out_assert(5, wallet.get_confirmed_balance, funds)
|
||||
|
||||
|
@ -105,7 +101,8 @@ class TestWalletSimulator:
|
|||
# await full_node_api.farm_new_block(FarmNewBlockProtocol(ph))
|
||||
#
|
||||
# new_funds = sum(
|
||||
# [calculate_base_fee(uint32(i)) + calculate_block_reward(uint32(i)) for i in range(1, (2 * num_blocks) - 1)]
|
||||
# [calculate_base_fee(uint32(i)) + calculate_block_reward(uint32(i))
|
||||
# for i in range(1, (2 * num_blocks) - 1)]
|
||||
# )
|
||||
# await time_out_assert(5, wallet.get_confirmed_balance, new_funds - 10)
|
||||
# await time_out_assert(5, wallet.get_unconfirmed_balance, new_funds - 10)
|
||||
|
|
|
@ -30,9 +30,12 @@
|
|||
# coin_2 = Coin(token_bytes(32), token_bytes(32), uint64(12312))
|
||||
# coin_3 = Coin(token_bytes(32), token_bytes(32), uint64(12312))
|
||||
# coin_4 = Coin(token_bytes(32), token_bytes(32), uint64(12312))
|
||||
# record_replaced = WalletCoinRecord(coin_1, uint32(8), uint32(0), False, True, WalletType.STANDARD_WALLET, 0)
|
||||
# record_1 = WalletCoinRecord(coin_1, uint32(4), uint32(0), False, True, WalletType.STANDARD_WALLET, 0)
|
||||
# record_2 = WalletCoinRecord(coin_2, uint32(5), uint32(0), False, True, WalletType.STANDARD_WALLET, 0)
|
||||
# record_replaced = WalletCoinRecord(coin_1, uint32(8), uint32(0),
|
||||
# False, True, WalletType.STANDARD_WALLET, 0)
|
||||
# record_1 = WalletCoinRecord(coin_1, uint32(4), uint32(0), False,
|
||||
# True, WalletType.STANDARD_WALLET, 0)
|
||||
# record_2 = WalletCoinRecord(coin_2, uint32(5), uint32(0),
|
||||
# False, True, WalletType.STANDARD_WALLET, 0)
|
||||
# record_3 = WalletCoinRecord(
|
||||
# coin_3,
|
||||
# uint32(5),
|
||||
|
|
Loading…
Reference in New Issue