Fix lint, and catch harvester drive access failure

This commit is contained in:
Mariano Sorgente 2020-08-30 19:40:59 +09:00 committed by Gene Hoffman
parent 914b385b16
commit 429d7874a0
9 changed files with 52 additions and 31 deletions

View File

@ -30,13 +30,16 @@ def _get_filenames(directory: Path) -> List[Path]:
log.warning(f"Directory: {directory} does not exist.")
return []
all_files: List[Path] = []
for child in directory.iterdir():
if not child.is_dir():
# If it is a file ending in .plot, add it
if child.suffix == ".plot":
all_files.append(child)
else:
log.info(f"Not checking subdirectory {child}")
try:
for child in directory.iterdir():
if not child.is_dir():
# If it is a file ending in .plot, add it
if child.suffix == ".plot":
all_files.append(child)
else:
log.info(f"Not checking subdirectory {child}")
except Exception as e:
log.info(f"Error reading directory {directory} {e}")
return all_files

View File

@ -337,7 +337,9 @@ class CCWallet:
if coin is not None:
if cc_wallet_puzzles.check_is_cc_puzzle(puzzle_program):
inner_puzzle_hash = get_inner_puzzle_hash_from_puzzle(puzzle_program)
inner_puzzle_hash = get_inner_puzzle_hash_from_puzzle(
puzzle_program
)
self.log.info(
f"parent: {coin_name} inner_puzzle for parent is {inner_puzzle_hash.hex()}"
@ -393,9 +395,7 @@ class CCWallet:
return new
def puzzle_for_pk(self, pubkey) -> Program:
inner_puzzle = self.standard_wallet.puzzle_for_pk(
bytes(pubkey)
)
inner_puzzle = self.standard_wallet.puzzle_for_pk(bytes(pubkey))
inner_puzzle_hash = inner_puzzle.get_tree_hash()
cc_puzzle: Program = self.cc_info.puzzle_for_inner_puzzle(inner_puzzle)
self.base_puzzle_program = bytes(cc_puzzle)
@ -440,7 +440,9 @@ class CCWallet:
eve_spend = cc_generate_eve_spend(eve_coin, cc_inner_puzzle, genesis_id)
full_spend = SpendBundle.aggregate([tx.spend_bundle, eve_spend])
future_parent = CCParent(eve_coin.parent_coin_info, cc_inner_puzzle_hash, eve_coin.amount)
future_parent = CCParent(
eve_coin.parent_coin_info, cc_inner_puzzle_hash, eve_coin.amount
)
eve_parent = CCParent(
origin.parent_coin_info, origin.puzzle_hash, origin.amount
)
@ -794,7 +796,9 @@ class CCWallet:
await self.save_info(cc_info)
cc_inner_puzzle = await self.get_new_inner_puzzle()
cc_puzzle = cc_wallet_puzzles.puzzle_for_inner_puzzle(cc_inner_puzzle, origin_id)
cc_puzzle = cc_wallet_puzzles.puzzle_for_inner_puzzle(
cc_inner_puzzle, origin_id
)
cc_puzzle_hash = cc_puzzle.get_tree_hash()
tx_record: Optional[
@ -867,10 +871,7 @@ class CCWallet:
CoinSolution(
coin,
Program.to(
[
self.cc_info.puzzle_for_inner_puzzle(innerpuz),
solution,
]
[self.cc_info.puzzle_for_inner_puzzle(innerpuz), solution]
),
)
)

View File

@ -74,7 +74,9 @@ def cc_make_solution(
aggees_program = Program.to([] if auditees is None else [list(_) for _ in auditees])
solution = Program.to([parent, amount, inner_solution, auditor_list, aggees_program])
solution = Program.to(
[parent, amount, inner_solution, auditor_list, aggees_program]
)
return solution

View File

@ -34,7 +34,9 @@ CC_MOD = load_clvm("cc.clvm", package_or_requirement=__name__)
ZERO_GENESIS_MOD = load_clvm("zero-genesis.clvm", package_or_requirement=__name__)
PUZZLE_TABLE: Dict[bytes32, Program] = dict((_.get_tree_hash(), _) for _ in [ANYONE_CAN_SPEND_PUZZLE])
PUZZLE_TABLE: Dict[bytes32, Program] = dict(
(_.get_tree_hash(), _) for _ in [ANYONE_CAN_SPEND_PUZZLE]
)
def hash_to_puzzle_f(puzzle_hash: bytes32) -> Optional[Program]:

View File

@ -50,7 +50,9 @@ def puzzle_for_public_key_and_hidden_puzzle(
return puzzle_for_synthetic_public_key(synthetic_public_key)
def solution_with_delegated_puzzle(synthetic_public_key, delegated_puzzle, solution) -> Program:
def solution_with_delegated_puzzle(
synthetic_public_key, delegated_puzzle, solution
) -> Program:
puzzle = puzzle_for_synthetic_public_key(synthetic_public_key)
return Program.to([puzzle, [[], delegated_puzzle, solution]])

View File

@ -17,6 +17,8 @@ def puzzle_for_m_of_public_key_list(m, public_key_list) -> Program:
return MOD.curry(m, public_key_list)
def solution_for_delegated_puzzle(m, public_key_list, selectors, puzzle, solution) -> Program:
def solution_for_delegated_puzzle(
m, public_key_list, selectors, puzzle, solution
) -> Program:
puzzle_reveal = puzzle_for_m_of_public_key_list(m, public_key_list)
return Program.to([puzzle_reveal, [selectors, puzzle, solution]])

View File

@ -424,7 +424,9 @@ class TradeManager:
)
if coinsol.coin in [record.coin for record in unspent]:
return False, None, "can't respond to own offer"
innerpuzzlereveal = cc_wallet_puzzles.get_inner_puzzle_from_puzzle(puzzle)
innerpuzzlereveal = cc_wallet_puzzles.get_inner_puzzle_from_puzzle(
puzzle
)
innersol = cc_wallet_puzzles.inner_puzzle_solution(solution)
out_amount = cc_wallet_puzzles.get_output_amount_for_puzzle_and_solution(
innerpuzzlereveal, innersol
@ -661,7 +663,7 @@ class TradeManager:
cc_wallet_puzzles.puzzle_for_inner_puzzle(
auditor_inner_puzzle, bytes.fromhex(colour),
),
solution
solution,
]
),
)

