Alpha: Fix CREATE_CONTRACT spends twice

This commit is contained in:
Alain Mebsout 2018-07-13 14:26:28 +02:00 committed by Benjamin Canou
parent 7d58552bd5
commit a36f42506a
2 changed files with 11 additions and 3 deletions

View File

@ -412,12 +412,19 @@ assert_fails $client transfer 0 from bootstrap1 to replay
# Tests create_account # Tests create_account
init_with_transfer $contract_dir/create_account.tz $key2 None 1,000 bootstrap1 init_with_transfer $contract_dir/create_account.tz $key2 None 1,000 bootstrap1
$client transfer 100 from bootstrap1 to create_account \ assert_balance create_account "1000 ꜩ"
-arg '(Left "tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx")' | assert_in_output "New contract" created_account=\
`$client transfer 100 from bootstrap1 to create_account -arg '(Left "tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx")' \
| grep 'New contract' \
| sed -E 's/.*(KT1[a-zA-Z0-9]+).*/\1/' \
| head -1`
bake bake
assert_balance $created_account "100 ꜩ"
assert_balance create_account "1000 ꜩ"
# Creates a contract, transfers data to it and stores the data # Creates a contract, transfers data to it and stores the data
init_with_transfer $contract_dir/create_contract.tz $key2 Unit 1,000 bootstrap1 init_with_transfer $contract_dir/create_contract.tz $key2 Unit 1,000 bootstrap1
assert_balance create_contract "1000 ꜩ"
created_contract=\ created_contract=\
`$client transfer 0 from bootstrap1 to create_contract -arg '(Left "tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx")' \ `$client transfer 0 from bootstrap1 to create_contract -arg '(Left "tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx")' \
| grep 'New contract' \ | grep 'New contract' \
@ -425,6 +432,8 @@ created_contract=\
| head -1` | head -1`
bake bake
assert_storage_contains $created_contract '"abcdefg"' assert_storage_contains $created_contract '"abcdefg"'
assert_balance $created_contract "100 ꜩ"
assert_balance create_contract "900 ꜩ"
# Test IMPLICIT_ACCOUNT # Test IMPLICIT_ACCOUNT
init_with_transfer $contract_dir/default_account.tz $key1 \ init_with_transfer $contract_dir/default_account.tz $key1 \

View File

@ -725,7 +725,6 @@ let rec interp
Prim (0, K_code, [ Micheline.root code ], []) ])) in Prim (0, K_code, [ Micheline.root code ], []) ])) in
unparse_data ctxt Optimized storage_type init >>=? fun (storage, ctxt) -> unparse_data ctxt Optimized storage_type init >>=? fun (storage, ctxt) ->
let storage = Micheline.strip_locations storage in let storage = Micheline.strip_locations storage in
Contract.spend_from_script ctxt self credit >>=? fun ctxt ->
Contract.fresh_contract_from_current_nonce ctxt >>=? fun (ctxt, contract) -> Contract.fresh_contract_from_current_nonce ctxt >>=? fun (ctxt, contract) ->
let operation = let operation =
Origination Origination