Skip to content

Commit

Permalink
versioning, travis badge, minor doc improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
AdrienChampion committed Mar 5, 2019
1 parent 2349aae commit d97e133
Show file tree
Hide file tree
Showing 14 changed files with 96 additions and 44 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Techelson
# Techelson [![Build Status](https://travis-ci.org/AdrienChampion/techelson.svg?branch=master)](https://travis-ci.org/AdrienChampion/techelson)

TEst miCHELSON: `techelson`
TEst miCHELSON: `techelson`.

A test execution engine for Michelson smart contracts.

Expand Down
6 changes: 3 additions & 3 deletions docs/index.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Techelson
# Techelson [![Build Status](https://travis-ci.org/AdrienChampion/techelson.svg?branch=master)](https://travis-ci.org/AdrienChampion/techelson)

TEst miCHELSON: `techelson`
TEst miCHELSON: `techelson`.

A test execution engine for Michelson smart contracts.

Expand Down Expand Up @@ -49,7 +49,7 @@ You can also run `make test` to make sure there is no problem with the Techelson
Assuming the binary Techelson is in you path, you can run it with

```bash
> techelson [ --contract <contract_file> <optional_init_file> ]* -- [ <testcase> ]*
> techelson [ --contract <contract_file> ]* -- [ <testcase> ]*
```

Argument `<contract_file>` is a michelson contract (`storage`, `parameter` and `code` fields). `<optional_init_file>` is an optional initializer for the contract. It should contain two fields : `parameter` and `code`. The former is the type of data the initializer takes as input, and the latter is a (sequence of) michelson instruction(s) which, from a stack with a value of type `parameter`, produces a stack with a value of the `storage` type appearing in the `<contract_file>` associated with the initializer.
Expand Down
3 changes: 2 additions & 1 deletion docs/user_doc/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,8 @@ <h1 class="menu-title">Techelson User Documentation</h1>
<a class="header" href="#techelson" id="techelson"><h1>Techelson</h1></a>
<p><strong><a href="https://ocamlpro.github.io/techelson" title="Techelson's homepage">Techelson</a></strong> is a <strong>T</strong>est <strong>E</strong>xecution <strong>E</strong>nvironment (TEE) for <a href="https://tezos.gitlab.io/master/whitedoc/michelson.html" title="Michelson documentation page">Michelson smart contracts</a>.
Michelson is the stack-based language used by the <a href="https://tezos.com" title="Tezos official page">tezos blockchain</a>. Techelson is open
source and <a href="https://github.com/OCamlPro/techelson" title="Techelson on github.com">hosted on github</a>, where you can find the build instructions.</p>
source and <a href="https://github.com/OCamlPro/techelson" title="Techelson on github.com">hosted on github</a>, where you can find the build instructions. If you just want to
retrieve a binary, head over to <a href="https://github.com/OCamlPro/techelson/releases" title="Techelson's release page">releases</a>.</p>
<p>Techelson emulates just enough of the tezos blockchain protocol to be able to create smart
contracts and make transfers between contracts. Currently, techelson only aims at testing
functional properties of smart contracts. In particular, it does not provide any information about
Expand Down
29 changes: 18 additions & 11 deletions docs/user_doc/print.html
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,8 @@ <h1 class="menu-title">Techelson User Documentation</h1>
<a class="header" href="#techelson" id="techelson"><h1>Techelson</h1></a>
<p><strong><a href="https://ocamlpro.github.io/techelson" title="Techelson's homepage">Techelson</a></strong> is a <strong>T</strong>est <strong>E</strong>xecution <strong>E</strong>nvironment (TEE) for <a href="https://tezos.gitlab.io/master/whitedoc/michelson.html" title="Michelson documentation page">Michelson smart contracts</a>.
Michelson is the stack-based language used by the <a href="https://tezos.com" title="Tezos official page">tezos blockchain</a>. Techelson is open
source and <a href="https://github.com/OCamlPro/techelson" title="Techelson on github.com">hosted on github</a>, where you can find the build instructions.</p>
source and <a href="https://github.com/OCamlPro/techelson" title="Techelson on github.com">hosted on github</a>, where you can find the build instructions. If you just want to
retrieve a binary, head over to <a href="https://github.com/OCamlPro/techelson/releases" title="Techelson's release page">releases</a>.</p>
<p>Techelson emulates just enough of the tezos blockchain protocol to be able to create smart
contracts and make transfers between contracts. Currently, techelson only aims at testing
functional properties of smart contracts. In particular, it does not provide any information about
Expand Down Expand Up @@ -2046,40 +2047,44 @@ <h1 class="menu-title">Techelson User Documentation</h1>
<li>
<p><code>STEP</code> and <code>STEP &lt;string&gt;</code>:</p>
<p><code>'S</code> <code>-&gt;</code> <code>'S</code></p>
<p>Relevant section of this book: <a href="quick_ref/../testing/basic.html" title="First Steps section">First Steps</a>.</p>
<p>Since <code>0.7.0</code>, relevant section of this book: <a href="quick_ref/../testing/basic.html" title="First Steps section">First Steps</a>.</p>
<p>suspends the evaluator and prints a string, if any.</p>
</li>
<li>
<p><code>PRINT_STACK</code>:</p>
<p><code>'S</code> <code>-&gt;</code> <code>'S</code></p>
<p>Relevant section of this book: <a href="quick_ref/../testing/basic.html" title="First Steps section">First Steps</a>.</p>
<p>Since <code>0.7.0</code>, relevant section of this book: <a href="quick_ref/../testing/basic.html" title="First Steps section">First Steps</a>.</p>
<p>prints the current state of the stack</p>
</li>
</ul>
<blockquote>
<p>Note that Techelson treats <code>#&gt;</code> as whitespaces. You can have <code>#&gt; STEP &quot;important step&quot; ;</code> in your
contracts which keeps them pure Michelson, but Techelson will stop when it reaches the <code>STEP</code>.</p>
</blockquote>
<a class="header" href="#testcase-only-extensions" id="testcase-only-extensions"><h2>Testcase-only Extensions</h2></a>
<p>The following instructions are <strong>only</strong> legal in testcases:</p>
<ul>
<li>
<p><code>CREATE_CONTRACT &lt;string&gt;</code>:</p>
<p><code>:: key_hash : option key_hash : bool : bool : mutez : 'g : 'S</code>
<code>-&gt;</code> <code>operation : address : 'S</code></p>
<p>Relevant section of this book: <a href="quick_ref/../testing/contracts.html" title="Creating and Calling Contracts section">Creating and Calling Contracts</a>.</p>
<p>Since <code>0.7.0</code>, relevant section of this book: <a href="quick_ref/../testing/contracts.html" title="Creating and Calling Contracts section">Creating and Calling Contracts</a>.</p>
<p>Creates an instance of the contract named after the string parameter. The type of the storage
of the contract must be <code>'g</code>.</p>
</li>
<li>
<p><code>SPAWN_CONTRACT 'g</code>:</p>
<p><code>:: string : key_hash : option key_hash : bool : bool : mutez : 'g : 'S</code>
<code>-&gt;</code> <code>operation : address : 'S</code></p>
<p>Relevant section of this book: <a href="quick_ref/../testing/contracts.html" title="Creating and Calling Contracts section">Creating and Calling Contracts</a>.</p>
<p>Since <code>0.7.0</code>, relevant section of this book: <a href="quick_ref/../testing/contracts.html" title="Creating and Calling Contracts section">Creating and Calling Contracts</a>.</p>
<p>Exactly the same as the <code>CREATE_CONTRACT</code> extension above but the name of the contract is
passed as a stack parameter, and the type of the storage is an explicit parameter of the
instruction.</p>
</li>
<li>
<p><code>APPLY_OPERATIONS</code>:</p>
<p><code>(list operation) : 'S</code> <code>-&gt;</code> <code>'S</code></p>
<p>Relevant section of this book: <a href="quick_ref/../testing/contracts.html" title="Creating and Calling Contracts section">Creating and Calling Contracts</a>.</p>
<p>Since <code>0.7.0</code>, relevant section of this book: <a href="quick_ref/../testing/contracts.html" title="Creating and Calling Contracts section">Creating and Calling Contracts</a>.</p>
<ul>
<li>consumes a list of operations</li>
<li>suspends the execution of the testcase</li>
Expand All @@ -2092,7 +2097,7 @@ <h1 class="menu-title">Techelson User Documentation</h1>
<p><code>GET_STORAGE 'storage</code>:</p>
<p><code>contract _ : 'S</code> <code>-&gt;</code> <code>(option 'storage) : 'S</code></p>
<p><code>address : 'S</code> <code>-&gt;</code> <code>(option 'storage) : 'S</code></p>
<p>Relevant section of this book: <a href="quick_ref/../testing/inspection.html" title="Live Contract Inspection section">Live Contract Inspection</a>.</p>
<p>Since <code>0.7.0</code>, relevant section of this book: <a href="quick_ref/../testing/inspection.html" title="Live Contract Inspection section">Live Contract Inspection</a>.</p>
<ul>
<li>consumes a contract</li>
<li>pushes <code>Some</code> of the current value of the storage of the contract if its storage has type
Expand All @@ -2103,13 +2108,13 @@ <h1 class="menu-title">Techelson User Documentation</h1>
<p><code>GET_BALANCE</code>:</p>
<p><code>contract _ : 'S</code> <code>-&gt;</code> <code>mutez : 'S</code></p>
<p><code>address : 'S</code> <code>-&gt;</code> <code>mutez : 'S</code></p>
<p>Relevant section of this book: <a href="quick_ref/../testing/inspection.html" title="Live Contract Inspection section">Live Contract Inspection</a>.</p>
<p>Since <code>0.7.0</code>, relevant section of this book: <a href="quick_ref/../testing/inspection.html" title="Live Contract Inspection section">Live Contract Inspection</a>.</p>
<p>Same as <code>GET_STORAGE</code>, but pushes the balance of the contract instead of its storage</p>
</li>
<li>
<p><code>MUST_FAIL 'a</code>:</p>
<p><code>(option 'a) : operation : 'S</code> <code>-&gt;</code> <code>'S</code></p>
<p>Relevant section of this book: <a href="quick_ref/../testing/failures.html" title="Testing for Failures section">Testing for Failures</a>.</p>
<p>Since <code>0.7.0</code>, relevant section of this book: <a href="quick_ref/../testing/failures.html" title="Testing for Failures section">Testing for Failures</a>.</p>
<p>Specifies that an operation (or the operation it creates recursively) must fail, and optionaly
that it <code>FAIL</code>ed<code>WITH</code> a certain value. More precisely, the whole testcase will <strong>fail</strong> if the
<code>operation</code> or the operations it creates recursively, <em>when applied</em>, either</p>
Expand All @@ -2128,15 +2133,15 @@ <h1 class="menu-title">Techelson User Documentation</h1>
<li>
<p><code>SET_SOURCE code</code>, with <code>code :: [ 'A -&gt; 'B ]</code></p>
<p><code>address :: 'A</code> <code>-&gt;</code> <code>'B</code></p>
<p>Relevant section of this book: <a href="quick_ref/../testing/set_source.html" title="Usurpation of Identity section">Usurpation of Identity</a>.</p>
<p>Since <code>0.7.0</code>, relevant section of this book: <a href="quick_ref/../testing/set_source.html" title="Usurpation of Identity section">Usurpation of Identity</a>.</p>
<p>Sets the source of the testcase. Without this extension, the source of all transfers can only
be the testcase. This allows to run <code>code</code> while pretending the testcase is a different live
contract.</p>
</li>
<li>
<p><code>SET_TIMESTAMP</code></p>
<p><code>timestamp :: 'S</code> <code>-&gt;</code> <code>'S</code></p>
<p>Relevant section of this book: <a href="quick_ref/../testing/time.html" title="Timestame Control section">Timestamp Control</a>.</p>
<p>Since <code>0.7.0</code>, relevant section of this book: <a href="quick_ref/../testing/time.html" title="Timestame Control section">Timestamp Control</a>.</p>
<p>Sets the timestamp of the next block to some value. The default timestamp is
<code>1970-01-01T00:00:00Z</code>.</p>
</li>
Expand All @@ -2148,6 +2153,8 @@ <h1 class="menu-title">Techelson User Documentation</h1>
</blockquote>
<p>The full list of options (for the nominal mode) is obtained with <code>--help</code>:</p>
<pre><code>$ techelson --help
techelson v0.7.0

USAGE:
../bin/techelson [OPTIONS] -- [FILES]*
../bin/techelson [OPTIONS] testgen [TESTGEN_OPTIONS] [-- DIR]?
Expand Down
24 changes: 14 additions & 10 deletions docs/user_doc/quick_ref/extensions.html
Original file line number Diff line number Diff line change
Expand Up @@ -167,40 +167,44 @@ <h1 class="menu-title">Techelson User Documentation</h1>
<li>
<p><code>STEP</code> and <code>STEP &lt;string&gt;</code>:</p>
<p><code>'S</code> <code>-&gt;</code> <code>'S</code></p>
<p>Relevant section of this book: <a href="../testing/basic.html" title="First Steps section">First Steps</a>.</p>
<p>Since <code>0.7.0</code>, relevant section of this book: <a href="../testing/basic.html" title="First Steps section">First Steps</a>.</p>
<p>suspends the evaluator and prints a string, if any.</p>
</li>
<li>
<p><code>PRINT_STACK</code>:</p>
<p><code>'S</code> <code>-&gt;</code> <code>'S</code></p>
<p>Relevant section of this book: <a href="../testing/basic.html" title="First Steps section">First Steps</a>.</p>
<p>Since <code>0.7.0</code>, relevant section of this book: <a href="../testing/basic.html" title="First Steps section">First Steps</a>.</p>
<p>prints the current state of the stack</p>
</li>
</ul>
<blockquote>
<p>Note that Techelson treats <code>#&gt;</code> as whitespaces. You can have <code>#&gt; STEP &quot;important step&quot; ;</code> in your
contracts which keeps them pure Michelson, but Techelson will stop when it reaches the <code>STEP</code>.</p>
</blockquote>
<a class="header" href="#testcase-only-extensions" id="testcase-only-extensions"><h2>Testcase-only Extensions</h2></a>
<p>The following instructions are <strong>only</strong> legal in testcases:</p>
<ul>
<li>
<p><code>CREATE_CONTRACT &lt;string&gt;</code>:</p>
<p><code>:: key_hash : option key_hash : bool : bool : mutez : 'g : 'S</code>
<code>-&gt;</code> <code>operation : address : 'S</code></p>
<p>Relevant section of this book: <a href="../testing/contracts.html" title="Creating and Calling Contracts section">Creating and Calling Contracts</a>.</p>
<p>Since <code>0.7.0</code>, relevant section of this book: <a href="../testing/contracts.html" title="Creating and Calling Contracts section">Creating and Calling Contracts</a>.</p>
<p>Creates an instance of the contract named after the string parameter. The type of the storage
of the contract must be <code>'g</code>.</p>
</li>
<li>
<p><code>SPAWN_CONTRACT 'g</code>:</p>
<p><code>:: string : key_hash : option key_hash : bool : bool : mutez : 'g : 'S</code>
<code>-&gt;</code> <code>operation : address : 'S</code></p>
<p>Relevant section of this book: <a href="../testing/contracts.html" title="Creating and Calling Contracts section">Creating and Calling Contracts</a>.</p>
<p>Since <code>0.7.0</code>, relevant section of this book: <a href="../testing/contracts.html" title="Creating and Calling Contracts section">Creating and Calling Contracts</a>.</p>
<p>Exactly the same as the <code>CREATE_CONTRACT</code> extension above but the name of the contract is
passed as a stack parameter, and the type of the storage is an explicit parameter of the
instruction.</p>
</li>
<li>
<p><code>APPLY_OPERATIONS</code>:</p>
<p><code>(list operation) : 'S</code> <code>-&gt;</code> <code>'S</code></p>
<p>Relevant section of this book: <a href="../testing/contracts.html" title="Creating and Calling Contracts section">Creating and Calling Contracts</a>.</p>
<p>Since <code>0.7.0</code>, relevant section of this book: <a href="../testing/contracts.html" title="Creating and Calling Contracts section">Creating and Calling Contracts</a>.</p>
<ul>
<li>consumes a list of operations</li>
<li>suspends the execution of the testcase</li>
Expand All @@ -213,7 +217,7 @@ <h1 class="menu-title">Techelson User Documentation</h1>
<p><code>GET_STORAGE 'storage</code>:</p>
<p><code>contract _ : 'S</code> <code>-&gt;</code> <code>(option 'storage) : 'S</code></p>
<p><code>address : 'S</code> <code>-&gt;</code> <code>(option 'storage) : 'S</code></p>
<p>Relevant section of this book: <a href="../testing/inspection.html" title="Live Contract Inspection section">Live Contract Inspection</a>.</p>
<p>Since <code>0.7.0</code>, relevant section of this book: <a href="../testing/inspection.html" title="Live Contract Inspection section">Live Contract Inspection</a>.</p>
<ul>
<li>consumes a contract</li>
<li>pushes <code>Some</code> of the current value of the storage of the contract if its storage has type
Expand All @@ -224,13 +228,13 @@ <h1 class="menu-title">Techelson User Documentation</h1>
<p><code>GET_BALANCE</code>:</p>
<p><code>contract _ : 'S</code> <code>-&gt;</code> <code>mutez : 'S</code></p>
<p><code>address : 'S</code> <code>-&gt;</code> <code>mutez : 'S</code></p>
<p>Relevant section of this book: <a href="../testing/inspection.html" title="Live Contract Inspection section">Live Contract Inspection</a>.</p>
<p>Since <code>0.7.0</code>, relevant section of this book: <a href="../testing/inspection.html" title="Live Contract Inspection section">Live Contract Inspection</a>.</p>
<p>Same as <code>GET_STORAGE</code>, but pushes the balance of the contract instead of its storage</p>
</li>
<li>
<p><code>MUST_FAIL 'a</code>:</p>
<p><code>(option 'a) : operation : 'S</code> <code>-&gt;</code> <code>'S</code></p>
<p>Relevant section of this book: <a href="../testing/failures.html" title="Testing for Failures section">Testing for Failures</a>.</p>
<p>Since <code>0.7.0</code>, relevant section of this book: <a href="../testing/failures.html" title="Testing for Failures section">Testing for Failures</a>.</p>
<p>Specifies that an operation (or the operation it creates recursively) must fail, and optionaly
that it <code>FAIL</code>ed<code>WITH</code> a certain value. More precisely, the whole testcase will <strong>fail</strong> if the
<code>operation</code> or the operations it creates recursively, <em>when applied</em>, either</p>
Expand All @@ -249,15 +253,15 @@ <h1 class="menu-title">Techelson User Documentation</h1>
<li>
<p><code>SET_SOURCE code</code>, with <code>code :: [ 'A -&gt; 'B ]</code></p>
<p><code>address :: 'A</code> <code>-&gt;</code> <code>'B</code></p>
<p>Relevant section of this book: <a href="../testing/set_source.html" title="Usurpation of Identity section">Usurpation of Identity</a>.</p>
<p>Since <code>0.7.0</code>, relevant section of this book: <a href="../testing/set_source.html" title="Usurpation of Identity section">Usurpation of Identity</a>.</p>
<p>Sets the source of the testcase. Without this extension, the source of all transfers can only
be the testcase. This allows to run <code>code</code> while pretending the testcase is a different live
contract.</p>
</li>
<li>
<p><code>SET_TIMESTAMP</code></p>
<p><code>timestamp :: 'S</code> <code>-&gt;</code> <code>'S</code></p>
<p>Relevant section of this book: <a href="../testing/time.html" title="Timestame Control section">Timestamp Control</a>.</p>
<p>Since <code>0.7.0</code>, relevant section of this book: <a href="../testing/time.html" title="Timestame Control section">Timestamp Control</a>.</p>
<p>Sets the timestamp of the next block to some value. The default timestamp is
<code>1970-01-01T00:00:00Z</code>.</p>
</li>
Expand Down
2 changes: 2 additions & 0 deletions docs/user_doc/quick_ref/usage.html
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ <h1 class="menu-title">Techelson User Documentation</h1>
</blockquote>
<p>The full list of options (for the nominal mode) is obtained with <code>--help</code>:</p>
<pre><code>$ techelson --help
techelson v0.7.0

USAGE:
../bin/techelson [OPTIONS] -- [FILES]*
../bin/techelson [OPTIONS] testgen [TESTGEN_OPTIONS] [-- DIR]?
Expand Down
2 changes: 1 addition & 1 deletion docs/user_doc/searchindex.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/user_doc/searchindex.json

Large diffs are not rendered by default.

15 changes: 15 additions & 0 deletions src/1_base/common.ml
Original file line number Diff line number Diff line change
Expand Up @@ -442,4 +442,19 @@ module Rng = struct
let rand = Random.int 101 in
Proba.Test.add_transfer >= rand
end
end

module Version = struct
type t = int * int * int

let current : t = 0, 7, 0

let fmt (fmt : formatter) (v_1, v_2, v_3 : t) : unit =
fprintf fmt "%i.%i.%i" v_1 v_2 v_3

let cmp (v_1, v_2, v_3 : t) (t_1, t_2, t_3 : t) : int =
match compare v_1 t_1, compare v_2 t_2, compare v_3 t_3 with
| 0, 0, res -> res
| 0, res, _ -> res
| res, _, _ -> res
end
14 changes: 14 additions & 0 deletions src/1_base/common.mli
Original file line number Diff line number Diff line change
Expand Up @@ -304,3 +304,17 @@ module Rng : sig
val transfer : unit -> bool
end
end

module Version : sig
(** Version, from major to minor. *)
type t = int * int * int

(** Current version, from major to minor. *)
val current : t

(** Version formatter. *)
val fmt : formatter -> t -> unit

(** Version comparison. *)
val cmp : t -> t -> int
end
Loading

0 comments on commit d97e133

Please sign in to comment.