From ce45e15b9f2d36e23e2105eddf478cfcf5b011c0 Mon Sep 17 00:00:00 2001 From: "Mark A. Greenslade" Date: Wed, 3 Mar 2021 23:51:07 +0100 Subject: [PATCH] 1. Auction withdraw bid updated. --- stests/__init__.py | 2 +- stests/chain/set_auction_bid_submit.py | 2 +- stests/chain/set_auction_bid_withdraw.py | 19 ++++++++++++++----- stests/generators/wg_200/p1s1_submit_bid.py | 3 --- stests/generators/wg_201/p1s1_withdraw_bid.py | 19 +++---------------- 5 files changed, 19 insertions(+), 26 deletions(-) diff --git a/stests/__init__.py b/stests/__init__.py index 5cf1a157..12dff440 100644 --- a/stests/__init__.py +++ b/stests/__init__.py @@ -7,7 +7,7 @@ # ╚═════╝░░░░╚═╝░░░╚══════╝╚═════╝░░░░╚═╝░░░╚═════╝░ __title__ = "stests" -__version__ = "1.2.6" +__version__ = "1.2.7" __author__ = "Casper Labs AG, Zug, Switzerland" __license__ = "CasperLabs Open Source License (COSL)" __copyright__ = "Copyright 2020 Casper Labs" diff --git a/stests/chain/set_auction_bid_submit.py b/stests/chain/set_auction_bid_submit.py index 409b4987..0c31c7b8 100644 --- a/stests/chain/set_auction_bid_submit.py +++ b/stests/chain/set_auction_bid_submit.py @@ -40,7 +40,7 @@ def execute(info: DeployDispatchInfo, amount: int, delegation_rate: int, verbose if verbose: log_event( EventType.WFLOW_DEPLOY_DISPATCHED, - f"{info.node.address} :: {deploy_hash} :: auction add-bid :: {amount} CSPR :: from node {info.node.index} ", + f"{info.node.address} :: {deploy_hash} :: auction add-bid :: {amount} CSPR :: by node {info.node.index} ", info.node, deploy_hash=deploy_hash, ) diff --git a/stests/chain/set_auction_bid_withdraw.py b/stests/chain/set_auction_bid_withdraw.py index a26b2034..af33749f 100644 --- a/stests/chain/set_auction_bid_withdraw.py +++ b/stests/chain/set_auction_bid_withdraw.py @@ -1,6 +1,7 @@ from stests.chain import set_deploy from stests.chain.utils import execute_cli from stests.chain.utils import DeployDispatchInfo +from stests.core.logging import log_event from stests.events import EventType @@ -13,18 +14,17 @@ @execute_cli(_CLIENT_METHOD, EventType.WFLOW_DEPLOY_DISPATCH_FAILURE) -def execute(info: DeployDispatchInfo, amount: int) -> str: +def execute(info: DeployDispatchInfo, amount: int, verbose: bool = True) -> str: """Withdraws a bid from network's validator slot auction contract. :param info: Information required when dispatching a deploy. :param amount: Amount to withdraw from auction bid (motes). + :param verbose: Flag inidcating whether event will be logged. :returns: Deploy hash. """ - main_purse_uref = "TODO" - - return set_deploy.execute( + deploy_hash = set_deploy.execute( info.network, info.node, info.dispatcher, @@ -32,6 +32,15 @@ def execute(info: DeployDispatchInfo, amount: int) -> str: [ "--session-arg", f"amount:u512='{amount}'", "--session-arg", f"public_key:public_key='{info.dispatcher.account_key}'", - "--session-arg", f"unbond_purse:uref='{main_purse_uref}'", ] ) + + if verbose: + log_event( + EventType.WFLOW_DEPLOY_DISPATCHED, + f"{info.node.address} :: {deploy_hash} :: auction withdraw-bid :: {amount} CSPR :: by node {info.node.index} ", + info.node, + deploy_hash=deploy_hash, + ) + + return deploy_hash diff --git a/stests/generators/wg_200/p1s1_submit_bid.py b/stests/generators/wg_200/p1s1_submit_bid.py index 169207c7..8230c399 100644 --- a/stests/generators/wg_200/p1s1_submit_bid.py +++ b/stests/generators/wg_200/p1s1_submit_bid.py @@ -1,13 +1,10 @@ from stests import chain from stests.core import cache from stests.core import factory -from stests.core.types.chain import AccountType from stests.core.types.chain import DeployType from stests.core.types.orchestration import ExecutionContext -from stests.generators.utils import verification from stests.generators.utils.infra import get_network_node -import time # Step label. diff --git a/stests/generators/wg_201/p1s1_withdraw_bid.py b/stests/generators/wg_201/p1s1_withdraw_bid.py index 0e17d418..ffaa6f67 100644 --- a/stests/generators/wg_201/p1s1_withdraw_bid.py +++ b/stests/generators/wg_201/p1s1_withdraw_bid.py @@ -1,13 +1,12 @@ from stests import chain from stests.core import cache from stests.core import factory -from stests.core.types.chain import AccountType from stests.core.types.chain import DeployType from stests.core.types.orchestration import ExecutionContext -from stests.generators.utils import verification from stests.generators.utils.infra import get_network_node + # Step label. LABEL = "auction-bid-withdraw" @@ -24,11 +23,8 @@ def execute(ctx: ExecutionContext): # Set target network / node. network, node = get_network_node(ctx) - # Set validator account. - validator = factory.create_account_for_run(ctx, _USER_ACCOUNT_INDEX, "WG-200") - # Submit deploy. - dispatch_info = chain.DeployDispatchInfo(validator, network, node) + dispatch_info = chain.DeployDispatchInfo(node.account, network, node) deploy_hash, dispatch_duration, dispatch_attempts = \ chain.set_auction_bid_withdraw( dispatch_info, @@ -38,19 +34,10 @@ def execute(ctx: ExecutionContext): # Update cache: deploy. cache.state.set_deploy(factory.create_deploy_for_run( ctx=ctx, - account=validator, + account=node.account, node=node, deploy_hash=deploy_hash, dispatch_attempts=dispatch_attempts, dispatch_duration=dispatch_duration, typeof=DeployType.AUCTION_BID_WITHDRAW )) - - -def verify(ctx: ExecutionContext): - """Step execution verifier. - - :param ctx: Execution context information. - - """ - verification.verify_deploy_count(ctx, 1)