[More Detail] [Collapse All]
Feature: Constructor fails - no change in storagRoot
features/100-contructors/300-contruct-fails.feature
- Background: Create configuration with two source files
link
features/100-contructors/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]

       # TODO: should be created automatically
     - domain: eth_code_hash
       values:
          - Demo1
          - Demo2




  #  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: Construct 'Demo1' which creates 'Demo2'
link
features/100-contructors/300-contruct-fails.feature:91
# Step 1: Account created, no gas used, nothing mined
#    eth_gasUsed@1=0
#    eth_mined@1=0
#    step@1="p_personal_newAccount__"
#    eth_accounts@1={[address |-> "acc1", codeHash |-> Nil, balance |-> 0]}
#    eth_storageRoot@1={}
# Step 2: Account created,  mined 6 units to 'acc1'
#    eth_gasUsed@2=0
#    eth_mined@2=-6
#    step@2="p_geth_mine__"
#    eth_accounts@2={[address |-> "acc1", codeHash |-> Nil, balance |-> 6]}
#    eth_storageRoot@2={}
# Step 3:
#    - Constructor Demo2 starts
#       -- 1 unit intrinsic gas used
#    - Contructor Demo1() fails
#       -- 1 unit intrinsic gas used to 
#       -- Demo1() will not be created
#    - Constructor Demo2() does not check status
#       -- Demo2() gets created
#       -- 1 unit transaction gas consumed
#
#  - State space extract from state 3:
#    step@3="p_Demo2__"
#    eth_gasUsed@3=3
#    eth_mined@3=-6
#    eth_accounts@3={ [address |-> "acc1", codeHash |-> Nil, balance |-> 2],
#                     [address |-> "acc2", codeHash |-> "Demo2", balance |-> 1] }
#    eth_storageRoot@3={}
#  Summary of balance changes:
#
#       Step     acc1 acc2 acc3 gasUsed  mined
#        1       0     -    -   0         0 
#        2       6              0        -6
#        3       2     1        3        -6 
Given I generate, translate, and model check setup `setup1`
Then State space extract `gen/setup1/tla/state.dump` contains
Tick Variable Field Value
1 step p_personal_newAccount__
1 eth_accounts address acc1
2 step p_geth_mine__
3 step p_Demo2__
2 eth_accounts balance 6
2 eth_gasUsed 0
3 eth_accounts balance 2
3 eth_accounts balance 1
3 eth_accounts address acc1
3 eth_accounts address acc2
3 eth_gasUsed 3
3 eth_mined -6