Skip to content

Commit

Permalink
integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
dssei committed Jan 14, 2025
1 parent 31f0d8b commit 53217b2
Showing 1 changed file with 53 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# Tests for querying ct account via precompile. These tests depend on initialize_account_tests running and passing.
- name: Test querying confidential token account via precompile
inputs:
# Setup test account
- cmd: printf "12345678\n" | seid keys add ctquerytest
- cmd: printf "12345678\n" | seid keys show -a admin
env: ADMIN_ADDR
- cmd: printf "12345678\n" | seid keys show -a ctquerytest
env: TEST_ADDR
- cmd: printf "12345678\n" | seid tx bank send $ADMIN_ADDR $TEST_ADDR 100000000uatom -b block --fees 2000usei --chain-id sei -y --output json | jq -r ".code"
- cmd: printf "12345678\n" | seid tx bank send $ADMIN_ADDR $TEST_ADDR 1sei -b block --fees 2000usei --chain-id sei -y --output json | jq -r ".code"

# Initialize confidential token account for denom uatom for admin
- cmd: printf "12345678\n" | seid tx ct init-account uatom --from ctquerytest --fees 4000usei --chain-id sei -b block -y --output json | jq -r ".code"
env: INIT_ACCOUNT_CODE

# Deposit to the confidential token account
- cmd: printf "12345678\n" | seid tx ct deposit 500000uatom --from ctquerytest --fees 4000usei --chain-id sei -b block -y --output json | jq -r ".code"
env: DEPOSIT_CODE

# Query the account state
- cmd: printf "12345678\n" | seid q ct account uatom $TEST_ADDR --output json
env: ACCOUNT_STATE
- cmd: echo $ACCOUNT_STATE | jq -r ".pending_balance_credit_counter"
env: PENDING_BALANCE_COUNTER
- cmd: echo $ACCOUNT_STATE | jq -r ".decryptable_available_balance"
env: AVAILABLE_BALANCE_CIPHER

# Query the account to verify the new account state via precompile
- cmd: cast call 0x0000000000000000000000000000000000001010 "account(string,string)((bytes,bytes,bytes,uint32,bytes,string))" $TEST_ADDR uatom
env: ACCOUNT_STATE_PRECOMPILE
- cmd: echo $ACCOUNT_STATE_PRECOMPILE | jq -R -r "split(\", \")[3]"
env: PENDING_BALANCE_COUNTER_PRECOMPILE
- cmd: echo $ACCOUNT_STATE_PRECOMPILE| jq -R -r "split(\", \")[5]"| sed -e s/\"\)//g -e s/\"//
env: AVAILABLE_BALANCE_CIPHER_PRECOMPILE
verifiers:
# Verify that the account exists after the instruction is executed.
- type: eval
expr: INIT_ACCOUNT_CODE == 0 or INIT_ACCOUNT_CODE == 38

# Verify that the deposit was successful
- type: eval
expr: DEPOSIT_CODE == 0

# Verify that the pending balance counter is the same in both queries
- type: eval
expr: PENDING_BALANCE_COUNTER == PENDING_BALANCE_COUNTER_PRECOMPILE

# Verify that the available balance is the same in both queries
- type: eval
expr: AVAILABLE_BALANCE_CIPHER == AVAILABLE_BALANCE_CIPHER_PRECOMPILE


0 comments on commit 53217b2

Please sign in to comment.