@@ -25,9 +25,9 @@ module TupleUsageExample;
25
25
Eq-Example : Eq Example;
26
26
27
27
{-- To define the ;ToBytes; instance we must create an ;EvmTuple; with the fields
28
- of the record given in order. Then we use the ;ToBytes; instance of the ;EvmTuple;
29
- as shown below.
30
- Note that each of the fields must be an instance of ;ToBytes; and ;HasEvmSize;.
28
+ of the record given in order. Then we use the ;ToBytes; instance of the ;EvmTuple;
29
+ as shown below.
30
+ Note that each of the fields must be an instance of ;ToBytes; and ;HasEvmSize;.
31
31
--}
32
32
instance
33
33
ToBytes-Example : ToBytes Example :=
@@ -47,14 +47,14 @@ module TupleUsageExample;
47
47
};
48
48
49
49
{-- To define the ;FromBytes; instance we must follow these steps:
50
- 1. call `l <- tupleSplit sizes`, where `sizes` is a list of the ;EvmSize; of
51
- the type of each field.
52
- 2. case on `l`. `l` will exactly `n` elements, where `n` is the number
53
- of fields with a type `T` such that `evmSize T` is ;EvmSize.static;
54
- 3. For each element `s` of `l`, we call:
55
- `fieldName <- BytesConsumer.local FromBytes.fromBytes s`
56
- 4. Then, for each field `f` with a dynamic ;EvmSize;, we call:
57
- `f <- FromBytes.fromBytes`
50
+ 1. call `l <- tupleSplit sizes`, where `sizes` is a list of the ;EvmSize; of
51
+ the type of each field.
52
+ 2. case on `l`. `l` will exactly `n` elements, where `n` is the number
53
+ of fields with a type `T` such that `evmSize T` is ;EvmSize.static;
54
+ 3. For each element `s` of `l`, we call:
55
+ `fieldName <- BytesConsumer.local FromBytes.fromBytes s`
56
+ 4. Then, for each field `f` with a dynamic ;EvmSize;, we call:
57
+ `f <- FromBytes.fromBytes`
58
58
59
59
For a concrete example, see the code below:
60
60
--}
@@ -241,6 +241,16 @@ module List;
241
241
];
242
242
end;
243
243
244
+ module ByteArray;
245
+ test : TestSuite :=
246
+ TestSuite.group
247
+ "Dynamic ByteArray"
248
+ [
249
+ testCase "[]" (assertRoundTrip (ByteArray.fromList []));
250
+ testCase "[1;2;3]" (assertRoundTrip (ByteArray.fromList [1; 2; 3]));
251
+ ];
252
+ end;
253
+
244
254
module UInt32;
245
255
test : TestSuite := UIntN.test UInt32 "UInt32";
246
256
end;
@@ -268,4 +278,5 @@ test : TestSuite :=
268
278
Int256.test;
269
279
Bool.test;
270
280
List.test;
281
+ ByteArray.test;
271
282
];
0 commit comments