[More Detail] [Collapse All]
Feature: Solidity methods
features/010-solidity/210-call-func-on-func.feature
- Background: Define contract with methods
link
features/010-solidity/210-call-func-on-func.feature:4
Given I create initial sbuilder context with:
Directory
solidity Demo1
setup setup1
And a file named "solidity/Demo1.sol" with:
contract Demo1 {
     uint storedData1;


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

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

  //  Demo2 constructor creates also Demo1 constructor.

  contract Demo2 { 

     Demo1 demo1;

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

      function setInDemo1() {
           demo1.set.value(3)( 87 );
      }

  }
- Scenario: Call function on value to pass value
link


                Balances        acc3.storedData1
step         acc1 acc2 acc3 
step 1        -     -   -           - 
step 2        6     -   -           - 
step 3        2     4   0           0
step 4        2     1   3           87
features/010-solidity/210-call-func-on-func.feature:47
Given 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



 - step-extension:
         

         # step 1 & 2: create acc1 with balance 6             

        - interface: personal_newAccount()
        - interface: geth_mine()
          bindExact: true
          input:
              _default: 1
              value: 6

        # step 3: create contract acc2 with 4 units

        - interface: Demo2()
          bindExact: true
          input:
              _default: 0
              value: 4
              sender: 1

        # step 4: call setInDemo1, which uses
        # demo1.set.value(2)( 3 ) to pass 3 units
        # demo1 contract (account acc3)

        - interface: Demo2(setInDemo1)
          bindExact: true
          input:
              _default: 0
              value: 0
              recipient: 2
              sender: 1
When 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 eth_accounts acc1 balance 2
3 eth_accounts acc2 balance 4
3 eth_accounts acc3 balance 0
3 eth_accounts acc1 balance 2
3 eth_accounts acc2 balance 1
3 eth_accounts acc3 balance 3
Then State space extract `gen/setup1/tla/state.dump` contains
Tick Variable Key Field Value
3 eth_storageRoot acc3 storedData1 0
4 eth_storageRoot acc3 storedData1 87