mirror of
https://github.com/Chia-Network/chia-blockchain.git
synced 2024-11-13 12:09:25 +03:00
Test passing
This commit is contained in:
parent
e1b653310d
commit
5303db737b
@ -58,14 +58,14 @@ class Farmer:
|
||||
raise RuntimeError(error_str)
|
||||
|
||||
# This is the farmer configuration
|
||||
self.wallet_target = decode_puzzle_hash(bytes.fromhex(self.config["xch_target_address"]))
|
||||
self.wallet_target = decode_puzzle_hash(self.config["xch_target_address"])
|
||||
self.pool_public_keys = [
|
||||
G1Element.from_bytes(bytes.fromhex(pk))
|
||||
for pk in self.config["pool_public_keys"]
|
||||
]
|
||||
|
||||
# This is the pool configuration, which should be moved out to the pool once it exists
|
||||
self.pool_target = decode_puzzle_hash(bytes.fromhex(pool_config["xch_target_address"]))
|
||||
self.pool_target = decode_puzzle_hash(pool_config["xch_target_address"])
|
||||
self.pool_sks_map: Dict = {}
|
||||
for key in self._get_private_keys():
|
||||
self.pool_sks_map[bytes(key.get_g1())] = key
|
||||
|
@ -28,10 +28,10 @@ from src.types.full_block import FullBlock, additions_for_npc
|
||||
from src.types.header import Header
|
||||
from src.types.header_block import HeaderBlock
|
||||
from src.types.sized_bytes import bytes32
|
||||
from src.util.blockchain_check_conditions import blockchain_check_conditions_dict
|
||||
from src.full_node.blockchain_check_conditions import blockchain_check_conditions_dict
|
||||
from src.util.clvm import int_from_bytes
|
||||
from src.util.condition_tools import pkm_pairs_for_conditions_dict
|
||||
from src.util.cost_calculator import calculate_cost_of_program
|
||||
from src.full_node.cost_calculator import calculate_cost_of_program
|
||||
from src.util.errors import ConsensusError, Err
|
||||
from src.util.hash import std_hash
|
||||
from src.util.ints import uint32, uint64
|
||||
|
@ -6,7 +6,7 @@ from src.types.program import Program
|
||||
from src.types.name_puzzle_condition import NPC
|
||||
from src.util.errors import Err
|
||||
from src.util.ints import uint64
|
||||
from src.util.mempool_check_conditions import get_name_puzzle_conditions
|
||||
from src.full_node.mempool_check_conditions import get_name_puzzle_conditions
|
||||
|
||||
|
||||
def calculate_cost_of_program(
|
@ -48,8 +48,8 @@ from src.types.proof_of_time import ProofOfTime
|
||||
from src.types.sized_bytes import bytes32
|
||||
from src.types.spend_bundle import SpendBundle
|
||||
from src.util.api_decorators import api_request
|
||||
from src.util.bundle_tools import best_solution_program
|
||||
from src.util.cost_calculator import calculate_cost_of_program
|
||||
from src.full_node.bundle_tools import best_solution_program
|
||||
from src.full_node.cost_calculator import calculate_cost_of_program
|
||||
from src.util.errors import ConsensusError, Err
|
||||
from src.util.hash import std_hash
|
||||
from src.util.ints import uint32, uint64, uint128
|
||||
@ -613,12 +613,11 @@ class FullNode:
|
||||
# Ignore if we have already added this transaction
|
||||
if self.mempool_manager.get_spendbundle(tx.transaction.name()) is not None:
|
||||
return
|
||||
self.log.warning(f"Adding transaction to mempool: {transaction.transaction_id}")
|
||||
cost, status, error = await self.mempool_manager.add_spendbundle(
|
||||
tx.transaction
|
||||
)
|
||||
if status == MempoolInclusionStatus.SUCCESS:
|
||||
self.log.warning(f"Added transaction to mempool: {transaction.transaction_id}")
|
||||
self.log.info(f"Added transaction to mempool: {tx.transaction.name()}")
|
||||
fees = tx.transaction.fees()
|
||||
assert fees >= 0
|
||||
assert cost is not None
|
||||
|
@ -9,7 +9,7 @@ from blspy import G1Element, G2Element, AugSchemeMPL
|
||||
from src.consensus.constants import ConsensusConstants
|
||||
from src.types.condition_opcodes import ConditionOpcode
|
||||
from src.types.condition_var_pair import ConditionVarPair
|
||||
from src.util.bundle_tools import best_solution_program
|
||||
from src.full_node.bundle_tools import best_solution_program
|
||||
from src.types.full_block import FullBlock
|
||||
from src.types.coin import Coin
|
||||
from src.types.spend_bundle import SpendBundle
|
||||
@ -21,8 +21,8 @@ from src.types.sized_bytes import bytes32
|
||||
from src.full_node.coin_store import CoinStore
|
||||
from src.util.errors import Err
|
||||
from src.util.clvm import int_from_bytes
|
||||
from src.util.cost_calculator import calculate_cost_of_program
|
||||
from src.util.mempool_check_conditions import mempool_check_conditions_dict
|
||||
from src.full_node.cost_calculator import calculate_cost_of_program
|
||||
from src.full_node.mempool_check_conditions import mempool_check_conditions_dict
|
||||
from src.util.condition_tools import pkm_pairs_for_conditions_dict
|
||||
from src.util.ints import uint64, uint32
|
||||
from src.types.mempool_inclusion_status import MempoolInclusionStatus
|
||||
|
@ -21,9 +21,9 @@ class WalletRpcClient(RpcClient):
|
||||
=======
|
||||
async def send_transaction(
|
||||
self, wallet_id: str, amount: uint64, address: str, fee: uint64 = uint64(0)
|
||||
) -> TransactionRecord:
|
||||
) -> Dict:
|
||||
|
||||
response = await self.fetch(
|
||||
res = await self.fetch(
|
||||
"send_transaction",
|
||||
{
|
||||
"wallet_id": wallet_id,
|
||||
@ -32,24 +32,33 @@ class WalletRpcClient(RpcClient):
|
||||
"fee": fee,
|
||||
},
|
||||
)
|
||||
if response["success"]:
|
||||
return TransactionRecord.from_json_dict(response["transaction"])
|
||||
raise Exception(response["reason"])
|
||||
res["transaction"] = TransactionRecord.from_json_dict(res["transaction"])
|
||||
return res
|
||||
|
||||
async def get_next_address(self, wallet_id: str) -> Dict:
|
||||
return await self.fetch("get_next_address", {"wallet_id": wallet_id})
|
||||
|
||||
async def get_transaction(
|
||||
self, wallet_id: str, transaction_id: bytes32
|
||||
) -> Optional[TransactionRecord]:
|
||||
) -> Dict:
|
||||
|
||||
response = await self.fetch(
|
||||
res = await self.fetch(
|
||||
"get_transaction",
|
||||
{"walled_id": wallet_id, "transaction_id": transaction_id.hex()},
|
||||
)
|
||||
if response["success"]:
|
||||
return TransactionRecord.from_json_dict(response["transaction"])
|
||||
return None
|
||||
res["transaction"] = TransactionRecord.from_json_dict(res["transaction"])
|
||||
return res
|
||||
|
||||
async def get_transactions(
|
||||
self, wallet_id: str,
|
||||
) -> Dict:
|
||||
res = await self.fetch(
|
||||
"get_transactions",
|
||||
{"walled_id": wallet_id},
|
||||
)
|
||||
parsed = [TransactionRecord.from_json_dict(tx) for tx in res["transactions"])
|
||||
res[transactions] = parsed
|
||||
return res
|
||||
|
||||
>>>>>>> f1c565a8... More test
|
||||
async def log_in(self, fingerprint) -> Dict:
|
||||
|
@ -7,7 +7,7 @@ from src.protocols import (
|
||||
wallet_protocol,
|
||||
)
|
||||
from src.simulator.simulator_protocol import FarmNewBlockProtocol, ReorgProtocol
|
||||
from src.util.bundle_tools import best_solution_program
|
||||
from src.full_node.bundle_tools import best_solution_program
|
||||
from src.server.outbound_message import OutboundMessage
|
||||
from src.server.server import ChiaServer
|
||||
from src.types.full_block import FullBlock
|
||||
|
@ -6,7 +6,7 @@ from src.types.program import Program
|
||||
from src.types.coin import Coin
|
||||
from src.types.header import Header
|
||||
from src.types.sized_bytes import bytes32
|
||||
from src.util.mempool_check_conditions import get_name_puzzle_conditions
|
||||
from src.full_node.mempool_check_conditions import get_name_puzzle_conditions
|
||||
from src.util.condition_tools import created_outputs_for_conditions_dict
|
||||
from src.util.ints import uint32, uint128
|
||||
from src.util.streamable import Streamable, streamable
|
||||
|
@ -39,7 +39,7 @@ from src.util.ints import uint8, uint32, uint64, uint128, int512
|
||||
from src.util.hash import std_hash
|
||||
from src.util.path import mkdir
|
||||
from src.util.significant_bits import truncate_to_significant_bits
|
||||
from src.util.mempool_check_conditions import get_name_puzzle_conditions
|
||||
from src.full_node.mempool_check_conditions import get_name_puzzle_conditions
|
||||
from src.plotting.plot_tools import load_plots
|
||||
from src.util.logging import initialize_logging
|
||||
from src.util.wallet_tools import WalletTool
|
||||
|
@ -698,7 +698,7 @@ class WalletStateManager:
|
||||
Full node received our transaction, no need to keep it in queue anymore
|
||||
"""
|
||||
await self.tx_store.increment_sent(spendbundle_id, name, send_status, error)
|
||||
tx: Optional[TransactionRecord] = self.get_transaction(spendbundle_id)
|
||||
tx: Optional[TransactionRecord] = await self.get_transaction(spendbundle_id)
|
||||
if tx is not None:
|
||||
self.state_changed("tx_update", tx.wallet_id, {"transaction": tx})
|
||||
|
||||
|
@ -9,7 +9,7 @@ from src.types.condition_var_pair import ConditionVarPair
|
||||
from src.types.condition_opcodes import ConditionOpcode
|
||||
from src.types.header import HeaderData, Header
|
||||
from src.types.sized_bytes import bytes32
|
||||
from src.util.bundle_tools import best_solution_program
|
||||
from src.full_node.bundle_tools import best_solution_program
|
||||
from src.server.outbound_message import OutboundMessage
|
||||
from src.protocols import full_node_protocol
|
||||
from src.types.full_block import FullBlock
|
||||
|
@ -16,7 +16,7 @@ from src.types.peer_info import PeerInfo
|
||||
from src.types.full_block import FullBlock
|
||||
from src.types.proof_of_space import ProofOfSpace
|
||||
from src.types.spend_bundle import SpendBundle
|
||||
from src.util.bundle_tools import best_solution_program
|
||||
from src.full_node.bundle_tools import best_solution_program
|
||||
from src.util.ints import uint16, uint32, uint64, uint8
|
||||
from src.util.hash import std_hash
|
||||
from src.full_node.full_node import FullNode
|
||||
|
@ -89,12 +89,11 @@ class TestWalletRpc:
|
||||
await wallet_node_2.wallet_state_manager.main_wallet.get_new_puzzlehash()
|
||||
)
|
||||
tx_amount = 15600000
|
||||
tx = await client.send_transaction("1", tx_amount, addr)
|
||||
assert tx is not None
|
||||
tx = (await client.send_transaction("1", tx_amount, addr))["transaction"]
|
||||
transaction_id = tx.name()
|
||||
|
||||
async def tx_in_mempool():
|
||||
tx = await client.get_transaction("1", transaction_id)
|
||||
tx = (await client.get_transaction("1", transaction_id))["transaction"]
|
||||
return tx.is_in_mempool()
|
||||
await time_out_assert(5, tx_in_mempool, True)
|
||||
await time_out_assert(5, wallet.get_unconfirmed_balance, initial_funds - tx_amount)
|
||||
@ -109,7 +108,11 @@ class TestWalletRpc:
|
||||
|
||||
await time_out_assert(5, eventual_balance, initial_funds_eventually - tx_amount)
|
||||
|
||||
await client.get_next_address()
|
||||
address = (await client.get_next_address("1"))["address"]
|
||||
assert len(address) > 10
|
||||
|
||||
txs = (await client.get_transactions("1"))["transactions"]
|
||||
|
||||
|
||||
|
||||
except Exception:
|
||||
|
@ -270,9 +270,9 @@ async def setup_farmer(
|
||||
config = load_config(bt.root_path, "config.yaml", "farmer")
|
||||
config_pool = load_config(bt.root_path, "config.yaml", "pool")
|
||||
|
||||
config["xch_target_address"] = encode_puzzle_hash(bt.farmer_ph).hex()
|
||||
config["xch_target_address"] = encode_puzzle_hash(bt.farmer_ph)
|
||||
config["pool_public_keys"] = [bytes(pk).hex() for pk in bt.pool_pubkeys]
|
||||
config_pool["xch_target_address"] = encode_puzzle_hash(bt.pool_ph).hex()
|
||||
config_pool["xch_target_address"] = encode_puzzle_hash(bt.pool_ph)
|
||||
if full_node_port:
|
||||
connect_peers = [PeerInfo(self_hostname, full_node_port)]
|
||||
else:
|
||||
|
@ -2,9 +2,9 @@ import asyncio
|
||||
|
||||
import pytest
|
||||
|
||||
from src.util.bundle_tools import best_solution_program
|
||||
from src.util.cost_calculator import calculate_cost_of_program
|
||||
from src.util.mempool_check_conditions import get_name_puzzle_conditions
|
||||
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
|
||||
from src.util.wallet_tools import WalletTool
|
||||
|
||||
|
@ -7,7 +7,7 @@ from src.protocols import full_node_protocol
|
||||
from src.util.ints import uint16, uint64, uint32
|
||||
from tests.setup_nodes import setup_node_and_wallet, test_constants, bt
|
||||
from src.types.spend_bundle import SpendBundle
|
||||
from src.util.bundle_tools import best_solution_program
|
||||
from src.full_node.bundle_tools import best_solution_program
|
||||
from src.util.wallet_tools import WalletTool
|
||||
from src.types.coin import Coin
|
||||
from src.consensus.coinbase import create_coinbase_coin
|
||||
|
Loading…
Reference in New Issue
Block a user