Skip to content

Commit

Permalink
Encode and decode contracts in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
virgil-serbanuta committed Oct 24, 2024
1 parent 236a8de commit 86104b3
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 1 deletion.
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
```
3 changes: 2 additions & 1 deletion ukm-semantics/main/encoding.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ requires "encoding/syntax.md"
requires "encoding/encoder.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 86104b3

Please sign in to comment.