[More Detail] [Collapse All]
Feature: Constructor fails - no change in storagRoot
features/100-constructors/300-contruct-fails.feature
- Background: Create configuration with two source files
link
features/100-constructors/300-contruct-fails.feature:3
Given I create initial sbuilder context with:
Directory
solidity demo1
setup setup1
# Content of solidity 'demo1'
#
# Two contracts, where contract Demo2 constructor
# creates also Demo1 constructor.
And a file named "solidity/demo1.sol" with:
pragma solidity ^0.3.5;

contract Demo1 {

    function Demo1() {
       throw;
    }

}

contract Demo2 { 

      address demo1;

       function Demo2() {
          demo1 = new Demo1();
       }

}
# Content of setup 'setup1'
And a file named "cnf/setup1.yaml" with:
 - domain-extension:

     - domain: eth_address
       values:
          - acc1
          - acc2
          - acc3

       # Ethre value range, could be also int
     - domain: eth_value
       range: [0,7]




  #  Three steps:
  #  - step 1: create account 
  #  - step 2: mine 6 units ether
  #  - step 3: constract Demo2 contract, which fails
  #    because Demo1 throws expcetion

 - step-extension:
        - interface: personal_newAccount()
        - interface: geth_mine()
          bindExact: true
          input:
              _default: 1
              value: 6
        - interface: Demo2()
          bindExact: true
          input:
              _default: 0
              value: 1
              sender: 1
- Scenario: Constructor of called contract fails
link

In this scenario
- contract Demo2 call constructors of Demo1
- constructor Demo1 thrown an exception

Expect:
- Contract Demo2 to exist (with balance 1 transferred)
- Contract Demo1 NOT to exists
features/100-constructors/300-contruct-fails.feature:85
# State space extract:
#
# eth_accounts@2={ [address |-> "acc1", codeHash |-> Nil, balance |-> 6]}

# eth_accounts@3={ [address |-> "acc1", codeHash |-> Nil, balance |-> 5],
#                  [address |-> "acc2", codeHash |-> "Demo2", balance |-> 1] }
Given I generate, translate, and model check setup `setup1`
Then State space extract `gen/setup1/tla/state.dump` contains
Tick Variable Key Field Value
2 eth_accounts acc1 balance 6
3 step p_Demo2__
3 eth_accounts acc1 balance 5
3 eth_accounts acc2 balance 1
3 eth_accounts acc2 codeHash Demo2