View File

@ -53,7 +53,9 @@ def get_discrepancies_for_spend_bundle(
if not cc_wallet_puzzles.is_ephemeral_solution(solution):
colour = cc_wallet_puzzles.get_genesis_from_puzzle(puzzle).hex()
# get puzzle and solution
innerpuzzlereveal = cc_wallet_puzzles.get_inner_puzzle_from_puzzle(puzzle)
innerpuzzlereveal = cc_wallet_puzzles.get_inner_puzzle_from_puzzle(
puzzle
)
innersol = cc_wallet_puzzles.inner_puzzle_solution(solution)
# Get output amounts by running innerpuzzle and solution
out_amount = cc_wallet_puzzles.get_output_amount_for_puzzle_and_solution(

View File

@ -77,7 +77,7 @@ class TestCCWallet:
assert val["type"] == WalletType.RATE_LIMITED.value
assert val["origin"]
assert val["pubkey"]
admin_wallet_id = val['id']
admin_wallet_id = val["id"]
admin_pubkey = val["pubkey"]
origin: Coin = val["origin"]
@ -96,9 +96,9 @@ class TestCCWallet:
)
assert val["success"]
assert (await api_user.get_wallet_balance({"wallet_id": user_wallet_id}))["wallet_balance"][
"confirmed_wallet_balance"
] == 0
assert (await api_user.get_wallet_balance({"wallet_id": user_wallet_id}))[
"wallet_balance"
]["confirmed_wallet_balance"] == 0
for i in range(0, 2 * num_blocks):
await full_node.farm_new_block(FarmNewBlockProtocol(32 * b"\0"))
@ -112,7 +112,12 @@ class TestCCWallet:
puzzle_hash = 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": 0, "puzzle_hash": puzzle_hash}
{
"wallet_id": user_wallet_id,
"amount": 3,
"fee": 0,
"puzzle_hash": puzzle_hash,
}
)
assert val["status"] == "SUCCESS"
@ -121,8 +126,8 @@ class TestCCWallet:
await time_out_assert(15, check_balance, 97, api_user, user_wallet_id)
await time_out_assert(15, receiving_wallet.get_spendable_balance, 3)
val = await api_admin.send_clawback_transaction({'wallet_id': admin_wallet_id})
assert val['status'] == 'SUCCESS'
val = await api_admin.send_clawback_transaction({"wallet_id": admin_wallet_id})
assert val["status"] == "SUCCESS"
for i in range(0, num_blocks):
await full_node.farm_new_block(FarmNewBlockProtocol(32 * b"\0"))
await time_out_assert(15, check_balance, 0, api_admin, admin_wallet_id)