Commit 01b0a9ff authored by Maurelian's avatar Maurelian

ctb: Fix RLP test function names

parent 30c02c32
......@@ -6,55 +6,55 @@ import { CommonTest } from "./CommonTest.t.sol";
import { stdError } from "forge-std/Test.sol";
contract RLPReader_Test is CommonTest {
function test_readBytes_bytestring00() external {
function test_readBytes_bytestring00_succeeds() external {
assertEq(RLPReader.readBytes(hex"00"), hex"00");
}
function test_readBytes_bytestring01() external {
function test_readBytes_bytestring01_succeeds() external {
assertEq(RLPReader.readBytes(hex"01"), hex"01");
}
function test_readBytes_bytestring7f() external {
function test_readBytes_bytestring7f_succeeds() external {
assertEq(RLPReader.readBytes(hex"7f"), hex"7f");
}
function test_readBytes_revertListItem() external {
function test_readBytes_revertListItem_reverts() external {
vm.expectRevert("RLPReader: decoded item type for bytes is not a data item");
RLPReader.readBytes(hex"c7c0c1c0c3c0c1c0");
}
function test_readBytes_invalidStringLength() external {
function test_readBytes_invalidStringLength_reverts() external {
vm.expectRevert(
"RLPReader: length of content must be > than length of string length (long string)"
);
RLPReader.readBytes(hex"b9");
}
function test_readBytes_invalidListLength() external {
function test_readBytes_invalidListLength_reverts() external {
vm.expectRevert(
"RLPReader: length of content must be > than length of list length (long list)"
);
RLPReader.readBytes(hex"ff");
}
function test_readBytes_invalidRemainder() external {
function test_readBytes_invalidRemainder_reverts() external {
vm.expectRevert("RLPReader: bytes value contains an invalid remainder");
RLPReader.readBytes(hex"800a");
}
function test_readBytes_invalidPrefix() external {
function test_readBytes_invalidPrefix_reverts() external {
vm.expectRevert(
"RLPReader: invalid prefix, single byte < 0x80 are not prefixed (short string)"
);
RLPReader.readBytes(hex"810a");
}
function test_readList_empty() external {
function test_readList_empty_succeeds() external {
RLPReader.RLPItem[] memory list = RLPReader.readList(hex"c0");
assertEq(list.length, 0);
}
function test_readList_multiList() external {
function test_readList_multiList_succeeds() external {
RLPReader.RLPItem[] memory list = RLPReader.readList(hex"c6827a77c10401");
assertEq(list.length, 3);
......@@ -63,7 +63,7 @@ contract RLPReader_Test is CommonTest {
assertEq(RLPReader.readRawBytes(list[2]), hex"01");
}
function test_readList_shortListMax1() external {
function test_readList_shortListMax1_succeeds() external {
RLPReader.RLPItem[] memory list = RLPReader.readList(
hex"f784617364668471776572847a78637684617364668471776572847a78637684617364668471776572847a78637684617364668471776572"
);
......@@ -82,7 +82,7 @@ contract RLPReader_Test is CommonTest {
assertEq(RLPReader.readRawBytes(list[10]), hex"8471776572");
}
function test_readList_longList1() external {
function test_readList_longList1_succeeds() external {
RLPReader.RLPItem[] memory list = RLPReader.readList(
hex"f840cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376"
);
......@@ -94,7 +94,7 @@ contract RLPReader_Test is CommonTest {
assertEq(RLPReader.readRawBytes(list[3]), hex"cf84617364668471776572847a786376");
}
function test_readList_longList2() external {
function test_readList_longList2_succeeds() external {
RLPReader.RLPItem[] memory list = RLPReader.readList(
hex"f90200cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376cf84617364668471776572847a786376"
);
......@@ -105,21 +105,21 @@ contract RLPReader_Test is CommonTest {
}
}
function test_readList_listLongerThan32Elements() external {
function test_readList_listLongerThan32Elements_reverts() external {
vm.expectRevert(stdError.indexOOBError);
RLPReader.readList(
hex"e1454545454545454545454545454545454545454545454545454545454545454545"
);
}
function test_readList_listOfLists() external {
function test_readList_listOfLists_succeeds() external {
RLPReader.RLPItem[] memory list = RLPReader.readList(hex"c4c2c0c0c0");
assertEq(list.length, 2);
assertEq(RLPReader.readRawBytes(list[0]), hex"c2c0c0");
assertEq(RLPReader.readRawBytes(list[1]), hex"c0");
}
function test_readList_listOfLists2() external {
function test_readList_listOfLists2_succeeds() external {
RLPReader.RLPItem[] memory list = RLPReader.readList(hex"c7c0c1c0c3c0c1c0");
assertEq(list.length, 3);
......@@ -128,7 +128,7 @@ contract RLPReader_Test is CommonTest {
assertEq(RLPReader.readRawBytes(list[2]), hex"c3c0c1c0");
}
function test_readList_dictTest1() external {
function test_readList_dictTest1_succeeds() external {
RLPReader.RLPItem[] memory list = RLPReader.readList(
hex"ecca846b6579318476616c31ca846b6579328476616c32ca846b6579338476616c33ca846b6579348476616c34"
);
......@@ -140,21 +140,21 @@ contract RLPReader_Test is CommonTest {
assertEq(RLPReader.readRawBytes(list[3]), hex"ca846b6579348476616c34");
}
function test_readList_invalidShortList() external {
function test_readList_invalidShortList_reverts() external {
vm.expectRevert(
"RLPReader: length of content must be greater than list length (short list)"
);
RLPReader.readList(hex"efdebd");
}
function test_readList_longStringLength() external {
function test_readList_longStringLength_reverts() external {
vm.expectRevert(
"RLPReader: length of content must be greater than list length (short list)"
);
RLPReader.readList(hex"efb83600");
}
function test_readList_notLongEnough() external {
function test_readList_notLongEnough_reverts() external {
vm.expectRevert(
"RLPReader: length of content must be greater than list length (short list)"
);
......@@ -163,21 +163,21 @@ contract RLPReader_Test is CommonTest {
);
}
function test_readList_int32Overflow() external {
function test_readList_int32Overflow_reverts() external {
vm.expectRevert(
"RLPReader: length of content must be greater than total length (long string)"
);
RLPReader.readList(hex"bf0f000000000000021111");
}
function test_readList_int32Overflow2() external {
function test_readList_int32Overflow2_reverts() external {
vm.expectRevert(
"RLPReader: length of content must be greater than total length (long list)"
);
RLPReader.readList(hex"ff0f000000000000021111");
}
function test_readList_incorrectLengthInArray() external {
function test_readList_incorrectLengthInArray_reverts() external {
vm.expectRevert(
"RLPReader: length of content must not have any leading zeros (long string)"
);
......@@ -186,7 +186,7 @@ contract RLPReader_Test is CommonTest {
);
}
function test_readList_leadingZerosInLongLengthArray1() external {
function test_readList_leadingZerosInLongLengthArray1_reverts() external {
vm.expectRevert(
"RLPReader: length of content must not have any leading zeros (long string)"
);
......@@ -195,76 +195,76 @@ contract RLPReader_Test is CommonTest {
);
}
function test_readList_leadingZerosInLongLengthArray2() external {
function test_readList_leadingZerosInLongLengthArray2_reverts() external {
vm.expectRevert(
"RLPReader: length of content must not have any leading zeros (long string)"
);
RLPReader.readList(hex"b800");
}
function test_readList_leadingZerosInLongLengthList1() external {
function test_readList_leadingZerosInLongLengthList1_reverts() external {
vm.expectRevert("RLPReader: length of content must not have any leading zeros (long list)");
RLPReader.readList(
hex"fb00000040000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132333435363738393a3b3c3d3e3f"
);
}
function test_readList_nonOptimalLongLengthArray1() external {
function test_readList_nonOptimalLongLengthArray1_reverts() external {
vm.expectRevert("RLPReader: length of content must be greater than 55 bytes (long string)");
RLPReader.readList(hex"b81000112233445566778899aabbccddeeff");
}
function test_readList_nonOptimalLongLengthArray2() external {
function test_readList_nonOptimalLongLengthArray2_reverts() external {
vm.expectRevert("RLPReader: length of content must be greater than 55 bytes (long string)");
RLPReader.readList(hex"b801ff");
}
function test_readList_invalidValue() external {
function test_readList_invalidValue_reverts() external {
vm.expectRevert(
"RLPReader: length of content must be greater than string length (short string)"
);
RLPReader.readList(hex"91");
}
function test_readList_invalidRemainder() external {
function test_readList_invalidRemainder_reverts() external {
vm.expectRevert("RLPReader: list item has an invalid data remainder");
RLPReader.readList(hex"c000");
}
function test_readList_notEnoughContentForString1() external {
function test_readList_notEnoughContentForString1_reverts() external {
vm.expectRevert(
"RLPReader: length of content must be greater than total length (long string)"
);
RLPReader.readList(hex"ba010000aabbccddeeff");
}
function test_readList_notEnoughContentForString2() external {
function test_readList_notEnoughContentForString2_reverts() external {
vm.expectRevert(
"RLPReader: length of content must be greater than total length (long string)"
);
RLPReader.readList(hex"b840ffeeddccbbaa99887766554433221100");
}
function test_readList_notEnoughContentForList1() external {
function test_readList_notEnoughContentForList1_reverts() external {
vm.expectRevert(
"RLPReader: length of content must be greater than total length (long list)"
);
RLPReader.readList(hex"f90180");
}
function test_readList_notEnoughContentForList2() external {
function test_readList_notEnoughContentForList2_reverts() external {
vm.expectRevert(
"RLPReader: length of content must be greater than total length (long list)"
);
RLPReader.readList(hex"ffffffffffffffffff0001020304050607");
}
function test_readList_longStringLessThan56Bytes() external {
function test_readList_longStringLessThan56Bytes_reverts() external {
vm.expectRevert("RLPReader: length of content must be greater than 55 bytes (long string)");
RLPReader.readList(hex"b80100");
}
function test_readList_longListLessThan56Bytes() external {
function test_readList_longListLessThan56Bytes_reverts() external {
vm.expectRevert("RLPReader: length of content must be greater than 55 bytes (long list)");
RLPReader.readList(hex"f80100");
}
......
......@@ -5,41 +5,41 @@ import { RLPWriter } from "../libraries/rlp/RLPWriter.sol";
import { CommonTest } from "./CommonTest.t.sol";
contract RLPWriter_Test is CommonTest {
function test_writeString_empty() external {
function test_writeString_empty_succeeds() external {
assertEq(RLPWriter.writeString(""), hex"80");
}
function test_writeString_bytestring00() external {
function test_writeString_bytestring00_succeeds() external {
assertEq(RLPWriter.writeString("\u0000"), hex"00");
}
function test_writeString_bytestring01() external {
function test_writeString_bytestring01_succeeds() external {
assertEq(RLPWriter.writeString("\u0001"), hex"01");
}
function test_writeString_bytestring7f() external {
function test_writeString_bytestring7f_succeeds() external {
assertEq(RLPWriter.writeString("\u007F"), hex"7f");
}
function test_writeString_shortstring() external {
function test_writeString_shortstring_succeeds() external {
assertEq(RLPWriter.writeString("dog"), hex"83646f67");
}
function test_writeString_shortstring2() external {
function test_writeString_shortstring2_succeeds() external {
assertEq(
RLPWriter.writeString("Lorem ipsum dolor sit amet, consectetur adipisicing eli"),
hex"b74c6f72656d20697073756d20646f6c6f722073697420616d65742c20636f6e7365637465747572206164697069736963696e6720656c69"
);
}
function test_writeString_longstring() external {
function test_writeString_longstring_succeeds() external {
assertEq(
RLPWriter.writeString("Lorem ipsum dolor sit amet, consectetur adipisicing elit"),
hex"b8384c6f72656d20697073756d20646f6c6f722073697420616d65742c20636f6e7365637465747572206164697069736963696e6720656c6974"
);
}
function test_writeString_longstring2() external {
function test_writeString_longstring2_succeeds() external {
assertEq(
RLPWriter.writeString(
"Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur mauris magna, suscipit sed vehicula non, iaculis faucibus tortor. Proin suscipit ultricies malesuada. Duis tortor elit, dictum quis tristique eu, ultrices at risus. Morbi a est imperdiet mi ullamcorper aliquet suscipit nec lorem. Aenean quis leo mollis, vulputate elit varius, consequat enim. Nulla ultrices turpis justo, et posuere urna consectetur nec. Proin non convallis metus. Donec tempor ipsum in mauris congue sollicitudin. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Suspendisse convallis sem vel massa faucibus, eget lacinia lacus tempor. Nulla quis ultricies purus. Proin auctor rhoncus nibh condimentum mollis. Aliquam consequat enim at metus luctus, a eleifend purus egestas. Curabitur at nibh metus. Nam bibendum, neque at auctor tristique, lorem libero aliquet arcu, non interdum tellus lectus sit amet eros. Cras rhoncus, metus ac ornare cursus, dolor justo ultrices metus, at ullamcorper volutpat"
......@@ -48,43 +48,43 @@ contract RLPWriter_Test is CommonTest {
);
}
function test_writeUint_zero() external {
function test_writeUint_zero_succeeds() external {
assertEq(RLPWriter.writeUint(0x0), hex"80");
}
function test_writeUint_smallint() external {
function test_writeUint_smallint_succeeds() external {
assertEq(RLPWriter.writeUint(1), hex"01");
}
function test_writeUint_smallint2() external {
function test_writeUint_smallint2_succeeds() external {
assertEq(RLPWriter.writeUint(16), hex"10");
}
function test_writeUint_smallint3() external {
function test_writeUint_smallint3_succeeds() external {
assertEq(RLPWriter.writeUint(79), hex"4f");
}
function test_writeUint_smallint4() external {
function test_writeUint_smallint4_succeeds() external {
assertEq(RLPWriter.writeUint(127), hex"7f");
}
function test_writeUint_mediumint() external {
function test_writeUint_mediumint_succeeds() external {
assertEq(RLPWriter.writeUint(128), hex"8180");
}
function test_writeUint_mediumint2() external {
function test_writeUint_mediumint2_succeeds() external {
assertEq(RLPWriter.writeUint(1000), hex"8203e8");
}
function test_writeUint_mediumint3() external {
function test_writeUint_mediumint3_succeeds() external {
assertEq(RLPWriter.writeUint(100000), hex"830186a0");
}
function test_writeList_empty() external {
function test_writeList_empty_succeeds() external {
assertEq(RLPWriter.writeList(new bytes[](0)), hex"c0");
}
function test_writeList_stringList() external {
function test_writeList_stringList_succeeds() external {
bytes[] memory list = new bytes[](3);
list[0] = RLPWriter.writeString("dog");
list[1] = RLPWriter.writeString("god");
......@@ -93,7 +93,7 @@ contract RLPWriter_Test is CommonTest {
assertEq(RLPWriter.writeList(list), hex"cc83646f6783676f6483636174");
}
function test_writeList_multiList() external {
function test_writeList_multiList_succeeds() external {
bytes[] memory list = new bytes[](3);
bytes[] memory list2 = new bytes[](1);
list2[0] = RLPWriter.writeUint(4);
......@@ -105,7 +105,7 @@ contract RLPWriter_Test is CommonTest {
assertEq(RLPWriter.writeList(list), hex"c6827a77c10401");
}
function test_writeList_shortListMax1() external {
function test_writeList_shortListMax1_succeeds() external {
bytes[] memory list = new bytes[](11);
list[0] = RLPWriter.writeString("asdf");
list[1] = RLPWriter.writeString("qwer");
......@@ -125,7 +125,7 @@ contract RLPWriter_Test is CommonTest {
);
}
function test_writeList_longlist1() external {
function test_writeList_longlist1_succeeds() external {
bytes[] memory list = new bytes[](4);
bytes[] memory list2 = new bytes[](3);
......@@ -144,7 +144,7 @@ contract RLPWriter_Test is CommonTest {
);
}
function test_writeList_longlist2() external {
function test_writeList_longlist2_succeeds() external {
bytes[] memory list = new bytes[](32);
bytes[] memory list2 = new bytes[](3);
......@@ -162,7 +162,7 @@ contract RLPWriter_Test is CommonTest {
);
}
function test_writeList_listoflists() external {
function test_writeList_listoflists_succeeds() external {
// [ [ [], [] ], [] ]
bytes[] memory list = new bytes[](2);
bytes[] memory list2 = new bytes[](2);
......@@ -176,7 +176,7 @@ contract RLPWriter_Test is CommonTest {
assertEq(RLPWriter.writeList(list), hex"c4c2c0c0c0");
}
function test_writeList_listoflists2() external {
function test_writeList_listoflists2_succeeds() external {
// [ [], [[]], [ [], [[]] ] ]
bytes[] memory list = new bytes[](3);
list[0] = RLPWriter.writeList(new bytes[](0));
......@@ -195,7 +195,7 @@ contract RLPWriter_Test is CommonTest {
assertEq(RLPWriter.writeList(list), hex"c7c0c1c0c3c0c1c0");
}
function test_writeList_dictTest1() external {
function test_writeList_dictTest1_succeeds() external {
bytes[] memory list = new bytes[](4);
bytes[] memory list1 = new bytes[](2);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment