<
 
 
 
 
×
>
hide You are viewing an archived web page, collected at the request of Ethereum Foundation using Archive-It. This page was captured on 09:02:13 Jun 23, 2021 , and is part of the Community collection. The information on this web page may be out of date. See All versions of this archived page. Loading media information

Ethereum CLL Contract Simulator

mids106mids106 Member Posts: 188 ✭✭✭
I have created a simulator of the Ethereum C-Like Language Contracts. The intention of this simulator is to help contract coders develop and test their work using test driven best practises and in full isolation, without the need to connect to the Ethereum Test Net.

Contracts from the whitepaper are slightly modified to make them Python syntax compatible and contained within a Contract class. Automated testing scenarios are also written in a Simulator DSL (similar to unit tests) which can run, inspect and verify the outcome of contract runs.

Source Code:
https://github.com/jorisbontje/cll-sim

Let me know what you think!
Joris Bontje / @mids106 / mids on IRC #ethereum


Example Run:
./run.py examples/subcurrency.py
This will execute several simulation scenarios on the Sub-Currency example from the Ethereum whitepaper.

Example Output
sim          INFO    RUN test_insufficient_fee: 
sim WARNING Stopped: Insufficient basefee
sim INFO --------------------
sim INFO RUN test_creation:
sim DEBUG Accessing storage 1000
subcurrency INFO Initializing storage for creator alice
sim DEBUG Setting storage alice to 1000000000000000000
sim DEBUG Setting storage 1000 to 1
sim INFO --------------------
sim INFO RUN test_alice_to_bob:
sim DEBUG Accessing storage 1000
sim DEBUG Accessing storage alice
subcurrency INFO Transfering 1000 from alice to bob
sim DEBUG Accessing storage alice
sim DEBUG Setting storage alice to 999999999999999000
sim DEBUG Accessing storage bob
sim DEBUG Setting storage bob to 1000
sim INFO --------------------
sim INFO RUN test_bob_to_charlie_invalid:
sim DEBUG Accessing storage 1000
sim DEBUG Accessing storage bob
sim DEBUG Accessing storage bob
sim WARNING Stopped: Insufficient funds, bob has 1000 needs 1001
sim INFO --------------------
sim INFO RUN test_bob_to_charlie_valid:
sim DEBUG Accessing storage 1000
sim DEBUG Accessing storage bob
subcurrency INFO Transfering 1000 from bob to charlie
sim DEBUG Accessing storage bob
sim DEBUG Setting storage bob to 0
sim DEBUG Accessing storage charlie
sim DEBUG Setting storage charlie to 1000
sim INFO --------------------
subcurrency INFO , {1000: 1, 'charlie': 1000, 'bob': 0, 'alice': 999999999999999000})>

Comments

Sign In or Register to comment.