Skip to content

Instantly share code, notes, and snippets.

@trevorbernard
Last active May 10, 2023 16:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save trevorbernard/800c7e84cb63adf31c888a6ec1a270d5 to your computer and use it in GitHub Desktop.
Save trevorbernard/800c7e84cb63adf31c888a6ec1a270d5 to your computer and use it in GitHub Desktop.
Testing steps for UAT01 OCV

Mina User Acceptance Testing

UAT01 - Delegate vote override

An account holder that delegates their stake can override the vote of their delegate.

The follow defines some convenience methods to execute the testing sceneario.

export MINA_PRIVKEY_PASS='naughty blue worm'

MINA_EXE=mina
MINA_UAT_FOLDER=${HOME}/.mina-uat
REST_SERVER=3085

generate_keypair() {
  ${MINA_EXE} advanced generate-keypair -privkey-path ${1}
}

delegate() {
  ${MINA_EXE} client delegate-stake -rest-server ${REST_SERVER} -memo DELEGATING -sender ${1} -receiver ${2} 
}

vote_for() {
  ${MINA_EXE} client send-payment -rest-server ${REST_SERVER} -receiver ${1} -sender ${1} -memo ${2}
}

vote_against() {
  ${MINA_EXE} client send-payment -rest-server ${REST_SERVER} -receiver ${1} -sender ${1} -memo "no ${2}"
}

send_payment() {
  ${MINA_EXE} client send-payment -rest-server ${REST_SERVER} -receiver ${1} -sender ${2}
}

Step 1 - Setup

Create a BP keypair along with a user account so that we may delegate the user’s stake to the BP.

  1. Fund the BP key with 100 + fees
  2. Fund the user account with 100 + fees
# Change to correct fauct
FAUCET_PUB=B62qrA5JuNaYD8LpuHwYEttTxjanCVoLiZqJhRruTgEFonYhrSkTCS9

generate-keypair ${MINA_UAT_FOLDER}/uat01_keys/user01
generate-keypair ${MINA_UAT_FOLDER}/uat01_keys/bp01

USER_KEY_FILE=${MINA_UAT_FOLDER}/uat01_keys/user01
USER_PUB_KEY=$(cat "${MINA_UAT_FOLDER}/uat01_keys/user01.pub")
# import and unlock user account
${MINA_EXE} account import -rest-server ${REST_SERVER} -privkey-path ${USER_KEY_FILE}
${MINA_EXE} account unlock -rest-server ${REST_SERVER} -public-key ${USER_PUB_KEY}

BP_KEY_FILE=${MINA_UAT_FOLDER}/uat01_keys/bp01
BP_PUB_KEY=$(cat "${MINA_UAT_FOLDER}/uat01_keys/bp01.pub")
# import and unlock bp account
${MINA_EXE} account import -rest-server ${REST_SERVER} -privkey-path ${BP_KEY_FILE}
${MINA_EXE} account unlock -rest-server ${REST_SERVER} -public-key ${BP_PUB_KEY}

#Fund BP and User
${MINA_EXE} client send-payment -rest-server ${REST_SERVER} -receiver ${BP_PUB_KEY} -sender ${FAUCET_PUB} -amount 101.25
${MINA_EXE} client send-payment -rest-server ${REST_SERVER} -receiver ${USER_PUB_KEY} -sender ${FAUCET_PUB} -amount 101.25

Expected Results

User account: 100 tokens BP account: 100 tokens

Step 2 - Delegate the User’s stake to the BP

Delegate the user’s stake to the BP and keep track of which epoch the delegate transaction makes it into a block.

You can see which epoch you are on by issueing the mina client status command.

# Delegate staking weight to BP
${MINA_EXE} client delegate-stake -rest-server ${REST_SERVER} -receiver ${BP_PUB_KEY=$} -sender ${USER_PUB_KEY} -memo "uat01 delegation"

You will need to wait at 2 epochs before the delgation will have made it into the staking ledger.

Verify the delegation takes place and is in the appropriate staking ledger.

MINA_PORT=8301
# Wait two epochs since you issued the delegation
${MINA_EXE} ledger export staking-epoch-ledger -daemon-port ${MINA_PORT} |  jq ".[] | select(.delegate==\"${BP_PUB_KEY}\" or .pk==\"${BP_PUB_KEY}\")"

Step 3 - Delegate votes for and user votes against

Now that the user has staked their delgation and it’s in the ledger issue votes

BP Votes for MIP

MEMO=UAT01
vote_for ${BP_PUB_KEY} "${MEMO}"
# Wait until the the transaction is in a block. Typically < 3 mins

User overrides delegate by voting against

vote_against ${USER_PUB_KEY} "${MEMO}"
# Wait until the the transaction is in a block. Typically < 3 mins

Step 4 - Verify the vote in progress

  • Delegate’s (BP) vote should appear in the dashboard
  • User’s vote should appear in the dashboard
  • Total number of votes should increase by 2

Step 5 - Wait 2 epoch for the vote to be finalized

Administrator should assign the correct ledger-hash to the voting proposal so voting results may be aggregated.

  • Voting results for delegate are weighted based on their account balance and will not include the balance delegated to them from account holder
  • Voting results for the account holder are weighted based on their account balance
@jstavh
Copy link

jstavh commented May 10, 2023

🙌🚀:kermit-arms-flail:

@jstavh
Copy link

jstavh commented May 10, 2023

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment