-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #32 from freespek/th/launch-apalache
Launch Apalache on monitor files
- Loading branch information
Showing
8 changed files
with
302 additions
and
8 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
(* | ||
* This specification ensures that the Timelock methods properly | ||
* handle initialization. | ||
*) | ||
---- MODULE timelock_mon1 ---- | ||
VARIABLES | ||
\* @type: Bool; | ||
is_initialized, | ||
\* @type: Str; | ||
last_error | ||
|
||
Deposit(env, from, token, amount, claimants, time_bound) == | ||
\/ /\ ~is_initialized | ||
/\ is_initialized' = TRUE | ||
/\ last_error' = "" | ||
\/ /\ is_initialized | ||
/\ UNCHANGED is_initialized | ||
/\ last_error' = "contract has been already initialized" | ||
|
||
Claim(env, claimant) == | ||
\/ /\ ~is_initialized | ||
/\ UNCHANGED is_initialized | ||
(* the contract simply panics instead of reporting a nice error *) | ||
/\ last_error' = "contract is not initialized" | ||
\/ /\ is_initialized | ||
/\ UNCHANGED is_initialized | ||
/\ last_error' \in { | ||
"", | ||
"time predicate is not fulfilled", | ||
"claimant is not allowed to claim this balance" | ||
} | ||
(* the below behavior is not present in the contract *) | ||
\/ /\ is_initialized | ||
/\ is_initialized' = FALSE | ||
/\ last_error' = "" | ||
|
||
============================= |
14 changes: 14 additions & 0 deletions
14
solarkraft/test/e2e/tla/timelock_mon1_instrumented_fail.tla
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
---- MODULE timelock_mon1_instrumented_fail ---- | ||
EXTENDS timelock_mon1 | ||
|
||
Init == | ||
(* is_initialized is initialized from the current ledger state *) | ||
/\ is_initialized = FALSE | ||
/\ last_error = "" | ||
|
||
Next == | ||
(* the contract method being called along with its parameters *) | ||
/\ Claim([ timestamp |-> 100 ], "alice") | ||
(* the error message as produced by the contract invocation *) | ||
/\ last_error' = "transaction simulation failed: host invocation failed" | ||
=========================================== |
14 changes: 14 additions & 0 deletions
14
solarkraft/test/e2e/tla/timelock_mon1_instrumented_okay.tla
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
---- MODULE timelock_mon1_instrumented_okay ---- | ||
EXTENDS timelock_mon1 | ||
|
||
Init == | ||
(* is_initialized is initialized from the current ledger state *) | ||
/\ is_initialized = FALSE | ||
/\ last_error = "" | ||
|
||
Next == | ||
(* the contract method being called along with its parameters *) | ||
/\ Claim([ timestamp |-> 100 ], "alice") | ||
(* the error message as produced by the contract invocation *) | ||
/\ last_error' = "contract is not initialized" | ||
=========================================== |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Integration tests for the `verify` command | ||
|
||
import { describe, it } from 'mocha' | ||
|
||
import { spawn } from 'nexpect' | ||
|
||
describe('verify', () => { | ||
it('fails on missing file', function (done) { | ||
spawn('solarkraft verify --txHash mimimi --monitor doesnotexist') | ||
.wait('The monitor file doesnotexist does not exist.') | ||
.expect('[Error]') | ||
.run(done) | ||
}) | ||
|
||
it('reports success on okay monitor', function (done) { | ||
this.timeout(50000) | ||
spawn( | ||
'solarkraft verify --txHash mimimi --monitor test/e2e/tla/timelock_mon1_instrumented_okay.tla' | ||
) | ||
.wait('[OK]') | ||
.run(done) | ||
}) | ||
|
||
it('reports failure on deadlocking monitor', function (done) { | ||
this.timeout(50000) | ||
spawn( | ||
'solarkraft verify --txHash mimimi --monitor test/e2e/tla/timelock_mon1_instrumented_fail.tla' | ||
) | ||
.wait('Monitor is unable to reproduce the transaction') | ||
.expect('[Fail]') | ||
.run(done) | ||
}) | ||
}) |