Skip to content

Commit

Permalink
1. Auction withdraw bid updated.
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark A. Greenslade committed Mar 3, 2021
1 parent 2bb4e17 commit ce45e15
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 26 deletions.
2 changes: 1 addition & 1 deletion stests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
2 changes: 1 addition & 1 deletion stests/chain/set_auction_bid_submit.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
Expand Down
19 changes: 14 additions & 5 deletions stests/chain/set_auction_bid_withdraw.py
Original file line number Diff line number Diff line change
@@ -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


Expand All @@ -13,25 +14,33 @@


@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,
_CONTRACT_FNAME,
[
"--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
3 changes: 0 additions & 3 deletions stests/generators/wg_200/p1s1_submit_bid.py
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
19 changes: 3 additions & 16 deletions stests/generators/wg_201/p1s1_withdraw_bid.py
Original file line number Diff line number Diff line change
@@ -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"

Expand All @@ -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,
Expand All @@ -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)

0 comments on commit ce45e15

Please sign in to comment.