Tests: add a Michelson guestbook test contract

This commit is contained in:
Pierre Chambart 2018-06-30 17:40:52 +02:00 committed by Benjamin Canou
parent c3c4e3d5a8
commit 8581264d11
3 changed files with 22 additions and 1 deletions

View File

@ -0,0 +1,10 @@
parameter string;
storage (map address (option string));
code { UNPAIR @message @guestbook; SWAP;
DUP; SENDER; GET @previous_message;
ASSERT_SOME;
ASSERT_NONE;
SWAP; SOME; SOME; SENDER; UPDATE;
NIL operation;
PAIR }

View File

@ -488,6 +488,17 @@ assert_storage $contract_dir/hash_consistency_checker.tz '0x00' \
assert_storage $contract_dir/hash_consistency_checker.tz '0x00' \
'(Pair 22220000000 (Pair "2017-12-13T04:49:00+00:00" 34))' "$hash_result"
# Test goldenbook
init_with_transfer $contract_dir/guestbook.tz $key1\
'{ Elt "tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx" None }' \
100 bootstrap1
assert_fails $client transfer 0 from bootstrap2 to guestbook -arg '"Pas moi"'
bake_after $client transfer 0 from bootstrap1 to guestbook -arg '"Coucou"'
assert_storage_contains guestbook '{ Elt "tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx" (Some "Coucou") }'
assert_fails $client transfer 0 from bootstrap3 to guestbook -arg '"Pas moi non plus"'
assert_fails $client transfer 0 from bootstrap1 to guestbook -arg '"Recoucou ?"'
# Test for big maps
init_with_transfer $contract_dir/big_map_mem.tz $key1\
'(Pair { Elt 1 Unit ; Elt 2 Unit ; Elt 3 Unit } Unit)' \

View File

@ -177,7 +177,7 @@ contract_storage () {
assert_storage_contains () {
local CONTRACT_NAME="$1"
local EXPECTED_STORAGE="$2"
contract_storage ${CONTRACT_NAME} | assert_in_output ${EXPECTED_STORAGE}
contract_storage ${CONTRACT_NAME} | assert_in_output "${EXPECTED_STORAGE}"
}
assert() {