Skip to content

Commit aab58d5

Browse files
committed
bytearray tests
1 parent c97d93f commit aab58d5

File tree

1 file changed

+22
-11
lines changed

1 file changed

+22
-11
lines changed

Test/Test/Ethereum/Abi.juvix

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ module TupleUsageExample;
2525
Eq-Example : Eq Example;
2626

2727
{-- 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;.
3131
--}
3232
instance
3333
ToBytes-Example : ToBytes Example :=
@@ -47,14 +47,14 @@ module TupleUsageExample;
4747
};
4848

4949
{-- 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`
5858

5959
For a concrete example, see the code below:
6060
--}
@@ -241,6 +241,16 @@ module List;
241241
];
242242
end;
243243

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+
244254
module UInt32;
245255
test : TestSuite := UIntN.test UInt32 "UInt32";
246256
end;
@@ -268,4 +278,5 @@ test : TestSuite :=
268278
Int256.test;
269279
Bool.test;
270280
List.test;
281+
ByteArray.test;
271282
];

0 commit comments

Comments
 (0)