mirror of
https://github.com/Chia-Network/chia-blockchain.git
synced 2024-11-29 05:18:11 +03:00
black tests/
This commit is contained in:
parent
c32809b749
commit
f7f38685d3
@ -297,8 +297,10 @@ class TestCCWallet:
|
||||
await time_out_assert(15, cc_wallet_2.get_unconfirmed_balance, 60)
|
||||
|
||||
cc2_ph = await cc_wallet_2.get_new_cc_puzzle_hash()
|
||||
tx_record = await wallet.wallet_state_manager.main_wallet.generate_signed_transaction(
|
||||
10, cc2_ph, 0
|
||||
tx_record = (
|
||||
await wallet.wallet_state_manager.main_wallet.generate_signed_transaction(
|
||||
10, cc2_ph, 0
|
||||
)
|
||||
)
|
||||
await wallet.wallet_state_manager.add_pending_transaction(tx_record)
|
||||
|
||||
|
@ -37,7 +37,10 @@ class TestPotIterations:
|
||||
]
|
||||
iters = [
|
||||
calculate_iterations_quality(
|
||||
qualities[i], farmer_ks[i], uint64(50000000), uint64(5000 * 30),
|
||||
qualities[i],
|
||||
farmer_ks[i],
|
||||
uint64(50000000),
|
||||
uint64(5000 * 30),
|
||||
)
|
||||
for i in range(len(qualities))
|
||||
]
|
||||
|
@ -698,11 +698,15 @@ class TestBlockchainTransactions:
|
||||
spent_block = blocks[1]
|
||||
bad_block = blocks[2]
|
||||
valid_cvp = ConditionVarPair(
|
||||
ConditionOpcode.ASSERT_MY_COIN_ID, spent_block.get_coinbase().name(), None,
|
||||
ConditionOpcode.ASSERT_MY_COIN_ID,
|
||||
spent_block.get_coinbase().name(),
|
||||
None,
|
||||
)
|
||||
valid_dic = {valid_cvp.opcode: [valid_cvp]}
|
||||
bad_cvp = ConditionVarPair(
|
||||
ConditionOpcode.ASSERT_MY_COIN_ID, bad_block.get_coinbase().name(), None,
|
||||
ConditionOpcode.ASSERT_MY_COIN_ID,
|
||||
bad_block.get_coinbase().name(),
|
||||
None,
|
||||
)
|
||||
|
||||
bad_dic = {bad_cvp.opcode: [bad_cvp]}
|
||||
@ -776,7 +780,9 @@ class TestBlockchainTransactions:
|
||||
|
||||
# This condition requires block2 coinbase to be spent
|
||||
block1_cvp = ConditionVarPair(
|
||||
ConditionOpcode.ASSERT_COIN_CONSUMED, block2.get_coinbase().name(), None,
|
||||
ConditionOpcode.ASSERT_COIN_CONSUMED,
|
||||
block2.get_coinbase().name(),
|
||||
None,
|
||||
)
|
||||
block1_dic = {block1_cvp.opcode: [block1_cvp]}
|
||||
block1_spend_bundle = wallet_a.generate_signed_transaction(
|
||||
@ -785,7 +791,9 @@ class TestBlockchainTransactions:
|
||||
|
||||
# This condition requires block1 coinbase to be spent
|
||||
block2_cvp = ConditionVarPair(
|
||||
ConditionOpcode.ASSERT_COIN_CONSUMED, block1.get_coinbase().name(), None,
|
||||
ConditionOpcode.ASSERT_COIN_CONSUMED,
|
||||
block1.get_coinbase().name(),
|
||||
None,
|
||||
)
|
||||
block2_dic = {block2_cvp.opcode: [block2_cvp]}
|
||||
block2_spend_bundle = wallet_a.generate_signed_transaction(
|
||||
|
@ -155,7 +155,11 @@ class TestFullNodeProtocol:
|
||||
|
||||
dic_h = {5: (program, aggsig)}
|
||||
blocks_new = bt.get_consecutive_blocks(
|
||||
test_constants, 3, blocks[:-1], 10, transaction_data_at_height=dic_h,
|
||||
test_constants,
|
||||
3,
|
||||
blocks[:-1],
|
||||
10,
|
||||
transaction_data_at_height=dic_h,
|
||||
)
|
||||
# Already seen
|
||||
msgs = [x async for x in full_node_1.new_transaction(new_transaction)]
|
||||
@ -226,7 +230,9 @@ class TestFullNodeProtocol:
|
||||
|
||||
receiver_puzzlehash = wallet_receiver.get_new_puzzlehash()
|
||||
spend_bundle = wallet_a.generate_signed_transaction(
|
||||
100, receiver_puzzlehash, blocks[2].get_coinbase(),
|
||||
100,
|
||||
receiver_puzzlehash,
|
||||
blocks[2].get_coinbase(),
|
||||
)
|
||||
assert spend_bundle is not None
|
||||
respond_transaction = fnp.RespondTransaction(spend_bundle)
|
||||
@ -254,7 +260,9 @@ class TestFullNodeProtocol:
|
||||
|
||||
# Invalid transaction does not propagate
|
||||
spend_bundle = wallet_a.generate_signed_transaction(
|
||||
100000000000000, receiver_puzzlehash, blocks[3].get_coinbase(),
|
||||
100000000000000,
|
||||
receiver_puzzlehash,
|
||||
blocks[3].get_coinbase(),
|
||||
)
|
||||
assert spend_bundle is not None
|
||||
respond_transaction = fnp.RespondTransaction(spend_bundle)
|
||||
@ -276,7 +284,11 @@ class TestFullNodeProtocol:
|
||||
blocks = await get_block_path(full_node_1)
|
||||
|
||||
blocks_new = bt.get_consecutive_blocks(
|
||||
test_constants, 1, blocks[:-1], 10, seed=b"1212412",
|
||||
test_constants,
|
||||
1,
|
||||
blocks[:-1],
|
||||
10,
|
||||
seed=b"1212412",
|
||||
)
|
||||
|
||||
unf_block = FullBlock(
|
||||
@ -340,7 +352,11 @@ class TestFullNodeProtocol:
|
||||
blocks_list = await get_block_path(full_node_1)
|
||||
|
||||
blocks_new = bt.get_consecutive_blocks(
|
||||
test_constants, 1, blocks_list, 10, seed=b"another seed",
|
||||
test_constants,
|
||||
1,
|
||||
blocks_list,
|
||||
10,
|
||||
seed=b"another seed",
|
||||
)
|
||||
assert blocks_new[-1].proof_of_time is not None
|
||||
new_pot = fnp.NewProofOfTime(
|
||||
@ -380,7 +396,11 @@ class TestFullNodeProtocol:
|
||||
blocks_list = await get_block_path(full_node_1)
|
||||
|
||||
blocks_new = bt.get_consecutive_blocks(
|
||||
test_constants, 1, blocks_list, 10, seed=b"another seed 2",
|
||||
test_constants,
|
||||
1,
|
||||
blocks_list,
|
||||
10,
|
||||
seed=b"another seed 2",
|
||||
)
|
||||
assert blocks_new[-1].proof_of_time is not None
|
||||
assert blocks_new[-2].proof_of_time is not None
|
||||
@ -427,7 +447,11 @@ class TestFullNodeProtocol:
|
||||
blocks_list = await get_block_path(full_node_1)
|
||||
|
||||
blocks_new = bt.get_consecutive_blocks(
|
||||
test_constants, 2, blocks_list, 10, seed=b"another seed 3",
|
||||
test_constants,
|
||||
2,
|
||||
blocks_list,
|
||||
10,
|
||||
seed=b"another seed 3",
|
||||
)
|
||||
# Add one block
|
||||
[_ async for _ in full_node_1.respond_block(fnp.RespondBlock(blocks_new[-2]))]
|
||||
@ -468,7 +492,11 @@ class TestFullNodeProtocol:
|
||||
blocks_list = await get_block_path(full_node_1)
|
||||
|
||||
blocks_new = bt.get_consecutive_blocks(
|
||||
test_constants, 1, blocks_list[:], 4, seed=b"Another seed 4",
|
||||
test_constants,
|
||||
1,
|
||||
blocks_list[:],
|
||||
4,
|
||||
seed=b"Another seed 4",
|
||||
)
|
||||
for block in blocks_new:
|
||||
[_ async for _ in full_node_1.respond_block(fnp.RespondBlock(block))]
|
||||
@ -582,7 +610,10 @@ class TestFullNodeProtocol:
|
||||
# Don't propagate at old height
|
||||
[_ async for _ in full_node_1.respond_block(fnp.RespondBlock(candidates[0]))]
|
||||
blocks_new_3 = bt.get_consecutive_blocks(
|
||||
test_constants, 1, blocks_new[:] + [candidates[0]], 10,
|
||||
test_constants,
|
||||
1,
|
||||
blocks_new[:] + [candidates[0]],
|
||||
10,
|
||||
)
|
||||
unf_block_new = FullBlock(
|
||||
blocks_new_3[-1].proof_of_space,
|
||||
@ -682,7 +713,11 @@ class TestFullNodeProtocol:
|
||||
blocks_list = await get_block_path(full_node_1)
|
||||
|
||||
blocks_new = bt.get_consecutive_blocks(
|
||||
test_constants, 5, blocks_list[:], 10, seed=b"Another seed 5",
|
||||
test_constants,
|
||||
5,
|
||||
blocks_list[:],
|
||||
10,
|
||||
seed=b"Another seed 5",
|
||||
)
|
||||
|
||||
# In sync mode
|
||||
@ -743,7 +778,11 @@ class TestFullNodeProtocol:
|
||||
|
||||
# If orphan, don't send anything
|
||||
blocks_orphan = bt.get_consecutive_blocks(
|
||||
test_constants, 1, blocks_list[:-5], 10, seed=b"Another seed 6",
|
||||
test_constants,
|
||||
1,
|
||||
blocks_list[:-5],
|
||||
10,
|
||||
seed=b"Another seed 6",
|
||||
)
|
||||
|
||||
msgs = [
|
||||
@ -791,13 +830,18 @@ class TestWalletProtocol:
|
||||
blocks_list = await get_block_path(full_node_1)
|
||||
|
||||
blocks_new = bt.get_consecutive_blocks(
|
||||
test_constants, 1, block_list=blocks_list, seed=b"test_request_additions",
|
||||
test_constants,
|
||||
1,
|
||||
block_list=blocks_list,
|
||||
seed=b"test_request_additions",
|
||||
)
|
||||
async for _ in full_node_1.respond_block(fnp.RespondBlock(blocks_new[-1])):
|
||||
pass
|
||||
|
||||
spend_bundle = wallet_a.generate_signed_transaction(
|
||||
100, wallet_a.get_new_puzzlehash(), blocks_new[-1].get_coinbase(),
|
||||
100,
|
||||
wallet_a.get_new_puzzlehash(),
|
||||
blocks_new[-1].get_coinbase(),
|
||||
)
|
||||
spend_bundle_bad = wallet_a.generate_signed_transaction(
|
||||
constants.MAX_COIN_AMOUNT,
|
||||
@ -1002,7 +1046,9 @@ class TestWalletProtocol:
|
||||
|
||||
# If there are no transactions, empty proof and coins
|
||||
blocks_new = bt.get_consecutive_blocks(
|
||||
test_constants, 10, block_list=blocks_list,
|
||||
test_constants,
|
||||
10,
|
||||
block_list=blocks_list,
|
||||
)
|
||||
for block in blocks_new:
|
||||
[_ async for _ in full_node_1.respond_block(fnp.RespondBlock(block))]
|
||||
@ -1182,7 +1228,9 @@ class TestWalletProtocol:
|
||||
|
||||
# If there are no transactions, only cb and fees additions
|
||||
blocks_new = bt.get_consecutive_blocks(
|
||||
test_constants, 10, block_list=blocks_list,
|
||||
test_constants,
|
||||
10,
|
||||
block_list=blocks_list,
|
||||
)
|
||||
for block in blocks_new:
|
||||
[_ async for _ in full_node_1.respond_block(fnp.RespondBlock(block))]
|
||||
@ -1205,7 +1253,9 @@ class TestWalletProtocol:
|
||||
for i in range(5):
|
||||
spend_bundles.append(
|
||||
wallet_a.generate_signed_transaction(
|
||||
100, puzzle_hashes[i % 2], blocks_new[i - 8].get_coinbase(),
|
||||
100,
|
||||
puzzle_hashes[i % 2],
|
||||
blocks_new[i - 8].get_coinbase(),
|
||||
)
|
||||
)
|
||||
height_with_transactions = len(blocks_new) + 1
|
||||
|
@ -427,7 +427,9 @@ class TestMempool:
|
||||
pass
|
||||
|
||||
cvp = ConditionVarPair(
|
||||
ConditionOpcode.ASSERT_MY_COIN_ID, blocks[2].get_coinbase().name(), None,
|
||||
ConditionOpcode.ASSERT_MY_COIN_ID,
|
||||
blocks[2].get_coinbase().name(),
|
||||
None,
|
||||
)
|
||||
dic = {cvp.opcode: [cvp]}
|
||||
|
||||
@ -565,7 +567,9 @@ class TestMempool:
|
||||
pass
|
||||
|
||||
cvp = ConditionVarPair(
|
||||
ConditionOpcode.ASSERT_COIN_CONSUMED, block2.get_coinbase().name(), None,
|
||||
ConditionOpcode.ASSERT_COIN_CONSUMED,
|
||||
block2.get_coinbase().name(),
|
||||
None,
|
||||
)
|
||||
dic = {cvp.opcode: [cvp]}
|
||||
|
||||
@ -611,7 +615,9 @@ class TestMempool:
|
||||
pass
|
||||
|
||||
cvp = ConditionVarPair(
|
||||
ConditionOpcode.ASSERT_COIN_CONSUMED, block2.get_coinbase().name(), None,
|
||||
ConditionOpcode.ASSERT_COIN_CONSUMED,
|
||||
block2.get_coinbase().name(),
|
||||
None,
|
||||
)
|
||||
dic = {cvp.opcode: [cvp]}
|
||||
|
||||
@ -652,7 +658,11 @@ class TestMempool:
|
||||
):
|
||||
pass
|
||||
|
||||
cvp = ConditionVarPair(ConditionOpcode.ASSERT_FEE, int_to_bytes(10), None,)
|
||||
cvp = ConditionVarPair(
|
||||
ConditionOpcode.ASSERT_FEE,
|
||||
int_to_bytes(10),
|
||||
None,
|
||||
)
|
||||
dic = {cvp.opcode: [cvp]}
|
||||
|
||||
spend_bundle1 = wallet_a.generate_signed_transaction(
|
||||
@ -700,7 +710,11 @@ class TestMempool:
|
||||
):
|
||||
pass
|
||||
|
||||
cvp = ConditionVarPair(ConditionOpcode.ASSERT_FEE, int_to_bytes(10), None,)
|
||||
cvp = ConditionVarPair(
|
||||
ConditionOpcode.ASSERT_FEE,
|
||||
int_to_bytes(10),
|
||||
None,
|
||||
)
|
||||
dic = {cvp.opcode: [cvp]}
|
||||
|
||||
spend_bundle1 = wallet_a.generate_signed_transaction(
|
||||
@ -752,7 +766,11 @@ class TestMempool:
|
||||
):
|
||||
pass
|
||||
|
||||
cvp = ConditionVarPair(ConditionOpcode.ASSERT_FEE, int_to_bytes(10), None,)
|
||||
cvp = ConditionVarPair(
|
||||
ConditionOpcode.ASSERT_FEE,
|
||||
int_to_bytes(10),
|
||||
None,
|
||||
)
|
||||
dic = {cvp.opcode: [cvp]}
|
||||
|
||||
fee = 9
|
||||
|
@ -100,8 +100,10 @@ class TestTransactions:
|
||||
10, wallet_0.wallet_state_manager.main_wallet.get_confirmed_balance, funds
|
||||
)
|
||||
|
||||
tx = await wallet_0.wallet_state_manager.main_wallet.generate_signed_transaction(
|
||||
10, ph1, 0
|
||||
tx = (
|
||||
await wallet_0.wallet_state_manager.main_wallet.generate_signed_transaction(
|
||||
10, ph1, 0
|
||||
)
|
||||
)
|
||||
await wallet_0.wallet_state_manager.main_wallet.push_transaction(tx)
|
||||
|
||||
@ -173,8 +175,10 @@ class TestTransactions:
|
||||
10, wallet_0.wallet_state_manager.main_wallet.get_confirmed_balance, funds
|
||||
)
|
||||
|
||||
tx = await wallet_0.wallet_state_manager.main_wallet.generate_signed_transaction(
|
||||
10, token_bytes(), 0
|
||||
tx = (
|
||||
await wallet_0.wallet_state_manager.main_wallet.generate_signed_transaction(
|
||||
10, token_bytes(), 0
|
||||
)
|
||||
)
|
||||
await wallet_0.wallet_state_manager.main_wallet.push_transaction(tx)
|
||||
|
||||
|
@ -453,7 +453,10 @@ async def setup_node_and_wallet(
|
||||
|
||||
|
||||
async def setup_simulators_and_wallets(
|
||||
simulator_count: int, wallet_count: int, dic: Dict, starting_height=None,
|
||||
simulator_count: int,
|
||||
wallet_count: int,
|
||||
dic: Dict,
|
||||
starting_height=None,
|
||||
):
|
||||
simulators: List[Tuple[FullNode, ChiaServer]] = []
|
||||
wallets = []
|
||||
|
@ -22,7 +22,12 @@ class TestCostCalculation:
|
||||
receiver = WalletTool()
|
||||
|
||||
num_blocks = 2
|
||||
blocks = bt.get_consecutive_blocks(test_constants, num_blocks, [], 10,)
|
||||
blocks = bt.get_consecutive_blocks(
|
||||
test_constants,
|
||||
num_blocks,
|
||||
[],
|
||||
10,
|
||||
)
|
||||
|
||||
spend_bundle = wallet_tool.generate_signed_transaction(
|
||||
blocks[1].get_coinbase().amount,
|
||||
|
@ -19,7 +19,12 @@ class TestMerkleSet:
|
||||
WalletTool()
|
||||
|
||||
num_blocks = 10
|
||||
blocks = bt.get_consecutive_blocks(test_constants, num_blocks, [], 10,)
|
||||
blocks = bt.get_consecutive_blocks(
|
||||
test_constants,
|
||||
num_blocks,
|
||||
[],
|
||||
10,
|
||||
)
|
||||
|
||||
merkle_set = MerkleSet()
|
||||
merkle_set_reverse = MerkleSet()
|
||||
|
@ -191,8 +191,10 @@ class TestWalletSimulator:
|
||||
5, wallet_0.wallet_state_manager.main_wallet.get_confirmed_balance, funds
|
||||
)
|
||||
|
||||
tx = await wallet_0.wallet_state_manager.main_wallet.generate_signed_transaction(
|
||||
10, token_bytes(), 0
|
||||
tx = (
|
||||
await wallet_0.wallet_state_manager.main_wallet.generate_signed_transaction(
|
||||
10, token_bytes(), 0
|
||||
)
|
||||
)
|
||||
await wallet_0.wallet_state_manager.main_wallet.push_transaction(tx)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user