`newAddress` reuses keys from smart contracts
Description
newAddress "some-alias"
is meant to reuse an existing account if the alias "some-alias" already exists.
However, it also reuses keys even if the existing some-alias
is a contract, and not an implicit account.
For example, if your test suite contains two tests:
- The first test creates a smart contract with the alias "test"
- The second test uses
newAddress "test"
- The second test transfers tez from
test
to some other account - The second test will fail, because
test
is actually a smart contract, and tez cannot be transferred from a smart contract.
Steps to reproduce
Here's a simpler repro that should be used to create a regression test:
_ <- originateSimple @() @() "abcdefgh" () idContract
addr <- newAddress "abcdefgh"
target <- newAddress "target"
withSender addr $ transferMoney target 0.1_e6
Expected behaviour
Expected test to pass.
Actual behaviour
The test fails:
20 ┃ addr <- newAddress "abcdefgh"
21 ┃
22 ┃ target <- newAddress "target"
23 ┃ withSender addr $ transferMoney target 0.1_e6
┃ ^^^^^^^^^^^^^^^^^^^^^^^^^^^
┃ | Contracts (abcdefgh) cannot be revealed
If we comment out the originateSimple
and run tezos-client forget contract test
, then the test will pass.
Environment
- master 2422a598