Skip to content

Commit

Permalink
Encode and decode contracts in tests (#166)
Browse files Browse the repository at this point in the history
* Encode and decode contracts in tests

* tmp
  • Loading branch information
virgil-serbanuta authored Oct 24, 2024
1 parent 236a8de commit 076c304
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 2 deletions.
2 changes: 2 additions & 0 deletions ukm-semantics/main/decoding.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
```k
requires "decoding/impl.md"
requires "decoding/syntax.md"
module UKM-DECODING
imports private UKM-DECODING-IMPL
endmodule
```
16 changes: 16 additions & 0 deletions ukm-semantics/main/decoding/impl.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
```k
module UKM-DECODING-IMPL
imports private COMMON-K-CELL
imports private UKM-DECODING-SYNTAX
imports private UKM-FULL-PREPROCESSED-CONFIGURATION
syntax UkmFullPreprocessedCell ::= decodeUkmFullPreprocessedCell(Bytes)
[function, hook(ULM.decode)]
rule
<k> ukmDecodePreprocessedCell(B:Bytes) => .K ... </k>
(_:UkmFullPreprocessedCell => decodeUkmFullPreprocessedCell(B))
endmodule
```
6 changes: 4 additions & 2 deletions ukm-semantics/main/encoding.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
```k
requires "encoding/syntax.md"
requires "encoding/encoder.md"
requires "encoding/impl.md"
requires "encoding/syntax.md"
module UKM-ENCODING
imports UKM-CALLDATA-ENCODER
imports private UKM-CALLDATA-ENCODER
imports private UKM-ENCODING-IMPL
endmodule
```
22 changes: 22 additions & 0 deletions ukm-semantics/main/encoding/impl.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
```k
module UKM-ENCODING-IMPL
imports private COMMON-K-CELL
imports private BYTES-SYNTAX
imports private UKM-ENCODING-SYNTAX
imports private UKM-FULL-PREPROCESSED-CONFIGURATION
syntax Bytes ::= encodeUkmFullPreprocessedCell(UkmFullPreprocessedCell)
[function, hook(ULM.encode)]
rule
<k>
ukmEncodePreprocessedCell
=> ukmEncodedPreprocessedCell(encodeUkmFullPreprocessedCell(Cell))
...
</k>
Cell:UkmFullPreprocessedCell
endmodule
```
1 change: 1 addition & 0 deletions ukm-semantics/main/encoding/syntax.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ module UKM-ENCODING-SYNTAX
imports RUST-REPRESENTATION
syntax UKMInstruction ::= "ukmEncodePreprocessedCell"
| ukmEncodedPreprocessedCell(Bytes)
syntax Bytes ::= encodeCallData (String, List, List) [function] //Function name, argument types, argument list
| encodeFunctionSignature (String, List) [function]
Expand Down

0 comments on commit 076c304

Please sign in to comment.