Skip to content

Commit

Permalink
Merge branch 'master' into liorbond-patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
liorbond authored Mar 27, 2023
2 parents 00ef835 + 6553703 commit e66ced7
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions tests/integration.sh
Original file line number Diff line number Diff line change
Expand Up @@ -1651,6 +1651,58 @@ function test_send_from() {
assert_eq "$(get_allowance "$contract_addr" 'a' 'b')" 0
}

function measure_transfer_gas() {
set -e
local contract_addr="$1"

log_test_header

local tx_hash

# Deposit to "a"
quiet deposit "$contract_addr" 'a' 10

local b_balance=$(get_balance "$contract_addr" 'b')

local transfer_message='{"transfer":{"recipient":"'"${ADDRESS[b]}"'","amount":"5"}}'
local transfer_response
tx_hash="$(compute_execute "$contract_addr" "$transfer_message" ${FROM[a]} --gas 1500000)"
# Notice the `!` before the command - it is EXPECTED to fail.
! transfer_response="$(wait_for_compute_tx "$tx_hash" 'waiting for transfer from "a" to "b" to process')"
! transfer_response_not_compute="$(wait_for_tx "$tx_hash" 'waiting for transfer from "a" to "b" to process')"

assert_ne "$(get_balance "$contract_addr" 'b')" $b_balance

echo $transfer_response_not_compute
# echo "$(extract_gas "$transfer_response")"
}

function measure_transfer_with_decoys_gas() {
set -e
local contract_addr="$1"

log_test_header

local tx_hash

# Deposit to "a"
quiet deposit "$contract_addr" 'a' 10

local b_balance=$(get_balance "$contract_addr" 'b')

local transfer_message='{"transfer":{"recipient":"'"${ADDRESS[b]}"'","amount":"5", "entropy":"TXlQYXN3b3JkMTIz", "decoys":["secret1kmgdagt5efcz2kku0ak9ezfgntg29g2vr88q0e","secret18vd8fpwxzck93qlwghaj6arh4p7c5n8978vsyg","secret1qqq8g6cjht0qfemed6nmrgjp8gajhnw3panxcf","secret1qqg9z5473z4f842c9nddc2942mj82lw8h7n5uf","secret1qqjmkf275wwaeevkkmqdk5xw2j7k5u5c8j7e9y"]}}'
local transfer_response
tx_hash="$(compute_execute "$contract_addr" "$transfer_message" ${FROM[a]} --gas 1500000)"
# Notice the `!` before the command - it is EXPECTED to fail.
! transfer_response="$(wait_for_compute_tx "$tx_hash" 'waiting for transfer from "a" to "b" to process')"
! transfer_response_not_compute="$(wait_for_tx "$tx_hash" 'waiting for transfer from "a" to "b" to process')"

echo $transfer_response_not_compute
assert_ne "$(get_balance "$contract_addr" 'b')" $b_balance

# echo "$(extract_gas "$transfer_response")"
}

function main() {
log ' <####> Starting integration tests <####>'
log "secretcli version in the docker image is: $(secretcli version)"
Expand Down Expand Up @@ -1690,6 +1742,9 @@ function main() {
test_send_from "$contract_addr" register
test_send_from "$contract_addr" skip-register

measure_transfer_gas "$contract_addr"
measure_transfer_with_decoys_gas "$contract_addr"

log 'Tests completed successfully'

# If everything else worked, return successful status
Expand Down

0 comments on commit e66ced7

Please sign in to comment.