[More Detail] [Collapse All]
Feature: A contract constructors creates an other contract
features/100-constructors/200-contract-constructs.feature
- Background: Create configuration with two source files
link
features/100-constructors/200-contract-constructs.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.4.4;

contract Demo1 {

    uint storedData1;


    function set(uint x) {
        storedData1 = x;
    }

    function get() constant returns (uint retVal) {
        return storedData1;
    }

}

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]


     - domain: Demo1_storedData1
       values: 
           - store1_1
           - store1_2
           - store1_3


  #  Three steps:
  #  - step 1: create account 
  #  - step 2: mine 6 units ether
  #  - step 3: constract Demo2 contract (and "under the hood" 
  #    also Demo1 contract

 - 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

In this scenario:

- step 1: creates new account 'acc1'
- step 2: mines 6 units to beneficiary address 'acc1'
- step 3: account 'acc1' creates 'Demo2' (with address 'acc2')
          and 'acc2' further creates 'Demo1' with address 'acc3')


Expect:
features/100-constructors/200-contract-constructs.feature:97
Given I generate, translate, and model check setup `setup1`
Then State space extract `gen/setup1/tla/state.dump` contains
Tick Variable Key Field Value
1 step p_personal_newAccount__
2 step p_geth_mine__
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 acc3 balance 0
3 eth_accounts acc1 codeHash Nil
3 eth_accounts acc2 codeHash Demo2
3 eth_accounts acc3 codeHash Demo1