Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

E2E Testing: Actions (Timing, Budget, Transfer) #14

Open
42 tasks
TrevorJTClarke opened this issue Jan 26, 2022 · 0 comments
Open
42 tasks

E2E Testing: Actions (Timing, Budget, Transfer) #14

TrevorJTClarke opened this issue Jan 26, 2022 · 0 comments

Comments

@TrevorJTClarke
Copy link
Member

TrevorJTClarke commented Jan 26, 2022

Unit Tests

Workspace Tests

  • Add tests here: https://github.com/Cron-Near/treasury/tree/main/e2e/src in a new file actions.rs
  • Test Flow: Approve Actions
    • call add_allowed_actions
    • view get_action_label validate has the right actions
    • call remove_allowed_action
    • view get_action_labelvalidate has removed the right actions
  • Test Flow: Single Action (& Manual call)
    • call create_actions for a simple Near transfer, using timeout setting (1min in the future)
    • validate near balance is unchanged on the receiver account
    • ...wait appropriate time...
    • call call_timeout_actions
    • validate near balance is changed correctly on the receiver account
  • Test Flow: Cadence Action
    • call create_actions for a near amount budget, using cadence setting (1min in the future)
    • validate near balance is unchanged on the receiver account
    • ...wait appropriate time...
    • call call_cadence_action
    • validate near balance is changed correctly on the receiver account
  • Test Flow: Timeout Actions
    • call create_actions for a simple Near transfer, a budget of NEAR, a budget of Fungible token, and budget of near account balance percent, using timeout setting (1min in the future)
    • validate near balance is unchanged on the receiver account
    • validate FT balance is unchanged on the receiver account
    • ...wait appropriate time...
    • call call_timeout_actions
    • validate near balance is changed correctly on the receiver account
    • validate FT balance is changed correctly on the receiver account
  • Test Flow: CRUD Actions
    • call add_allowed_actions
    • call create_actions for a simple Near transfer, using timeout setting (1min in the future)
    • view get_actions
    • view has_timeout_actions
    • view remove_actions
    • call remove_allowed_action

Examples:

# add/remove permissions
near call $TREASURY_ACCOUNT_ID add_allowed_actions '{"actions": [{ "Transfer": { "token_id": "wrap.near", "receiver_id": "you.near", "amount": "100000000000000000000000000", "msg": "" }}]}' --accountId $TREASURY_ACCOUNT_ID
near call $TREASURY_ACCOUNT_ID add_allowed_actions '{"actions": [{ "Budget": { "token_id": "wrap.near", "receiver_id": "you.near", "amount": "100000000000000000000000000", "msg": "" }}]}' --accountId $TREASURY_ACCOUNT_ID
near call $TREASURY_ACCOUNT_ID remove_allowed_action '{"actions": [{ "token_id": "wrap.near", "receiver_id": "you.near", "amount": "100000000000000000000000000", "msg": "" }]}' --accountId $TREASURY_ACCOUNT_ID
near view $TREASURY_ACCOUNT_ID get_approved_action_types
near view $TREASURY_ACCOUNT_ID is_allowed_action '{ "token_id": "wrap.near", "receiver_id": "you.near", "amount": "100000000000000000000000000", "msg": "" }' --accountId $TREASURY_ACCOUNT_ID

# create actions
EPOCH=$(date +"%s")
ACTION_TIMEOUT_1min=$((($EPOCH * 1000 + 60000) * 1000000))
near call $TREASURY_ACCOUNT_ID create_actions '{"actions": [{"priority": 1, "timeout": "'$ACTION_TIMEOUT_1min'", "payload": { "Transfer": { "token_id": "wrap.testnet", "receiver_id": "you.testnet", "amount": "1000000000000000000000000", "msg": "transfer wrapped near"}}}]}' --accountId $TREASURY_ACCOUNT_ID --gas $MAX_GAS

# See everthing thats scheduled
#TBD

# Remove Actions
#TBD

# call cadence
near call $TREASURY_ACCOUNT_ID call_cadence_action '{"cadence": "0 3 * * * *"}' --accountId $CRONCAT_MANAGER_ID --gas $MAX_GAS

# call timeout
near call $TREASURY_ACCOUNT_ID call_timeout_actions --accountId $TREASURY_ACCOUNT_ID --gas $MAX_GAS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant