From 2c127685dba3f5b73a2374ead00503cd7b11120a Mon Sep 17 00:00:00 2001 From: turbocrime Date: Wed, 18 Dec 2024 17:26:42 -0800 Subject: [PATCH 1/8] rename tests, update workflow --- .gas-snapshot | 118 +++++----- .github/workflows/test.yml | 5 + lcov.info | 210 +++++++++--------- test/Array.t.sol | 10 +- test/Bytes.t.sol | 18 +- test/Int.t.sol | 65 ++++++ test/Map.t.sol | 87 ++++---- test/NInt.t.sol | 43 ++-- test/Simple.t.sol | 6 +- test/String.t.sol | 27 +-- test/Tag.t.sol | 8 +- test/UInt.t.sol | 34 ++- test/tags/{ReadBignum.t.sol => Bignum.t.sol} | 2 +- .../{ReadCidSha256.t.sol => CidSha256.t.sol} | 2 +- 14 files changed, 355 insertions(+), 280 deletions(-) create mode 100644 test/Int.t.sol rename test/tags/{ReadBignum.t.sol => Bignum.t.sol} (99%) rename test/tags/{ReadCidSha256.t.sol => CidSha256.t.sol} (98%) diff --git a/.gas-snapshot b/.gas-snapshot index 6d2deaf..a3309cf 100644 --- a/.gas-snapshot +++ b/.gas-snapshot @@ -1,14 +1,29 @@ -ArrayTest:test_decodeEmptyArray() (gas: 560) -ArrayTest:test_decodeLargeArray() (gas: 606) -ArrayTest:test_decodeMixedArray() (gas: 2048) -ArrayTest:test_decodeNestedArray() (gas: 2281) -ArrayTest:test_decodeSingleElementArray() (gas: 987) -BytesTest:test_Bytes32_short() (gas: 846) -BytesTest:test_decodeEmptyBytes() (gas: 760) -BytesTest:test_decodeLongBytes() (gas: 851) -BytesTest:test_decodeMediumBytes() (gas: 830) -BytesTest:test_decodeShortBytes() (gas: 777) +ArrayTest:test_Array_empty() (gas: 560) +ArrayTest:test_Array_large() (gas: 607) +ArrayTest:test_Array_mixed() (gas: 2071) +ArrayTest:test_Array_nested() (gas: 2280) +ArrayTest:test_Array_single() (gas: 964) +BignumTest:test_Integer() (gas: 12559) +BignumTest:test_NInt256_max() (gas: 1697) +BignumTest:test_NInt256_middle() (gas: 2134) +BignumTest:test_NInt256_multi() (gas: 1190) +BignumTest:test_NInt256_random(int256) (runs: 256, μ: 5100, ~: 5100) +BignumTest:test_NInt256_single() (gas: 1191) +BignumTest:test_UInt256_max() (gas: 1502) +BignumTest:test_UInt256_middle() (gas: 1946) +BignumTest:test_UInt256_multi() (gas: 1068) +BignumTest:test_UInt256_random(uint256) (runs: 256, μ: 1561, ~: 1561) +BignumTest:test_UInt256_single() (gas: 1364) +BytesTest:test_Bytes32_short() (gas: 802) +BytesTest:test_Bytes_empty() (gas: 761) +BytesTest:test_Bytes_extended() (gas: 851) +BytesTest:test_Bytes_short() (gas: 779) BytesTest:test_skipBytes() (gas: 653) +CidSha256Test:test_Cid() (gas: 521) +CidSha256Test:test_Cid_multicodec_raw() (gas: 449) +CidSha256Test:test_Cid_random(uint256) (runs: 256, μ: 3520, ~: 3520) +CidSha256Test:test_NullableCid_nullCbor() (gas: 519) +CidSha256Test:test_NullableCid_random(uint256) (runs: 256, μ: 885, ~: 889) ComparisonTest:test_decodeArrayU8_CBORDecoder() (gas: 5274) ComparisonTest:test_decodeArrayU8_ReadCbor() (gas: 2334) ComparisonTest:test_decodeFalse_CBORDecoder() (gas: 916) @@ -28,17 +43,25 @@ ComparisonTest:test_decodeTrue_ReadCbor() (gas: 483) HeaderTest:test_header() (gas: 651) HeaderTest:test_header32_u16() (gas: 726) HeaderTest:test_header32_u32() (gas: 700) -MapTest:test_decodeEmptyMap() (gas: 539) -MapTest:test_decodeNestedMap() (gas: 6619) -MapTest:test_decodeSingleKeyMap() (gas: 1764) -MapTest:test_deeplyNestedStructure() (gas: 3560) -NIntTest:test_decodeLongNInt8() (gas: 768) -NIntTest:test_decodeNInt16() (gas: 918) -NIntTest:test_decodeNInt32() (gas: 901) -NIntTest:test_decodeNInt64() (gas: 938) -NIntTest:test_decodeNInt8() (gas: 789) -NIntTest:test_decodeShortNInt8() (gas: 689) -NIntTest:test_decodeSmallNInts() (gas: 1155) +IntTest:test_Int_max() (gas: 835) +IntTest:test_Int_min() (gas: 948) +IntTest:test_Int_neg_one() (gas: 787) +IntTest:test_Int_nint16() (gas: 891) +IntTest:test_Int_uint16() (gas: 778) +IntTest:test_Int_zero() (gas: 695) +MapTest:test_Map_empty() (gas: 559) +MapTest:test_Map_nested() (gas: 6640) +MapTest:test_Map_nested2() (gas: 3561) +MapTest:test_Map_single() (gas: 1742) +NIntTest:test_NInt() (gas: 874) +NIntTest:test_NInt16() (gas: 874) +NIntTest:test_NInt32() (gas: 947) +NIntTest:test_NInt64() (gas: 938) +NIntTest:test_NInt8_0() (gas: 731) +NIntTest:test_NInt8_1() (gas: 666) +NIntTest:test_NInt8_long() (gas: 789) +NIntTest:test_NInt8_max() (gas: 766) +NIntTest:test_NInt8_short() (gas: 667) PeekTest:test_isArray_false() (gas: 317) PeekTest:test_isArray_true() (gas: 312) PeekTest:test_isBool_false() (gas: 305) @@ -68,39 +91,24 @@ PeekTest:test_isUInt_false() (gas: 349) PeekTest:test_isUInt_true() (gas: 370) PeekTest:test_isUndefined_false() (gas: 375) PeekTest:test_isUndefined_true() (gas: 303) -ReadBignum_Test:test_Integer() (gas: 12559) -ReadBignum_Test:test_NInt256_max() (gas: 1697) -ReadBignum_Test:test_NInt256_middle() (gas: 2134) -ReadBignum_Test:test_NInt256_multi() (gas: 1190) -ReadBignum_Test:test_NInt256_random(int256) (runs: 256, μ: 5100, ~: 5100) -ReadBignum_Test:test_NInt256_single() (gas: 1191) -ReadBignum_Test:test_UInt256_max() (gas: 1502) -ReadBignum_Test:test_UInt256_middle() (gas: 1946) -ReadBignum_Test:test_UInt256_multi() (gas: 1068) -ReadBignum_Test:test_UInt256_random(uint256) (runs: 256, μ: 1561, ~: 1561) -ReadBignum_Test:test_UInt256_single() (gas: 1364) -ReadCidSha256_Test:test_Cid() (gas: 521) -ReadCidSha256_Test:test_Cid_multicodec_raw() (gas: 449) -ReadCidSha256_Test:test_Cid_random(uint256) (runs: 256, μ: 3520, ~: 3520) -ReadCidSha256_Test:test_NullableCid_nullCbor() (gas: 519) -ReadCidSha256_Test:test_NullableCid_random(uint256) (runs: 256, μ: 885, ~: 889) -SimpleTest:test_decodeFalse() (gas: 424) -SimpleTest:test_decodeTrue() (gas: 438) +SimpleTest:test_Boolean_false() (gas: 446) +SimpleTest:test_Boolean_true() (gas: 482) SimpleTest:test_skipNull() (gas: 412) -SimpleTest:test_skipUndefined() (gas: 455) +SimpleTest:test_skipUndefined() (gas: 433) StringTest:test_String1() (gas: 457) -StringTest:test_String32_short() (gas: 805) -StringTest:test_decodeEmptyString() (gas: 755) -StringTest:test_decodeLongString() (gas: 801) -StringTest:test_decodeMediumString() (gas: 852) -StringTest:test_decodeShortString() (gas: 778) -StringTest:test_skipString() (gas: 677) -TagTest:test_decodeExpectedTag() (gas: 627) -TagTest:test_decodeTag() (gas: 666) -UIntTest:test_decodeLongUInt8() (gas: 636) -UIntTest:test_decodeShortUInt8() (gas: 578) -UIntTest:test_decodeSmallInts() (gas: 913) -UIntTest:test_decodeUInt16() (gas: 751) -UIntTest:test_decodeUInt32() (gas: 779) -UIntTest:test_decodeUInt64() (gas: 827) -UIntTest:test_decodeUInt8() (gas: 634) \ No newline at end of file +StringTest:test_String32_short() (gas: 849) +StringTest:test_String_empty() (gas: 755) +StringTest:test_String_extended() (gas: 799) +StringTest:test_String_short() (gas: 778) +StringTest:test_skipString() (gas: 654) +TagTest:test_Tag() (gas: 644) +TagTest:test_Tag_expected() (gas: 671) +UIntTest:test_UInt() (gas: 726) +UIntTest:test_UInt16_max() (gas: 752) +UIntTest:test_UInt32_max() (gas: 790) +UIntTest:test_UInt64_max() (gas: 805) +UIntTest:test_UInt8_0() (gas: 579) +UIntTest:test_UInt8_1() (gas: 577) +UIntTest:test_UInt8_extended() (gas: 657) +UIntTest:test_UInt8_max() (gas: 679) +UIntTest:test_UInt8_short() (gas: 533) \ No newline at end of file diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 762a296..64b7222 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -43,3 +43,8 @@ jobs: run: | forge test -vvv id: test + + - name: Run snapshot + run: | + forge snapshot --match-test test_ --check + id: test-committed \ No newline at end of file diff --git a/lcov.info b/lcov.info index 9053964..025b8fa 100644 --- a/lcov.info +++ b/lcov.info @@ -1,77 +1,77 @@ TN: SF:src/ReadCbor.sol -DA:33,811 +DA:33,819 FN:33,ReadCbor.parseArg -FNDA:811,ReadCbor.parseArg -DA:34,811 -BRDA:34,0,0,539 +FNDA:819,ReadCbor.parseArg +DA:34,819 +BRDA:34,0,0,541 BRDA:34,0,1,257 -DA:35,539 -DA:36,272 +DA:35,541 +DA:36,278 BRDA:36,1,0,3 BRDA:36,1,1,257 DA:37,3 DA:38,3 BRDA:38,2,0,1 BRDA:38,2,1,2 -DA:39,269 -BRDA:39,3,0,4 +DA:39,275 +BRDA:39,3,0,7 BRDA:39,3,1,257 -DA:40,4 -DA:41,265 +DA:40,7 +DA:41,268 BRDA:41,4,0,4 BRDA:41,4,1,257 DA:42,4 -DA:43,261 -BRDA:43,5,0,4 +DA:43,264 +BRDA:43,5,0,7 BRDA:43,5,1,257 -DA:44,4 +DA:44,7 DA:46,257 -DA:50,818 +DA:50,827 FN:50,ReadCbor.u8 -FNDA:818,ReadCbor.u8 -DA:53,818 -DA:54,818 -DA:58,4 +FNDA:827,ReadCbor.u8 +DA:53,827 +DA:54,827 +DA:58,7 FN:58,ReadCbor.u16 -FNDA:4,ReadCbor.u16 -DA:61,4 -DA:62,4 +FNDA:7,ReadCbor.u16 +DA:61,7 +DA:62,7 DA:66,4 FN:66,ReadCbor.u32 FNDA:4,ReadCbor.u32 DA:69,4 DA:70,4 -DA:74,4 +DA:74,7 FN:74,ReadCbor.u64 -FNDA:4,ReadCbor.u64 -DA:77,4 -DA:78,4 -DA:88,268 +FNDA:7,ReadCbor.u64 +DA:77,7 +DA:78,7 +DA:88,274 FN:88,ReadCbor.header -FNDA:268,ReadCbor.header -DA:89,268 -DA:90,268 -DA:91,268 -DA:92,268 -DA:93,268 -DA:103,538 +FNDA:274,ReadCbor.header +DA:89,274 +DA:90,274 +DA:91,274 +DA:92,274 +DA:93,274 +DA:103,540 FN:103,ReadCbor.header -FNDA:538,ReadCbor.header -DA:104,538 -DA:105,538 -DA:106,538 +FNDA:540,ReadCbor.header +DA:104,540 +DA:105,540 +DA:106,540 BRDA:106,6,0,1 -BRDA:106,6,1,537 -DA:107,537 -DA:118,9 +BRDA:106,6,1,539 +DA:107,539 +DA:118,10 FN:118,ReadCbor.header -FNDA:9,ReadCbor.header -DA:123,9 -DA:124,9 -DA:125,9 -DA:126,9 -BRDA:126,7,0,1 +FNDA:10,ReadCbor.header +DA:123,10 +DA:124,10 +DA:125,10 +DA:126,10 +BRDA:126,7,0,2 BRDA:126,7,1,8 DA:127,8 DA:128,8 @@ -100,25 +100,25 @@ DA:157,533 BRDA:157,12,0,2 BRDA:157,12,1,531 DA:160,586 -DA:170,47 +DA:170,45 FN:170,ReadCbor.header32 -FNDA:47,ReadCbor.header32 -DA:171,47 -DA:174,47 -DA:175,47 -DA:176,47 -DA:177,47 -DA:180,47 +FNDA:45,ReadCbor.header32 +DA:171,45 +DA:174,45 +DA:175,45 +DA:176,45 +DA:177,45 +DA:180,45 BRDA:180,13,0,2 -BRDA:180,13,1,45 -DA:182,45 -BRDA:182,14,0,4 +BRDA:180,13,1,43 +DA:182,43 +BRDA:182,14,0,2 BRDA:182,14,1,1 -DA:184,4 -DA:185,4 -DA:187,4 +DA:184,2 +DA:185,2 +DA:187,2 BRDA:187,15,0,1 -BRDA:187,15,1,3 +BRDA:187,15,1,1 DA:188,41 BRDA:188,16,0,3 DA:189,3 @@ -133,7 +133,7 @@ DA:195,1 BRDA:195,19,0,1 DA:197,1 DA:198,1 -DA:203,43 +DA:203,41 DA:210,263 FN:210,ReadCbor.isNull FNDA:263,ReadCbor.isNull @@ -192,16 +192,16 @@ DA:325,2 FN:325,ReadCbor.isString FNDA:2,ReadCbor.isString DA:327,2 -DA:336,11 +DA:336,10 FN:336,ReadCbor.String -FNDA:11,ReadCbor.String -DA:337,11 -DA:338,11 -DA:340,11 -DA:342,11 -DA:343,11 -DA:344,11 -DA:345,11 +FNDA:10,ReadCbor.String +DA:337,10 +DA:338,10 +DA:340,10 +DA:342,10 +DA:343,10 +DA:344,10 +DA:345,10 DA:357,14 FN:357,ReadCbor.String32 FNDA:14,ReadCbor.String32 @@ -238,16 +238,16 @@ DA:404,2 FN:404,ReadCbor.isBytes FNDA:2,ReadCbor.isBytes DA:406,2 -DA:415,4 +DA:415,3 FN:415,ReadCbor.Bytes -FNDA:4,ReadCbor.Bytes -DA:416,4 -DA:417,4 -DA:419,4 -DA:421,4 -DA:422,4 -DA:423,4 -DA:424,4 +FNDA:3,ReadCbor.Bytes +DA:416,3 +DA:417,3 +DA:419,3 +DA:421,3 +DA:422,3 +DA:423,3 +DA:424,3 DA:436,3 FN:436,ReadCbor.Bytes32 FNDA:3,ReadCbor.Bytes32 @@ -306,10 +306,10 @@ DA:524,2 FN:524,ReadCbor.isUInt FNDA:2,ReadCbor.isUInt DA:526,2 -DA:535,0 +DA:535,1 FN:535,ReadCbor.UInt -FNDA:0,ReadCbor.UInt -DA:536,0 +FNDA:1,ReadCbor.UInt +DA:536,1 DA:544,40 FN:544,ReadCbor.UInt8 FNDA:40,ReadCbor.UInt8 @@ -334,23 +334,23 @@ DA:583,2 FN:583,ReadCbor.isNInt FNDA:2,ReadCbor.isNInt DA:585,2 -DA:594,0 +DA:594,1 FN:594,ReadCbor.NInt -FNDA:0,ReadCbor.NInt -DA:595,0 -DA:596,0 -DA:597,0 +FNDA:1,ReadCbor.NInt +DA:595,1 +DA:596,1 +DA:597,1 DA:605,7 FN:605,ReadCbor.NInt8 FNDA:7,ReadCbor.NInt8 DA:606,7 DA:607,7 DA:608,5 -DA:616,2 +DA:616,3 FN:616,ReadCbor.NInt16 -FNDA:2,ReadCbor.NInt16 -DA:617,2 -DA:618,2 +FNDA:3,ReadCbor.NInt16 +DA:617,3 +DA:618,3 DA:619,1 DA:627,1 FN:627,ReadCbor.NInt32 @@ -369,25 +369,25 @@ FN:648,ReadCbor.isInt FNDA:3,ReadCbor.isInt DA:650,3 DA:651,3 -DA:660,10 +DA:660,16 FN:660,ReadCbor.Int -FNDA:10,ReadCbor.Int -DA:661,10 -DA:662,10 -DA:663,10 -DA:664,10 -BRDA:664,29,0,5 +FNDA:16,ReadCbor.Int +DA:661,16 +DA:662,16 +DA:663,16 +DA:664,16 +BRDA:664,29,0,8 BRDA:664,29,1,1 -DA:665,5 -DA:666,5 -BRDA:666,30,0,4 +DA:665,8 +DA:666,8 +BRDA:666,30,0,7 BRDA:666,30,1,1 -DA:667,4 +DA:667,7 DA:669,1 FNF:49 -FNH:47 +FNH:49 LF:229 -LH:223 +LH:229 BRF:57 BRH:57 end_of_record diff --git a/test/Array.t.sol b/test/Array.t.sol index 02f0e86..888e5bf 100644 --- a/test/Array.t.sol +++ b/test/Array.t.sol @@ -8,7 +8,7 @@ using ReadCbor for bytes; contract ArrayTest is Test { // Test array handling - function test_decodeEmptyArray() public pure { + function test_Array_empty() public pure { bytes memory cbor = hex"80"; // Empty array in CBOR uint i; uint32 len; @@ -16,7 +16,7 @@ contract ArrayTest is Test { assert(len == 0); } - function test_decodeLargeArray() public pure { + function test_Array_large() public pure { // Array with 23 elements (just below the threshold for extended header) bytes memory cbor = hex"97010101010101010101010101010101010101010101010101"; uint i; @@ -26,7 +26,7 @@ contract ArrayTest is Test { } // Test nested structures - function test_decodeNestedArray() public pure { + function test_Array_nested() public pure { // [[1, 2], [3, 4]] bytes memory cbor = hex"82820102820304"; uint i; @@ -56,7 +56,7 @@ contract ArrayTest is Test { assert(value == 4); } - function test_decodeSingleElementArray() public pure { + function test_Array_single() public pure { bytes memory cbor = hex"8118ff"; // [0xff] uint i; uint32 len; @@ -69,7 +69,7 @@ contract ArrayTest is Test { assert(value == 0xff); } - function test_decodeMixedArray() public pure { + function test_Array_mixed() public pure { // [1, "a", [2]] bytes memory cbor = hex"830161618102"; diff --git a/test/Bytes.t.sol b/test/Bytes.t.sol index f6e5ab8..8c261d6 100644 --- a/test/Bytes.t.sol +++ b/test/Bytes.t.sol @@ -8,17 +8,7 @@ using ReadCbor for bytes; /// @author turbocrime contract BytesTest is Test { - // Additional bytes tests - function test_decodeMediumBytes() public pure { - // Bytes with 24 bytes (just above the threshold for one-byte length encoding) - bytes memory cbor = hex"5818000102030405060708090a0b0c0d0e0f101112131415161718"; // 24 bytes of incrementing values - uint i; - bytes memory value; - (i, value) = cbor.Bytes(0); - assert(value.length == 24); - } - - function test_decodeEmptyBytes() public pure { + function test_Bytes_empty() public pure { bytes memory cbor = hex"40"; // zero-length bytes in CBOR uint i; bytes memory value; @@ -27,7 +17,7 @@ contract BytesTest is Test { assert(value.length == 0); } - function test_decodeShortBytes() public pure { + function test_Bytes_short() public pure { // Bytes with 23 bytes (just below the threshold for an extended header) bytes memory cbor = hex"57000102030405060708090a0b0c0d0e0f1011121314151617"; uint i; @@ -36,7 +26,7 @@ contract BytesTest is Test { assert(value.length == 23); } - function test_decodeLongBytes() public pure { + function test_Bytes_extended() public pure { // Bytes with 24 bytes (just at the threshold for an extended header) bytes memory cbor = hex"5818000102030405060708090a0b0c0d0e0f101112131415161718"; uint i; @@ -57,7 +47,7 @@ contract BytesTest is Test { assert(value == bytes32(hex"00")); } - function testFail_Bytes32_long() public pure { + function testFail_Bytes32_too_long() public pure { // 33 bytes of data bytes memory cbor = hex"5821000102030405060708090a0b0c0d0e0f101112131415161718192021"; uint i; diff --git a/test/Int.t.sol b/test/Int.t.sol new file mode 100644 index 0000000..de155ff --- /dev/null +++ b/test/Int.t.sol @@ -0,0 +1,65 @@ +// SPDX-License-Identifier: Apache-2.0 +pragma solidity ^0.8.28; + +import {console, Test} from "forge-std/Test.sol"; +import "../src/ReadCbor.sol"; + +using ReadCbor for bytes; + +contract IntTest is Test { + // Test generic Int method + function test_Int_zero() public pure { + bytes memory cbor = hex"00"; + uint i; + int value; + (i, value) = cbor.Int(0); + assert(value == 0); + } + + function test_Int_neg_one() public pure { + bytes memory cbor = hex"20"; + uint i; + int value; + (i, value) = cbor.Int(0); + assert(value == -1); + } + + function test_Int_uint16() public pure { + bytes memory cbor = hex"19FFFF"; + uint i; + int value; + (i, value) = cbor.Int(0); + assert(value == 0xFFFF); + } + + function test_Int_nint16() public pure { + bytes memory cbor = hex"39FFFF"; + uint i; + int value; + (i, value) = cbor.Int(0); + assert(value == -1 - 0xFFFF); + } + + function test_Int_max() public pure { + bytes memory cbor = hex"1bffffffffffffffff"; + uint i; + int value; + (i, value) = cbor.Int(0); + assert(value == 0xFFFF_FFFF_FFFF_FFFF); + } + + function test_Int_min() public pure { + bytes memory cbor = hex"3bFFFFFFFFFFFFFFFF"; + uint i; + int value; + (i, value) = cbor.Int(0); + assert(value == -1 - 0xFFFF_FFFF_FFFF_FFFF); + } + + function testFail_Int_not() public pure { + bytes memory cbor = hex"f7"; + uint i; + int value; + (i, value) = cbor.Int(0); + } +} diff --git a/test/Map.t.sol b/test/Map.t.sol index 0455b49..5f524bc 100644 --- a/test/Map.t.sol +++ b/test/Map.t.sol @@ -9,7 +9,7 @@ using ReadCbor for bytes; /// @author turbocrime contract MapTest is Test { // Test map handling - function test_decodeEmptyMap() public pure { + function test_Map_empty() public pure { bytes memory cbor = hex"a0"; // Empty map in CBOR uint i; uint len; @@ -18,7 +18,7 @@ contract MapTest is Test { } // Additional map tests - function test_decodeSingleKeyMap() public pure { + function test_Map_single() public pure { bytes memory cbor = hex"a161618102"; // {"a": [2]} uint i; uint len; @@ -38,48 +38,7 @@ contract MapTest is Test { assert(value == 2); } - // Test deeply nested structures - function test_deeplyNestedStructure() public pure { - // {"a": {"b": {"c": [1, 2, 3]}}} - bytes memory cbor = hex"a16161a16162a1616383010203"; - uint i; - uint len; - bytes32 key; - uint arrayLen; - uint8 value; - - (i, len) = cbor.Map(0); - assert(len == 1); - - (i, key,) = cbor.String32(i, 1); - assert(bytes1(key) == "a"); - - (i, len) = cbor.Map(i); - assert(len == 1); - - (i, key,) = cbor.String32(i, 1); - assert(bytes1(key) == "b"); - - (i, len) = cbor.Map(i); - assert(len == 1); - - (i, key,) = cbor.String32(i, 1); - assert(bytes1(key) == "c"); - - (i, arrayLen) = cbor.Array(i); - assert(arrayLen == 3); - - (i, value) = cbor.UInt8(i); - assert(value == 1); - - (i, value) = cbor.UInt8(i); - assert(value == 2); - - (i, value) = cbor.UInt8(i); - assert(value == 3); - } - - function test_decodeNestedMap() public pure { + function test_Map_nested() public pure { // {"a": {"b": 1, "c": 2}, "d": 3} bytes memory cbor = hex"a26161a2616201616302616403"; uint i; @@ -141,4 +100,44 @@ contract MapTest is Test { (i, value) = cbor.UInt8(i); assert(value == 3); } + + function test_Map_nested2() public pure { + // {"a": {"b": {"c": [1, 2, 3]}}} + bytes memory cbor = hex"a16161a16162a1616383010203"; + uint i; + uint len; + bytes32 key; + uint arrayLen; + uint8 value; + + (i, len) = cbor.Map(0); + assert(len == 1); + + (i, key,) = cbor.String32(i, 1); + assert(bytes1(key) == "a"); + + (i, len) = cbor.Map(i); + assert(len == 1); + + (i, key,) = cbor.String32(i, 1); + assert(bytes1(key) == "b"); + + (i, len) = cbor.Map(i); + assert(len == 1); + + (i, key,) = cbor.String32(i, 1); + assert(bytes1(key) == "c"); + + (i, arrayLen) = cbor.Array(i); + assert(arrayLen == 3); + + (i, value) = cbor.UInt8(i); + assert(value == 1); + + (i, value) = cbor.UInt8(i); + assert(value == 2); + + (i, value) = cbor.UInt8(i); + assert(value == 3); + } } diff --git a/test/NInt.t.sol b/test/NInt.t.sol index 350864d..d6d3c8f 100644 --- a/test/NInt.t.sol +++ b/test/NInt.t.sol @@ -9,7 +9,7 @@ using ReadCbor for bytes; /// @author turbocrime contract NIntTest is Test { // Test basic integer types - function test_decodeShortNInt8() public pure { + function test_NInt8_short() public pure { bytes memory cbor = hex"37"; // max minor literal uint8 for negative uint i; int16 value; @@ -17,7 +17,7 @@ contract NIntTest is Test { assert(value == -24); // -1 - 23 } - function test_decodeLongNInt8() public pure { + function test_NInt8_long() public pure { bytes memory cbor = hex"3818"; // minimum header extension uint8 for negative uint i; int16 value; @@ -25,7 +25,7 @@ contract NIntTest is Test { assert(value == -25); // -1 - 24 } - function testFail_invalidNInt8() public pure { + function testFail_NInt8_invalid() public pure { bytes memory cbor = hex"3817"; // extended header too small uint i; int16 value; @@ -33,7 +33,7 @@ contract NIntTest is Test { assert(value == -24); } - function test_decodeNInt8() public pure { + function test_NInt8_max() public pure { bytes memory cbor = hex"38ff"; // max uint8 for negative uint i; int16 value; @@ -41,14 +41,14 @@ contract NIntTest is Test { assert(value == -256); // -1 - 255 } - function testFail_notNInt8() public pure { + function testFail_NInt8_too_long() public pure { bytes memory cbor = hex"39ffff"; // uint16 value uint i; int16 value; (i, value) = cbor.NInt8(0); // Should fail as value exceeds int8 } - function test_decodeNInt16() public pure { + function test_NInt16() public pure { bytes memory cbor = hex"39ffff"; // max uint16 for negative uint i; int24 value; @@ -56,7 +56,7 @@ contract NIntTest is Test { assert(value == -65536); // -1 - 65535 } - function test_decodeNInt32() public pure { + function test_NInt32() public pure { bytes memory cbor = hex"3affffffff"; // max uint32 for negative uint i; int40 value; @@ -64,7 +64,7 @@ contract NIntTest is Test { assert(value == -4294967296); // -1 - 4294967295 } - function test_decodeNInt64() public pure { + function test_NInt64() public pure { bytes memory cbor = hex"3bffffffffffffffff"; // max uint64 for negative uint i; int72 value; @@ -72,27 +72,36 @@ contract NIntTest is Test { assert(value == -18446744073709551616); // -1 - 18446744073709551615 } - function test_decodeSmallNInts() public pure { - bytes memory cbor = hex"20"; // minor literal -1 + function test_NInt8_0() public pure { + bytes memory cbor = hex"20"; // 0 minor literal uint i; int16 value; (i, value) = cbor.NInt8(0); assert(value == -1); + } - cbor = hex"21"; // minor literal -2 + function test_NInt8_1() public pure { + bytes memory cbor = hex"21"; // 1 minor literal + uint i; + int16 value; (i, value) = cbor.NInt8(0); assert(value == -2); } - function testFail_outOfBoundsNInt16() public pure { + function testFail_NInt16_too_long() public pure { bytes memory cbor = hex"3a00010000"; // uint32 value - uint i; - int24 value; - (i, value) = cbor.NInt16(0); // Should fail as value exceeds int16 + cbor.NInt16(0); // Should fail as value exceeds int16 } - function testFail_badInt() public pure { + function testFail_NInt16_invalid() public pure { bytes memory cbor = hex"f4"; - cbor.Int(0); + cbor.NInt16(0); + } + + function test_NInt() public pure { + bytes memory cbor = hex"3bffff"; + uint i; + int72 value; + (i, value) = cbor.NInt(0); } } diff --git a/test/Simple.t.sol b/test/Simple.t.sol index 0cfe803..e197c1f 100644 --- a/test/Simple.t.sol +++ b/test/Simple.t.sol @@ -8,7 +8,7 @@ using ReadCbor for bytes; /// @author turbocrime contract SimpleTest is Test { - function test_decodeFalse() public pure { + function test_Boolean_false() public pure { bytes memory cbor = hex"f4"; uint i; bool value; @@ -16,7 +16,7 @@ contract SimpleTest is Test { assert(value == false); } - function test_decodeTrue() public pure { + function test_Boolean_true() public pure { bytes memory cbor = hex"f5"; uint i; bool value; @@ -24,7 +24,7 @@ contract SimpleTest is Test { assert(value == true); } - function testFail_decodeBool() public pure { + function testFail_Boolean_invalid() public pure { bytes memory cbor = hex"f6"; uint i; bool value; diff --git a/test/String.t.sol b/test/String.t.sol index 497652d..83fd3e0 100644 --- a/test/String.t.sol +++ b/test/String.t.sol @@ -8,18 +8,7 @@ using ReadCbor for bytes; /// @author turbocrime contract StringTest is Test { - // Additional string tests - function test_decodeMediumString() public pure { - // String with 24 bytes (just above the threshold for one-byte length encoding) - bytes memory cbor = hex"7818484848484848484848484848484848484848484848484848"; // 24 times 'H' - uint i; - string memory value; - (i, value) = cbor.String(0); - assert(bytes(value).length == 24); - } - - // Test string handling - function test_decodeEmptyString() public pure { + function test_String_empty() public pure { bytes memory cbor = hex"60"; // zero-length string in CBOR uint i; string memory value; @@ -27,7 +16,7 @@ contract StringTest is Test { assert(bytes(value).length == 0); } - function test_decodeShortString() public pure { + function test_String_short() public pure { // String with 23 bytes (just below the threshold for an extended header) bytes memory cbor = hex"77414141414141414141414141414141414141414141414141"; uint i; @@ -36,7 +25,7 @@ contract StringTest is Test { assert(bytes(value).length == 23); } - function test_decodeLongString() public pure { + function test_String_extended() public pure { // String with 24 bytes (just at the threshold for an extended header) bytes memory cbor = hex"7741414141414141414141414141414141414141414141414141"; uint i; @@ -57,17 +46,16 @@ contract StringTest is Test { assert(value == "a"); } - function testFail_String32_long() public pure { + function testFail_String32_too_long() public pure { // 33 characters "thisisquitealongstringisuppose..." bytes memory cbor = hex"78217468697369737175697465616C6F6E67737472696E6769737570706F73652E2E2E"; uint i; bytes32 value; uint8 len; (i, value, len) = cbor.String32(0); - assert(i == cbor.length); assert(len == 33); // missing the last character - assert(value == bytes32("thisisquitealongstringisuppose..")); + assert(value != bytes32("thisisquitealongstringisuppose..")); } function testFail_String32_parameter() public pure { @@ -87,7 +75,7 @@ contract StringTest is Test { function testFail_skipString() public pure { bytes memory cbor = hex"50"; uint i = cbor.skipString(0); - assert(i == cbor.length); + assert(cbor[i] == cbor[i]); } function test_String1() public pure { @@ -99,11 +87,10 @@ contract StringTest is Test { assert(value == bytes1("a")); } - function testFail_String1() public pure { + function testFail_String1_empty() public pure { bytes memory cbor = hex"60"; uint i; bytes1 value; (i, value) = cbor.String1(0); - assert(i == cbor.length); } } diff --git a/test/Tag.t.sol b/test/Tag.t.sol index 46d496d..fbce9f2 100644 --- a/test/Tag.t.sol +++ b/test/Tag.t.sol @@ -8,7 +8,7 @@ using ReadCbor for bytes; /// @author turbocrime contract TagTest is Test { - function test_decodeTag() public pure { + function test_Tag() public pure { bytes memory cbor = hex"c0"; // Tag(0) uint i; uint64 tag; @@ -17,20 +17,20 @@ contract TagTest is Test { assert(tag == 0); } - function test_decodeExpectedTag() public pure { + function test_Tag_expected() public pure { bytes memory cbor = hex"c0"; // Tag(0) uint i; i = cbor.Tag(i, 0); assert(i == cbor.length); } - function testFail_unexpectedTag() public pure { + function testFail_Tag_unexpected() public pure { bytes memory cbor = hex"c0"; // Tag(0) uint i; cbor.Tag(i, 1); } - function testFail_notTag() public pure { + function testFail_Tag_invalid() public pure { bytes memory cbor = hex"df"; // Not a tag uint i; cbor.Tag(i); diff --git a/test/UInt.t.sol b/test/UInt.t.sol index 8c28300..7b0299e 100644 --- a/test/UInt.t.sol +++ b/test/UInt.t.sol @@ -9,7 +9,7 @@ using ReadCbor for bytes; /// @author turbocrime contract UIntTest is Test { // Test basic integer types - function test_decodeShortUInt8() public pure { + function test_UInt8_short() public pure { bytes memory cbor = hex"17"; // max minor literal uint8 uint i; uint8 value; @@ -17,7 +17,7 @@ contract UIntTest is Test { assert(value == 0x17); } - function test_decodeLongUInt8() public pure { + function test_UInt8_extended() public pure { bytes memory cbor = hex"1818"; // minimum header extension uint8 uint i; uint8 value; @@ -25,7 +25,7 @@ contract UIntTest is Test { assert(value == 0x18); } - function testFail_invalidUInt8() public pure { + function testFail_UInt8_invalid() public pure { bytes memory cbor = hex"1817"; // extended header too small uint i; uint8 value; @@ -33,7 +33,7 @@ contract UIntTest is Test { assert(value == 0x17); } - function test_decodeUInt8() public pure { + function test_UInt8_max() public pure { bytes memory cbor = hex"18ff"; // max uint8 uint i; uint8 value; @@ -41,14 +41,14 @@ contract UIntTest is Test { assert(value == 0xff); } - function testFail_notUInt8() public pure { + function testFail_UInt8_too_long() public pure { bytes memory cbor = hex"19ffff"; // uint16 value uint i; uint8 value; (i, value) = cbor.UInt8(0); // Should fail as value exceeds uint8 } - function test_decodeUInt16() public pure { + function test_UInt16_max() public pure { bytes memory cbor = hex"19ffff"; // max uint16 uint i; uint16 value; @@ -56,7 +56,7 @@ contract UIntTest is Test { assert(value == 0xffff); } - function test_decodeUInt32() public pure { + function test_UInt32_max() public pure { bytes memory cbor = hex"1affffffff"; // max uint32 uint i; uint32 value; @@ -64,7 +64,7 @@ contract UIntTest is Test { assert(value == 0xffff_ffff); } - function test_decodeUInt64() public pure { + function test_UInt64_max() public pure { bytes memory cbor = hex"1bffffffffffffffff"; // max uint64 uint i; uint64 value; @@ -73,19 +73,31 @@ contract UIntTest is Test { } // Additional integer tests - function test_decodeSmallInts() public pure { + function test_UInt8_0() public pure { bytes memory cbor = hex"00"; // minor literal zero uint i; uint8 value; (i, value) = cbor.UInt8(0); assert(value == 0); + } - cbor = hex"01"; // minor literal 1 + function test_UInt8_1() public pure { + bytes memory cbor = hex"01"; // minor literal 1 + uint i; + uint8 value; (i, value) = cbor.UInt8(0); assert(value == 1); } - function testFail_outOfBoundsUInt16() public pure { + function test_UInt() public pure { + bytes memory cbor = hex"19ffff"; // max uint16 + uint i; + uint value; + (i, value) = cbor.UInt(0); + assert(value == 0xffff); + } + + function testFail_UInt16_too_long() public pure { bytes memory cbor = hex"1a00010000"; // uint32 value uint i; uint16 value; diff --git a/test/tags/ReadBignum.t.sol b/test/tags/Bignum.t.sol similarity index 99% rename from test/tags/ReadBignum.t.sol rename to test/tags/Bignum.t.sol index 3000515..64b4542 100644 --- a/test/tags/ReadBignum.t.sol +++ b/test/tags/Bignum.t.sol @@ -23,7 +23,7 @@ function intHead(uint64 num) pure returns (bytes memory) { } } -contract ReadBignum_Test is Test { +contract BignumTest is Test { using ReadCbor for bytes; using ReadBignum for bytes; diff --git a/test/tags/ReadCidSha256.t.sol b/test/tags/CidSha256.t.sol similarity index 98% rename from test/tags/ReadCidSha256.t.sol rename to test/tags/CidSha256.t.sol index 2011f86..98f0b87 100644 --- a/test/tags/ReadCidSha256.t.sol +++ b/test/tags/CidSha256.t.sol @@ -7,7 +7,7 @@ import "../../src/tags/ReadCidSha256.sol"; using ReadCbor for bytes; using ReadCidSha256 for bytes; -contract ReadCidSha256_Test is Test { +contract CidSha256Test is Test { bytes9 private constant dagHead = hex"D82A58250001711220"; bytes private constant constantCidCbor = From 703219ff1a99fcde525380fc428b6078ec79242c Mon Sep 17 00:00:00 2001 From: turbocrime Date: Wed, 18 Dec 2024 19:24:26 -0800 Subject: [PATCH 2/8] use foundry gas snapshots --- .gas-snapshot | 100 +--------------- .github/workflows/test.yml | 2 +- foundry.toml | 6 + snapshots/ArrayTest.json | 7 ++ snapshots/BignumTest.json | 11 ++ snapshots/BytesTest.json | 7 ++ snapshots/CidSha256Test.json | 5 + snapshots/IntTest.json | 8 ++ snapshots/MapTest.json | 6 + snapshots/NIntTest.json | 11 ++ snapshots/PeekTest.json | 28 +++++ snapshots/SimpleTest.json | 6 + snapshots/StringTest.json | 8 ++ snapshots/TagTest.json | 4 + snapshots/UIntTest.json | 11 ++ test/Array.t.sol | 33 ++++-- test/Bytes.t.sol | 33 ++++-- test/Int.t.sol | 47 +++++--- test/Map.t.sol | 26 ++++- test/NInt.t.sol | 45 +++++-- test/Peek.t.sol | 221 +++++++++++++++++++++++------------ test/Simple.t.sol | 26 +++-- test/String.t.sol | 36 +++++- test/Tag.t.sol | 14 ++- test/UInt.t.sol | 54 +++++++-- test/tags/Bignum.t.sol | 59 +++++++--- test/tags/CidSha256.t.sol | 32 +++-- 27 files changed, 577 insertions(+), 269 deletions(-) create mode 100644 snapshots/ArrayTest.json create mode 100644 snapshots/BignumTest.json create mode 100644 snapshots/BytesTest.json create mode 100644 snapshots/CidSha256Test.json create mode 100644 snapshots/IntTest.json create mode 100644 snapshots/MapTest.json create mode 100644 snapshots/NIntTest.json create mode 100644 snapshots/PeekTest.json create mode 100644 snapshots/SimpleTest.json create mode 100644 snapshots/StringTest.json create mode 100644 snapshots/TagTest.json create mode 100644 snapshots/UIntTest.json diff --git a/.gas-snapshot b/.gas-snapshot index a3309cf..31d13d9 100644 --- a/.gas-snapshot +++ b/.gas-snapshot @@ -1,29 +1,3 @@ -ArrayTest:test_Array_empty() (gas: 560) -ArrayTest:test_Array_large() (gas: 607) -ArrayTest:test_Array_mixed() (gas: 2071) -ArrayTest:test_Array_nested() (gas: 2280) -ArrayTest:test_Array_single() (gas: 964) -BignumTest:test_Integer() (gas: 12559) -BignumTest:test_NInt256_max() (gas: 1697) -BignumTest:test_NInt256_middle() (gas: 2134) -BignumTest:test_NInt256_multi() (gas: 1190) -BignumTest:test_NInt256_random(int256) (runs: 256, μ: 5100, ~: 5100) -BignumTest:test_NInt256_single() (gas: 1191) -BignumTest:test_UInt256_max() (gas: 1502) -BignumTest:test_UInt256_middle() (gas: 1946) -BignumTest:test_UInt256_multi() (gas: 1068) -BignumTest:test_UInt256_random(uint256) (runs: 256, μ: 1561, ~: 1561) -BignumTest:test_UInt256_single() (gas: 1364) -BytesTest:test_Bytes32_short() (gas: 802) -BytesTest:test_Bytes_empty() (gas: 761) -BytesTest:test_Bytes_extended() (gas: 851) -BytesTest:test_Bytes_short() (gas: 779) -BytesTest:test_skipBytes() (gas: 653) -CidSha256Test:test_Cid() (gas: 521) -CidSha256Test:test_Cid_multicodec_raw() (gas: 449) -CidSha256Test:test_Cid_random(uint256) (runs: 256, μ: 3520, ~: 3520) -CidSha256Test:test_NullableCid_nullCbor() (gas: 519) -CidSha256Test:test_NullableCid_random(uint256) (runs: 256, μ: 885, ~: 889) ComparisonTest:test_decodeArrayU8_CBORDecoder() (gas: 5274) ComparisonTest:test_decodeArrayU8_ReadCbor() (gas: 2334) ComparisonTest:test_decodeFalse_CBORDecoder() (gas: 916) @@ -39,76 +13,4 @@ ComparisonTest:test_decodeStringWithWeirdChar_ReadCbor() (gas: 884) ComparisonTest:test_decodeString_CBORDecoder() (gas: 3869) ComparisonTest:test_decodeString_ReadCbor() (gas: 957) ComparisonTest:test_decodeTrue_CBORDecoder() (gas: 937) -ComparisonTest:test_decodeTrue_ReadCbor() (gas: 483) -HeaderTest:test_header() (gas: 651) -HeaderTest:test_header32_u16() (gas: 726) -HeaderTest:test_header32_u32() (gas: 700) -IntTest:test_Int_max() (gas: 835) -IntTest:test_Int_min() (gas: 948) -IntTest:test_Int_neg_one() (gas: 787) -IntTest:test_Int_nint16() (gas: 891) -IntTest:test_Int_uint16() (gas: 778) -IntTest:test_Int_zero() (gas: 695) -MapTest:test_Map_empty() (gas: 559) -MapTest:test_Map_nested() (gas: 6640) -MapTest:test_Map_nested2() (gas: 3561) -MapTest:test_Map_single() (gas: 1742) -NIntTest:test_NInt() (gas: 874) -NIntTest:test_NInt16() (gas: 874) -NIntTest:test_NInt32() (gas: 947) -NIntTest:test_NInt64() (gas: 938) -NIntTest:test_NInt8_0() (gas: 731) -NIntTest:test_NInt8_1() (gas: 666) -NIntTest:test_NInt8_long() (gas: 789) -NIntTest:test_NInt8_max() (gas: 766) -NIntTest:test_NInt8_short() (gas: 667) -PeekTest:test_isArray_false() (gas: 317) -PeekTest:test_isArray_true() (gas: 312) -PeekTest:test_isBool_false() (gas: 305) -PeekTest:test_isBool_true() (gas: 364) -PeekTest:test_isBytes_false() (gas: 348) -PeekTest:test_isBytes_true() (gas: 311) -PeekTest:test_isInt_false() (gas: 326) -PeekTest:test_isInt_true() (gas: 488) -PeekTest:test_isMap_false() (gas: 304) -PeekTest:test_isMap_true() (gas: 334) -PeekTest:test_isNInt_false() (gas: 353) -PeekTest:test_isNInt_true() (gas: 312) -PeekTest:test_isNull_false() (gas: 376) -PeekTest:test_isNull_true() (gas: 334) -PeekTest:test_isString_false() (gas: 328) -PeekTest:test_isString_true() (gas: 313) -PeekTest:test_isTag_expect_badminor() (gas: 858) -PeekTest:test_isTag_expect_false() (gas: 468) -PeekTest:test_isTag_expect_rand_16(uint16) (runs: 256, μ: 766, ~: 766) -PeekTest:test_isTag_expect_rand_64(uint32) (runs: 256, μ: 777, ~: 777) -PeekTest:test_isTag_expect_rand_64(uint64) (runs: 256, μ: 750, ~: 750) -PeekTest:test_isTag_expect_true() (gas: 459) -PeekTest:test_isTag_false() (gas: 326) -PeekTest:test_isTag_false_expect() (gas: 413) -PeekTest:test_isTag_true() (gas: 333) -PeekTest:test_isUInt_false() (gas: 349) -PeekTest:test_isUInt_true() (gas: 370) -PeekTest:test_isUndefined_false() (gas: 375) -PeekTest:test_isUndefined_true() (gas: 303) -SimpleTest:test_Boolean_false() (gas: 446) -SimpleTest:test_Boolean_true() (gas: 482) -SimpleTest:test_skipNull() (gas: 412) -SimpleTest:test_skipUndefined() (gas: 433) -StringTest:test_String1() (gas: 457) -StringTest:test_String32_short() (gas: 849) -StringTest:test_String_empty() (gas: 755) -StringTest:test_String_extended() (gas: 799) -StringTest:test_String_short() (gas: 778) -StringTest:test_skipString() (gas: 654) -TagTest:test_Tag() (gas: 644) -TagTest:test_Tag_expected() (gas: 671) -UIntTest:test_UInt() (gas: 726) -UIntTest:test_UInt16_max() (gas: 752) -UIntTest:test_UInt32_max() (gas: 790) -UIntTest:test_UInt64_max() (gas: 805) -UIntTest:test_UInt8_0() (gas: 579) -UIntTest:test_UInt8_1() (gas: 577) -UIntTest:test_UInt8_extended() (gas: 657) -UIntTest:test_UInt8_max() (gas: 679) -UIntTest:test_UInt8_short() (gas: 533) \ No newline at end of file +ComparisonTest:test_decodeTrue_ReadCbor() (gas: 483) \ No newline at end of file diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 64b7222..add0128 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -46,5 +46,5 @@ jobs: - name: Run snapshot run: | - forge snapshot --match-test test_ --check + forge snapshot --match-path "test/comparison/*" --check id: test-committed \ No newline at end of file diff --git a/foundry.toml b/foundry.toml index edfabe3..7c6fe95 100644 --- a/foundry.toml +++ b/foundry.toml @@ -5,6 +5,12 @@ libs = ["lib"] optimize = true optimizer_runs = 1000000 +[profile.test-no-ir] +via-ir = false + +[profile.test-via-ir] +via-ir = true + # See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options [fmt] diff --git a/snapshots/ArrayTest.json b/snapshots/ArrayTest.json new file mode 100644 index 0000000..2a87de9 --- /dev/null +++ b/snapshots/ArrayTest.json @@ -0,0 +1,7 @@ +{ + "Array_empty": "235", + "Array_large": "235", + "Array_mixed": "1722", + "Array_nested": "1960", + "Array_single": "628" +} \ No newline at end of file diff --git a/snapshots/BignumTest.json b/snapshots/BignumTest.json new file mode 100644 index 0000000..535509e --- /dev/null +++ b/snapshots/BignumTest.json @@ -0,0 +1,11 @@ +{ + "Integer": "235", + "NInt256_max": "914", + "NInt256_middle": "235", + "NInt256_multi": "816", + "NInt256_single": "816", + "UInt256_max": "770", + "UInt256_middle": "672", + "UInt256_multi": "672", + "UInt256_single": "672" +} \ No newline at end of file diff --git a/snapshots/BytesTest.json b/snapshots/BytesTest.json new file mode 100644 index 0000000..1ff3fde --- /dev/null +++ b/snapshots/BytesTest.json @@ -0,0 +1,7 @@ +{ + "Bytes32_short": "422", + "Bytes_empty": "408", + "Bytes_extended": "497", + "Bytes_short": "445", + "skipBytes": "306" +} \ No newline at end of file diff --git a/snapshots/CidSha256Test.json b/snapshots/CidSha256Test.json new file mode 100644 index 0000000..a50b208 --- /dev/null +++ b/snapshots/CidSha256Test.json @@ -0,0 +1,5 @@ +{ + "Cid": "251", + "Cid_multicodec_raw": "202", + "NullableCid_nullCbor": "198" +} \ No newline at end of file diff --git a/snapshots/IntTest.json b/snapshots/IntTest.json new file mode 100644 index 0000000..3eafc68 --- /dev/null +++ b/snapshots/IntTest.json @@ -0,0 +1,8 @@ +{ + "Int_max": "495", + "Int_min": "630", + "Int_neg_one": "1111", + "Int_nint16": "572", + "Int_uint16": "437", + "Int_zero": "358" +} \ No newline at end of file diff --git a/snapshots/MapTest.json b/snapshots/MapTest.json new file mode 100644 index 0000000..397024c --- /dev/null +++ b/snapshots/MapTest.json @@ -0,0 +1,6 @@ +{ + "Map_empty": "249", + "Map_nested": "6269", + "Map_nested2": "3236", + "Map_single": "1437" +} \ No newline at end of file diff --git a/snapshots/NIntTest.json b/snapshots/NIntTest.json new file mode 100644 index 0000000..ab4aeef --- /dev/null +++ b/snapshots/NIntTest.json @@ -0,0 +1,11 @@ +{ + "NInt": "556", + "NInt16": "536", + "NInt32": "565", + "NInt64": "600", + "NInt8_0": "332", + "NInt8_1": "332", + "NInt8_long": "431", + "NInt8_max": "430", + "NInt8_short": "333" +} \ No newline at end of file diff --git a/snapshots/PeekTest.json b/snapshots/PeekTest.json new file mode 100644 index 0000000..e0e4374 --- /dev/null +++ b/snapshots/PeekTest.json @@ -0,0 +1,28 @@ +{ + "isArray_false": "0", + "isArray_true": "651", + "isBool_false_undefinedCbor": "0", + "isBool_true_falseCbor": "651", + "isBool_true_trueCbor": "648", + "isBytes_false": "0", + "isBytes_true": "651", + "isInt_false": "0", + "isInt_true_negativeCbor": "648", + "isInt_true_unsignedCbor": "699", + "isMap_false": "0", + "isMap_true": "651", + "isNInt_false": "60", + "isNInt_true": "651", + "isNull_false": "59", + "isNull_true": "651", + "isString_false": "0", + "isString_true": "651", + "isTag_expect_false": "181", + "isTag_expect_true": "794", + "isTag_false": "0", + "isTag_true": "651", + "isUInt_false": "0", + "isUInt_true": "681", + "isUndefined_false": "59", + "isUndefined_true": "651" +} \ No newline at end of file diff --git a/snapshots/SimpleTest.json b/snapshots/SimpleTest.json new file mode 100644 index 0000000..019d025 --- /dev/null +++ b/snapshots/SimpleTest.json @@ -0,0 +1,6 @@ +{ + "Boolean_false": "105", + "Boolean_true": "728", + "skipNull": "135", + "skipUndefined": "135" +} \ No newline at end of file diff --git a/snapshots/StringTest.json b/snapshots/StringTest.json new file mode 100644 index 0000000..f49c4f6 --- /dev/null +++ b/snapshots/StringTest.json @@ -0,0 +1,8 @@ +{ + "String1": "97", + "String32_short": "422", + "String_empty": "408", + "String_extended": "445", + "String_short": "445", + "skipString": "306" +} \ No newline at end of file diff --git a/snapshots/TagTest.json b/snapshots/TagTest.json new file mode 100644 index 0000000..9f006fa --- /dev/null +++ b/snapshots/TagTest.json @@ -0,0 +1,4 @@ +{ + "Tag": "293", + "Tag_expected": "314" +} \ No newline at end of file diff --git a/snapshots/UIntTest.json b/snapshots/UIntTest.json new file mode 100644 index 0000000..61c8b86 --- /dev/null +++ b/snapshots/UIntTest.json @@ -0,0 +1,11 @@ +{ + "UInt": "385", + "UInt16_max": "418", + "UInt32_max": "436", + "UInt64_max": "472", + "UInt8_0": "204", + "UInt8_1": "204", + "UInt8_extended": "303", + "UInt8_max": "302", + "UInt8_short": "205" +} \ No newline at end of file diff --git a/test/Array.t.sol b/test/Array.t.sol index 888e5bf..a4739e0 100644 --- a/test/Array.t.sol +++ b/test/Array.t.sol @@ -7,26 +7,32 @@ import "../src/ReadCbor.sol"; using ReadCbor for bytes; contract ArrayTest is Test { - // Test array handling - function test_Array_empty() public pure { + function test_Array_empty() public { bytes memory cbor = hex"80"; // Empty array in CBOR uint i; uint32 len; + + vm.startSnapshotGas("Array_empty"); (i, len) = cbor.Array(i); + vm.stopSnapshotGas(); + assert(len == 0); } - function test_Array_large() public pure { + function test_Array_large() public { // Array with 23 elements (just below the threshold for extended header) bytes memory cbor = hex"97010101010101010101010101010101010101010101010101"; uint i; uint32 len; + + vm.startSnapshotGas("Array_large"); (i, len) = cbor.Array(i); + vm.stopSnapshotGas(); + assert(len == 23); } - // Test nested structures - function test_Array_nested() public pure { + function test_Array_nested() public { // [[1, 2], [3, 4]] bytes memory cbor = hex"82820102820304"; uint i; @@ -34,6 +40,8 @@ contract ArrayTest is Test { uint innerLen; uint8 value; + vm.startSnapshotGas("Array_nested"); + (i, outerLen) = cbor.Array(0); assert(outerLen == 2); @@ -54,31 +62,38 @@ contract ArrayTest is Test { (i, value) = cbor.UInt8(i); assert(value == 4); + + vm.stopSnapshotGas(); } - function test_Array_single() public pure { + function test_Array_single() public { bytes memory cbor = hex"8118ff"; // [0xff] uint i; uint32 len; uint8 value; + vm.startSnapshotGas("Array_single"); + (i, len) = cbor.Array(0); assert(len == 1); (i, value) = cbor.UInt8(i); assert(value == 0xff); + + vm.stopSnapshotGas(); } - function test_Array_mixed() public pure { + function test_Array_mixed() public { // [1, "a", [2]] bytes memory cbor = hex"830161618102"; - uint i; uint32 len; uint8 value; string memory strValue; uint innerLen; + vm.startSnapshotGas("Array_mixed"); + (i, len) = cbor.Array(i); assert(len == 3); @@ -93,5 +108,7 @@ contract ArrayTest is Test { (i, value) = cbor.UInt8(i); assert(value == 2); + + vm.stopSnapshotGas(); } } diff --git a/test/Bytes.t.sol b/test/Bytes.t.sol index 8c261d6..b8f04e3 100644 --- a/test/Bytes.t.sol +++ b/test/Bytes.t.sol @@ -8,40 +8,53 @@ using ReadCbor for bytes; /// @author turbocrime contract BytesTest is Test { - function test_Bytes_empty() public pure { + function test_Bytes_empty() public { bytes memory cbor = hex"40"; // zero-length bytes in CBOR uint i; bytes memory value; + + vm.startSnapshotGas("Bytes_empty"); (i, value) = cbor.Bytes(0); + vm.stopSnapshotGas(); + assert(i == cbor.length); assert(value.length == 0); } - function test_Bytes_short() public pure { - // Bytes with 23 bytes (just below the threshold for an extended header) + function test_Bytes_short() public { bytes memory cbor = hex"57000102030405060708090a0b0c0d0e0f1011121314151617"; uint i; bytes memory value; + + vm.startSnapshotGas("Bytes_short"); (i, value) = cbor.Bytes(0); + vm.stopSnapshotGas(); + assert(value.length == 23); } - function test_Bytes_extended() public pure { - // Bytes with 24 bytes (just at the threshold for an extended header) + function test_Bytes_extended() public { bytes memory cbor = hex"5818000102030405060708090a0b0c0d0e0f101112131415161718"; uint i; bytes memory value; + + vm.startSnapshotGas("Bytes_extended"); (i, value) = cbor.Bytes(0); + vm.stopSnapshotGas(); + assert(value.length == 24); } - function test_Bytes32_short() public pure { - // 1 byte of data + function test_Bytes32_short() public { bytes memory cbor = hex"4100"; uint i; bytes32 value; uint8 len; + + vm.startSnapshotGas("Bytes32_short"); (i, value, len) = cbor.Bytes32(0); + vm.stopSnapshotGas(); + assert(i == cbor.length); assert(len == 1); assert(value == bytes32(hex"00")); @@ -67,9 +80,13 @@ contract BytesTest is Test { (i, value, len) = cbor.Bytes32(0, 33); } - function test_skipBytes() public pure { + function test_skipBytes() public { bytes memory cbor = hex"4100"; + + vm.startSnapshotGas("skipBytes"); uint i = cbor.skipBytes(0); + vm.stopSnapshotGas(); + assert(i == cbor.length); } diff --git a/test/Int.t.sol b/test/Int.t.sol index de155ff..ca7a675 100644 --- a/test/Int.t.sol +++ b/test/Int.t.sol @@ -8,58 +8,77 @@ using ReadCbor for bytes; contract IntTest is Test { // Test generic Int method - function test_Int_zero() public pure { - bytes memory cbor = hex"00"; + function test_Int() public { + bytes memory cborUInt_Zero = hex"00"; + bytes memory cborNInt_NegOne = hex"20"; uint i; int value; - (i, value) = cbor.Int(0); + + vm.startSnapshotGas("Int_zero"); + (i, value) = cborUInt_Zero.Int(0); + vm.stopSnapshotGas(); assert(value == 0); - } - function test_Int_neg_one() public pure { - bytes memory cbor = hex"20"; - uint i; - int value; - (i, value) = cbor.Int(0); + vm.startSnapshotGas("Int_neg_one"); + (i, value) = cborNInt_NegOne.Int(0); + vm.stopSnapshotGas(); assert(value == -1); } - function test_Int_uint16() public pure { + function test_Int_uint16() public { bytes memory cbor = hex"19FFFF"; uint i; int value; + + vm.startSnapshotGas("Int_uint16"); (i, value) = cbor.Int(0); + vm.stopSnapshotGas(); assert(value == 0xFFFF); } - function test_Int_nint16() public pure { + function test_Int_nint16() public { bytes memory cbor = hex"39FFFF"; uint i; int value; + + vm.startSnapshotGas("Int_nint16"); (i, value) = cbor.Int(0); + vm.stopSnapshotGas(); + assert(value == -1 - 0xFFFF); } - function test_Int_max() public pure { + function test_Int_max() public { bytes memory cbor = hex"1bffffffffffffffff"; uint i; int value; + + vm.startSnapshotGas("Int_max"); (i, value) = cbor.Int(0); + vm.stopSnapshotGas(); + assert(value == 0xFFFF_FFFF_FFFF_FFFF); } - function test_Int_min() public pure { + function test_Int_min() public { bytes memory cbor = hex"3bFFFFFFFFFFFFFFFF"; uint i; int value; + + vm.startSnapshotGas("Int_min"); (i, value) = cbor.Int(0); + vm.stopSnapshotGas(); + assert(value == -1 - 0xFFFF_FFFF_FFFF_FFFF); } - function testFail_Int_not() public pure { + function testFail_Int_not() public { bytes memory cbor = hex"f7"; uint i; int value; + + vm.startSnapshotGas("Int_not"); (i, value) = cbor.Int(0); + vm.stopSnapshotGas(); } } diff --git a/test/Map.t.sol b/test/Map.t.sol index 5f524bc..b9fcce9 100644 --- a/test/Map.t.sol +++ b/test/Map.t.sol @@ -8,17 +8,19 @@ using ReadCbor for bytes; /// @author turbocrime contract MapTest is Test { - // Test map handling - function test_Map_empty() public pure { + function test_Map_empty() public { bytes memory cbor = hex"a0"; // Empty map in CBOR uint i; uint len; + + vm.startSnapshotGas("Map_empty"); (i, len) = cbor.Map(0); + vm.stopSnapshotGas(); + assert(len == 0); } - // Additional map tests - function test_Map_single() public pure { + function test_Map_single() public { bytes memory cbor = hex"a161618102"; // {"a": [2]} uint i; uint len; @@ -26,6 +28,8 @@ contract MapTest is Test { uint arrayLen; uint8 value; + vm.startSnapshotGas("Map_single"); + (i, len) = cbor.Map(i); assert(len == 1); @@ -36,9 +40,11 @@ contract MapTest is Test { assert(arrayLen == 1); (i, value) = cbor.UInt8(i); assert(value == 2); + + vm.stopSnapshotGas(); } - function test_Map_nested() public pure { + function test_Map_nested() public { // {"a": {"b": 1, "c": 2}, "d": 3} bytes memory cbor = hex"a26161a2616201616302616403"; uint i; @@ -47,6 +53,8 @@ contract MapTest is Test { bytes32 key; uint8 value; + vm.startSnapshotGas("Map_nested"); + (i, outerLen) = cbor.Map(0); assert(outerLen == 2); @@ -99,9 +107,11 @@ contract MapTest is Test { assert(key == "d"); (i, value) = cbor.UInt8(i); assert(value == 3); + + vm.stopSnapshotGas(); } - function test_Map_nested2() public pure { + function test_Map_nested2() public { // {"a": {"b": {"c": [1, 2, 3]}}} bytes memory cbor = hex"a16161a16162a1616383010203"; uint i; @@ -110,6 +120,8 @@ contract MapTest is Test { uint arrayLen; uint8 value; + vm.startSnapshotGas("Map_nested2"); + (i, len) = cbor.Map(0); assert(len == 1); @@ -139,5 +151,7 @@ contract MapTest is Test { (i, value) = cbor.UInt8(i); assert(value == 3); + + vm.stopSnapshotGas(); } } diff --git a/test/NInt.t.sol b/test/NInt.t.sol index d6d3c8f..1842cab 100644 --- a/test/NInt.t.sol +++ b/test/NInt.t.sol @@ -9,19 +9,25 @@ using ReadCbor for bytes; /// @author turbocrime contract NIntTest is Test { // Test basic integer types - function test_NInt8_short() public pure { + function test_NInt8_short() public { bytes memory cbor = hex"37"; // max minor literal uint8 for negative uint i; int16 value; + + vm.startSnapshotGas("NInt8_short"); (i, value) = cbor.NInt8(i); + vm.stopSnapshotGas(); assert(value == -24); // -1 - 23 } - function test_NInt8_long() public pure { + function test_NInt8_long() public { bytes memory cbor = hex"3818"; // minimum header extension uint8 for negative uint i; int16 value; + + vm.startSnapshotGas("NInt8_long"); (i, value) = cbor.NInt8(i); + vm.stopSnapshotGas(); assert(value == -25); // -1 - 24 } @@ -33,11 +39,14 @@ contract NIntTest is Test { assert(value == -24); } - function test_NInt8_max() public pure { + function test_NInt8_max() public { bytes memory cbor = hex"38ff"; // max uint8 for negative uint i; int16 value; + + vm.startSnapshotGas("NInt8_max"); (i, value) = cbor.NInt8(0); + vm.stopSnapshotGas(); assert(value == -256); // -1 - 255 } @@ -48,43 +57,58 @@ contract NIntTest is Test { (i, value) = cbor.NInt8(0); // Should fail as value exceeds int8 } - function test_NInt16() public pure { + function test_NInt16() public { bytes memory cbor = hex"39ffff"; // max uint16 for negative uint i; int24 value; + + vm.startSnapshotGas("NInt16"); (i, value) = cbor.NInt16(0); + vm.stopSnapshotGas(); assert(value == -65536); // -1 - 65535 } - function test_NInt32() public pure { + function test_NInt32() public { bytes memory cbor = hex"3affffffff"; // max uint32 for negative uint i; int40 value; + + vm.startSnapshotGas("NInt32"); (i, value) = cbor.NInt32(0); + vm.stopSnapshotGas(); assert(value == -4294967296); // -1 - 4294967295 } - function test_NInt64() public pure { + function test_NInt64() public { bytes memory cbor = hex"3bffffffffffffffff"; // max uint64 for negative uint i; int72 value; + + vm.startSnapshotGas("NInt64"); (i, value) = cbor.NInt64(0); + vm.stopSnapshotGas(); assert(value == -18446744073709551616); // -1 - 18446744073709551615 } - function test_NInt8_0() public pure { + function test_NInt8_0() public { bytes memory cbor = hex"20"; // 0 minor literal uint i; int16 value; + + vm.startSnapshotGas("NInt8_0"); (i, value) = cbor.NInt8(0); + vm.stopSnapshotGas(); assert(value == -1); } - function test_NInt8_1() public pure { + function test_NInt8_1() public { bytes memory cbor = hex"21"; // 1 minor literal uint i; int16 value; + + vm.startSnapshotGas("NInt8_1"); (i, value) = cbor.NInt8(0); + vm.stopSnapshotGas(); assert(value == -2); } @@ -98,10 +122,13 @@ contract NIntTest is Test { cbor.NInt16(0); } - function test_NInt() public pure { + function test_NInt() public { bytes memory cbor = hex"3bffff"; uint i; int72 value; + + vm.startSnapshotGas("NInt"); (i, value) = cbor.NInt(0); + vm.stopSnapshotGas(); } } diff --git a/test/Peek.t.sol b/test/Peek.t.sol index cb081cd..7158155 100644 --- a/test/Peek.t.sol +++ b/test/Peek.t.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.28; -import {Test, console} from "forge-std/Test.sol"; +import "forge-std/Test.sol"; import "../src/ReadCbor.sol"; using ReadCbor for bytes; @@ -19,125 +19,196 @@ contract PeekTest is Test { bytes private constant trueCbor = hex"f5"; bytes private constant undefinedCbor = hex"f7"; - function test_isArray_false() public pure { - assert(!mapCbor.isArray(0)); - } + function test_isArray() public { + bool result; - function test_isArray_true() public pure { - assert(arrayCbor.isArray(0)); - } + vm.startSnapshotGas("isArray_false"); + result = mapCbor.isArray(0); + vm.stopSnapshotGas(); + assert(!result); - function test_isBool_false() public pure { - assert(!undefinedCbor.isBool(0)); + vm.startSnapshotGas("isArray_true"); + result = arrayCbor.isArray(0); + vm.stopSnapshotGas(); + assert(result); } - function test_isBool_true() public pure { - assert(falseCbor.isBool(0)); - assert(trueCbor.isBool(0)); - } + function test_isBool() public { + bool result; - function test_isBytes_false() public pure { - assert(!textCbor.isBytes(0)); - } + vm.startSnapshotGas("isBool_false_undefinedCbor"); + result = undefinedCbor.isBool(0); + vm.stopSnapshotGas(); + assert(!result); - function test_isBytes_true() public pure { - assert(bytesCbor.isBytes(0)); - } + vm.startSnapshotGas("isBool_true_falseCbor"); + result = falseCbor.isBool(0); + vm.stopSnapshotGas(); + assert(result); - function test_isInt_false() public pure { - assert(!nullCbor.isInt(0)); + vm.startSnapshotGas("isBool_true_trueCbor"); + result = trueCbor.isBool(0); + vm.stopSnapshotGas(); + assert(result); } - function test_isInt_true() public pure { - assert(unsignedCbor.isInt(0)); - assert(negativeCbor.isInt(0)); - } + function test_isBytes() public { + bool result; - function test_isMap_false() public pure { - assert(!arrayCbor.isMap(0)); - } + vm.startSnapshotGas("isBytes_false"); + result = textCbor.isBytes(0); + vm.stopSnapshotGas(); + assert(!result); - function test_isMap_true() public pure { - assert(mapCbor.isMap(0)); + vm.startSnapshotGas("isBytes_true"); + result = bytesCbor.isBytes(0); + vm.stopSnapshotGas(); + assert(result); } - function test_isNInt_false() public pure { - assert(!unsignedCbor.isNInt(0)); - } + function test_isInt() public { + bool result; - function test_isNInt_true() public pure { - assert(negativeCbor.isNInt(0)); + vm.startSnapshotGas("isInt_false"); + result = nullCbor.isInt(0); + vm.stopSnapshotGas(); + assert(!result); + + vm.startSnapshotGas("isInt_true_unsignedCbor"); + result = unsignedCbor.isInt(0); + vm.stopSnapshotGas(); + assert(result); + + vm.startSnapshotGas("isInt_true_negativeCbor"); + result = negativeCbor.isInt(0); + vm.stopSnapshotGas(); + assert(result); } - function test_isNull_false() public pure { - assert(!unsignedCbor.isNull(0)); + function test_isMap() public { + bool result; + + vm.startSnapshotGas("isMap_false"); + result = arrayCbor.isMap(0); + vm.stopSnapshotGas(); + assert(!result); + + vm.startSnapshotGas("isMap_true"); + result = mapCbor.isMap(0); + vm.stopSnapshotGas(); + assert(result); } - function test_isNull_true() public pure { - assert(nullCbor.isNull(0)); + function test_isNInt() public { + bool result; + + vm.startSnapshotGas("isNInt_false"); + result = unsignedCbor.isNInt(0); + vm.stopSnapshotGas(); + assert(!result); + + vm.startSnapshotGas("isNInt_true"); + result = negativeCbor.isNInt(0); + vm.stopSnapshotGas(); + assert(result); } - function test_isString_false() public pure { - assert(!bytesCbor.isString(0)); + function test_isNull() public { + bool result; + + vm.startSnapshotGas("isNull_false"); + result = unsignedCbor.isNull(0); + vm.stopSnapshotGas(); + assert(!result); + + vm.startSnapshotGas("isNull_true"); + result = nullCbor.isNull(0); + vm.stopSnapshotGas(); + assert(result); } - function test_isString_true() public pure { - assert(textCbor.isString(0)); + function test_isString() public { + bool result; + + vm.startSnapshotGas("isString_false"); + result = bytesCbor.isString(0); + vm.stopSnapshotGas(); + assert(!result); + + vm.startSnapshotGas("isString_true"); + result = textCbor.isString(0); + vm.stopSnapshotGas(); + assert(result); } - function test_isTag_expect_false() public pure { - assert(!tagCbor.isTag(0, 1)); + function test_isTag() public { + bool result; + + vm.startSnapshotGas("isTag_false"); + result = arrayCbor.isTag(0); + vm.stopSnapshotGas(); + assert(!result); + + vm.startSnapshotGas("isTag_true"); + result = tagCbor.isTag(0); + vm.stopSnapshotGas(); + assert(result); } - function test_isTag_expect_true() public pure { - assert(tagCbor.isTag(0, 0)); + function test_isTag_expect() public { + bool result; + + vm.startSnapshotGas("isTag_expect_false"); + result = tagCbor.isTag(0, 1); + vm.stopSnapshotGas(); + assert(!result); + + vm.startSnapshotGas("isTag_expect_true"); + result = tagCbor.isTag(0, 0); + vm.stopSnapshotGas(); + assert(result); } - function test_isTag_expect_rand_64(uint64 rand64) public pure { + function test_fuzz_isTag_expect_rand_64(uint64 rand64) public pure { bytes memory cbor = bytes.concat(bytes1(MajorTag << shiftMajor | MinorExtendU64), bytes8(rand64)); assert(cbor.isTag(0, uint64(rand64))); } - function test_isTag_expect_rand_64(uint32 rand32) public pure { + function test_fuzz_isTag_expect_rand_32(uint32 rand32) public pure { bytes memory cbor = bytes.concat(bytes1(MajorTag << shiftMajor | MinorExtendU32), bytes4(rand32)); assert(cbor.isTag(0, uint32(rand32))); } - function test_isTag_expect_rand_16(uint16 rand16) public pure { + function test_fuzz_isTag_expect_rand_16(uint16 rand16) public pure { bytes memory cbor = bytes.concat(bytes1(MajorTag << shiftMajor | MinorExtendU16), bytes2(rand16)); assert(cbor.isTag(0, uint16(rand16))); } - function test_isTag_expect_badminor() public pure { - bytes memory cbor = bytes.concat(bytes1(MajorTag << shiftMajor | (MinorExtendU64 + 1))); - assert(!cbor.isTag(0, MinorExtendU64 + 1)); - } + function test_isUInt() public { + bool result; - function test_isTag_false() public pure { - assert(!arrayCbor.isTag(0)); - } - - function test_isTag_false_expect() public pure { - assert(!arrayCbor.isTag(0, 0)); - } + vm.startSnapshotGas("isUInt_false"); + result = negativeCbor.isUInt(0); + vm.stopSnapshotGas(); + assert(!result); - function test_isTag_true() public pure { - assert(tagCbor.isTag(0)); + vm.startSnapshotGas("isUInt_true"); + result = unsignedCbor.isUInt(0); + vm.stopSnapshotGas(); + assert(result); } - function test_isUInt_false() public pure { - assert(!negativeCbor.isUInt(0)); - } + function test_isUndefined() public { + bool result; - function test_isUInt_true() public pure { - assert(unsignedCbor.isUInt(0)); - } - - function test_isUndefined_false() public pure { - assert(!unsignedCbor.isUndefined(0)); - } + vm.startSnapshotGas("isUndefined_false"); + result = unsignedCbor.isUndefined(0); + vm.stopSnapshotGas(); + assert(!result); - function test_isUndefined_true() public pure { - assert(undefinedCbor.isUndefined(0)); + vm.startSnapshotGas("isUndefined_true"); + result = undefinedCbor.isUndefined(0); + vm.stopSnapshotGas(); + assert(result); } } diff --git a/test/Simple.t.sol b/test/Simple.t.sol index e197c1f..ea44c2c 100644 --- a/test/Simple.t.sol +++ b/test/Simple.t.sol @@ -8,20 +8,22 @@ using ReadCbor for bytes; /// @author turbocrime contract SimpleTest is Test { - function test_Boolean_false() public pure { - bytes memory cbor = hex"f4"; + function test_Boolean() public { + bytes memory cbor = hex"f4f5"; uint i; bool value; + + vm.startSnapshotGas("Boolean_false"); (i, value) = cbor.Bool(i); + vm.stopSnapshotGas(); assert(value == false); - } - function test_Boolean_true() public pure { - bytes memory cbor = hex"f5"; - uint i; - bool value; + vm.startSnapshotGas("Boolean_true"); (i, value) = cbor.Bool(i); + vm.stopSnapshotGas(); assert(value == true); + + assert(i == cbor.length); } function testFail_Boolean_invalid() public pure { @@ -31,10 +33,13 @@ contract SimpleTest is Test { (i, value) = cbor.Bool(i); } - function test_skipNull() public pure { + function test_skipNull() public { bytes memory cbor = hex"f6"; uint i; + + vm.startSnapshotGas("skipNull"); (i) = cbor.Null(i); + vm.stopSnapshotGas(); } function testFail_skipNull() public pure { @@ -43,10 +48,13 @@ contract SimpleTest is Test { (i) = cbor.Null(i); } - function test_skipUndefined() public pure { + function test_skipUndefined() public { bytes memory cbor = hex"f7"; uint i; + + vm.startSnapshotGas("skipUndefined"); (i) = cbor.Undefined(i); + vm.stopSnapshotGas(); } function testFail_skipUndefined() public pure { diff --git a/test/String.t.sol b/test/String.t.sol index 83fd3e0..046004f 100644 --- a/test/String.t.sol +++ b/test/String.t.sol @@ -8,39 +8,55 @@ using ReadCbor for bytes; /// @author turbocrime contract StringTest is Test { - function test_String_empty() public pure { + function test_String_empty() public { bytes memory cbor = hex"60"; // zero-length string in CBOR uint i; string memory value; + + vm.startSnapshotGas("String_empty"); (i, value) = cbor.String(0); + vm.stopSnapshotGas(); + assert(bytes(value).length == 0); } - function test_String_short() public pure { + function test_String_short() public { // String with 23 bytes (just below the threshold for an extended header) bytes memory cbor = hex"77414141414141414141414141414141414141414141414141"; uint i; string memory value; + + vm.startSnapshotGas("String_short"); (i, value) = cbor.String(0); + vm.stopSnapshotGas(); + assert(bytes(value).length == 23); } - function test_String_extended() public pure { + function test_String_extended() public { // String with 24 bytes (just at the threshold for an extended header) bytes memory cbor = hex"7741414141414141414141414141414141414141414141414141"; uint i; string memory value; + + vm.startSnapshotGas("String_extended"); (i, value) = cbor.String(0); + vm.stopSnapshotGas(); + assert(bytes(value).length == 23); } - function test_String32_short() public pure { + function test_String32() public { // 1 character "a" bytes memory cbor = hex"6161"; uint i; bytes32 value; uint8 len; + + vm.startSnapshotGas("String32_short"); (i, value, len) = cbor.String32(0); + vm.stopSnapshotGas(); + assert(i == cbor.length); assert(len == 1); assert(value == "a"); @@ -66,9 +82,13 @@ contract StringTest is Test { (i, value, len) = cbor.String32(0, 33); } - function test_skipString() public pure { + function test_skipString() public { bytes memory cbor = hex"6161"; + + vm.startSnapshotGas("skipString"); uint i = cbor.skipString(0); + vm.stopSnapshotGas(); + assert(i == cbor.length); } @@ -78,11 +98,15 @@ contract StringTest is Test { assert(cbor[i] == cbor[i]); } - function test_String1() public pure { + function test_String1() public { bytes memory cbor = hex"6161"; uint i; bytes1 value; + + vm.startSnapshotGas("String1"); (i, value) = cbor.String1(0); + vm.stopSnapshotGas(); + assert(i == cbor.length); assert(value == bytes1("a")); } diff --git a/test/Tag.t.sol b/test/Tag.t.sol index fbce9f2..058164f 100644 --- a/test/Tag.t.sol +++ b/test/Tag.t.sol @@ -8,19 +8,27 @@ using ReadCbor for bytes; /// @author turbocrime contract TagTest is Test { - function test_Tag() public pure { + function test_Tag() public { bytes memory cbor = hex"c0"; // Tag(0) uint i; uint64 tag; + + vm.startSnapshotGas("Tag"); (i, tag) = cbor.Tag(i); + vm.stopSnapshotGas(); + assert(i == cbor.length); assert(tag == 0); } - function test_Tag_expected() public pure { + function test_Tag_expected() public { bytes memory cbor = hex"c0"; // Tag(0) uint i; + + vm.startSnapshotGas("Tag_expected"); i = cbor.Tag(i, 0); + vm.stopSnapshotGas(); + assert(i == cbor.length); } @@ -31,7 +39,7 @@ contract TagTest is Test { } function testFail_Tag_invalid() public pure { - bytes memory cbor = hex"df"; // Not a tag + bytes memory cbor = hex"01"; // unsigned int 1 uint i; cbor.Tag(i); } diff --git a/test/UInt.t.sol b/test/UInt.t.sol index 7b0299e..025ab12 100644 --- a/test/UInt.t.sol +++ b/test/UInt.t.sol @@ -9,19 +9,27 @@ using ReadCbor for bytes; /// @author turbocrime contract UIntTest is Test { // Test basic integer types - function test_UInt8_short() public pure { + function test_UInt8_short() public { bytes memory cbor = hex"17"; // max minor literal uint8 uint i; uint8 value; + + vm.startSnapshotGas("UInt8_short"); (i, value) = cbor.UInt8(i); + vm.stopSnapshotGas(); + assert(value == 0x17); } - function test_UInt8_extended() public pure { + function test_UInt8_extended() public { bytes memory cbor = hex"1818"; // minimum header extension uint8 uint i; uint8 value; + + vm.startSnapshotGas("UInt8_extended"); (i, value) = cbor.UInt8(i); + vm.stopSnapshotGas(); + assert(value == 0x18); } @@ -33,11 +41,15 @@ contract UIntTest is Test { assert(value == 0x17); } - function test_UInt8_max() public pure { + function test_UInt8_max() public { bytes memory cbor = hex"18ff"; // max uint8 uint i; uint8 value; + + vm.startSnapshotGas("UInt8_max"); (i, value) = cbor.UInt8(0); + vm.stopSnapshotGas(); + assert(value == 0xff); } @@ -48,52 +60,76 @@ contract UIntTest is Test { (i, value) = cbor.UInt8(0); // Should fail as value exceeds uint8 } - function test_UInt16_max() public pure { + function test_UInt16_max() public { bytes memory cbor = hex"19ffff"; // max uint16 uint i; uint16 value; + + vm.startSnapshotGas("UInt16_max"); (i, value) = cbor.UInt16(0); + vm.stopSnapshotGas(); + assert(value == 0xffff); } - function test_UInt32_max() public pure { + function test_UInt32_max() public { bytes memory cbor = hex"1affffffff"; // max uint32 uint i; uint32 value; + + vm.startSnapshotGas("UInt32_max"); (i, value) = cbor.UInt32(0); + vm.stopSnapshotGas(); + assert(value == 0xffff_ffff); } - function test_UInt64_max() public pure { + function test_UInt64_max() public { bytes memory cbor = hex"1bffffffffffffffff"; // max uint64 uint i; uint64 value; + + vm.startSnapshotGas("UInt64_max"); (i, value) = cbor.UInt64(0); + vm.stopSnapshotGas(); + assert(value == 0xffff_ffff_ffff_ffff); } // Additional integer tests - function test_UInt8_0() public pure { + function test_UInt8_0() public { bytes memory cbor = hex"00"; // minor literal zero uint i; uint8 value; + + vm.startSnapshotGas("UInt8_0"); (i, value) = cbor.UInt8(0); + vm.stopSnapshotGas(); + assert(value == 0); } - function test_UInt8_1() public pure { + function test_UInt8_1() public { bytes memory cbor = hex"01"; // minor literal 1 uint i; uint8 value; + + vm.startSnapshotGas("UInt8_1"); (i, value) = cbor.UInt8(0); + vm.stopSnapshotGas(); + assert(value == 1); } - function test_UInt() public pure { + function test_UInt() public { bytes memory cbor = hex"19ffff"; // max uint16 uint i; uint value; + + vm.startSnapshotGas("UInt"); (i, value) = cbor.UInt(0); + vm.stopSnapshotGas(); + assert(value == 0xffff); } diff --git a/test/tags/Bignum.t.sol b/test/tags/Bignum.t.sol index 64b4542..b199ae8 100644 --- a/test/tags/Bignum.t.sol +++ b/test/tags/Bignum.t.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: Apache-2.0 pragma solidity ^0.8.28; -import {Test} from "forge-std/Test.sol"; +import "forge-std/Test.sol"; import "../../src/tags/ReadBignum.sol"; import "../../src/ReadCbor.sol"; @@ -30,33 +30,42 @@ contract BignumTest is Test { bytes1 internal constant HeadUBn = hex"c2"; bytes1 internal constant HeadNBn = hex"c3"; - function test_UInt256_single() public pure { + function test_UInt256_single() public { bytes memory cbor = abi.encodePacked(HeadUBn, bytesHead(1), hex"ff"); uint i; uint256 value; + vm.startSnapshotGas("UInt256_single"); (i, value) = cbor.UInt256(i); + vm.stopSnapshotGas(); + assert(i == cbor.length); assert(value == 0xFF); } - function test_UInt256_multi() public pure { + function test_UInt256_multi() public { // 2(h'12345678') bytes memory cbor = hex"c24412345678"; uint i; uint256 value; + vm.startSnapshotGas("UInt256_multi"); (i, value) = cbor.UInt256(i); + vm.stopSnapshotGas(); + assert(i == cbor.length); assert(value == 0x12345678); } - function test_UInt256_max() public pure { + function test_UInt256_max() public { bytes memory cbor = abi.encodePacked(HeadUBn, bytesHead(32), type(uint256).max); uint i; uint256 value; + vm.startSnapshotGas("UInt256_max"); (i, value) = cbor.UInt256(i); + vm.stopSnapshotGas(); + assert(value == type(uint256).max); assert(i == cbor.length); } @@ -73,7 +82,7 @@ contract BignumTest is Test { assert(i == cbor.length); } - function test_UInt256_middle() public pure { + function test_UInt256_middle() public { // [2(h'123456'), "foo"] bytes memory cbor = hex"82c24312345663666F6F"; uint i; @@ -82,58 +91,73 @@ contract BignumTest is Test { string memory foo; (i, len) = cbor.Array(i); + + vm.startSnapshotGas("UInt256_middle"); (i, value) = cbor.UInt256(i); + vm.stopSnapshotGas(); + assert(value == 0x123456); (i, foo) = cbor.String(i); assert(i == cbor.length); assert(bytes3(bytes(foo)) == "foo"); } - function test_NInt256_single() public pure { + function test_NInt256_single() public { // 3(h'ff') bytes memory cbor = hex"c341ff"; uint i; int256 value; + vm.startSnapshotGas("NInt256_single"); (i, value) = cbor.NInt256(i); + vm.stopSnapshotGas(); + assert(value == -1 - 0xFF); assert(i == cbor.length); } - function test_NInt256_multi() public pure { + function test_NInt256_multi() public { // 3(h'12345678') bytes memory cbor = hex"c34412345678"; uint i; int256 value; + vm.startSnapshotGas("NInt256_multi"); (i, value) = cbor.NInt256(i); + vm.stopSnapshotGas(); + assert(value == -1 - 0x12345678); assert(i == cbor.length); } - function test_NInt256_max() public pure { + function test_NInt256_max() public { bytes memory cbor = abi.encodePacked(HeadNBn, bytesHead(32), uint256(type(int256).min) - 1); uint i; int256 value; + vm.startSnapshotGas("NInt256_max"); (i, value) = cbor.NInt256(i); + vm.stopSnapshotGas(); + assert(value == type(int256).min); assert(i == cbor.length); } - function testFail_NInt256_overflow() public pure { + function testFail_NInt256_overflow() public { // Invalid: one more than the 'maximum' negative number that can be represented as an int256 bytes memory cbor = abi.encodePacked(HeadNBn, bytesHead(32), uint256(type(int256).min)); uint i; int256 value; + vm.startSnapshotGas("NInt256_overflow"); (i, value) = cbor.NInt256(i); + vm.stopSnapshotGas(); // unreachable assert(i == cbor.length); } - function testFail_NInt256_maxu256() public pure { + function testFail_NInt256_max() public pure { // Invalid: maximum uint256 value as negative bignum // 3(h'ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff') bytes memory cbor = abi.encodePacked(HeadNBn, bytesHead(32), bytes32(type(uint256).max)); @@ -158,7 +182,7 @@ contract BignumTest is Test { assert(i == cbor.length); } - function test_NInt256_middle() public pure { + function test_NInt256_middle() public { // [3(h'123456'), "foo"] bytes memory cbor = hex"82c34312345663666F6F"; uint i; @@ -166,7 +190,10 @@ contract BignumTest is Test { int256 value; string memory foo; + vm.startSnapshotGas("NInt256_middle"); (i, len) = cbor.Array(i); + vm.stopSnapshotGas(); + (i, value) = cbor.NInt256(i); assert(value == -1 - 0x123456); (i, foo) = cbor.String(i); @@ -174,7 +201,7 @@ contract BignumTest is Test { assert(bytes3(bytes(foo)) == "foo"); } - function test_UInt256_random(uint256 randU) public pure { + function test_fuzz_UInt256_random(uint256 randU) public pure { bytes memory cbor = abi.encodePacked(HeadUBn, bytesHead(32), randU); uint i; uint256 value; @@ -184,7 +211,7 @@ contract BignumTest is Test { assert(i == cbor.length); } - function test_NInt256_random(int256 randN) public pure { + function test_fuzz_NInt256_random(int256 randN) public pure { vm.assume(randN < 0); vm.assume(randN != type(int256).min); @@ -197,13 +224,17 @@ contract BignumTest is Test { assert(i == cbor.length); } - function test_Integer() public pure { + function test_Integer() public { bytes memory cbor = hex"8C08387E18FF397FFE19FFFF3A7FFFFFFE1AFFFFFFFF3B7FFFFFFFFFFFFFFE1BFFFFFFFFFFFFFFFFC3507FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFC250FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFC358207FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"; uint j; int256 value; uint32 len; + + vm.startSnapshotGas("Integer"); (j, len) = cbor.Array(j); + vm.stopSnapshotGas(); + for (uint8 i = 0; i < len; i++) { (j, value) = cbor.Integer(j); } diff --git a/test/tags/CidSha256.t.sol b/test/tags/CidSha256.t.sol index 98f0b87..9318d34 100644 --- a/test/tags/CidSha256.t.sol +++ b/test/tags/CidSha256.t.sol @@ -21,16 +21,27 @@ contract CidSha256Test is Test { bytes private constant nullCbor = hex"F6"; - function test_Cid() public pure { - constantCidCbor.Cid(0); + function test_Cid() public { + uint i; + CidSha256 cid; + + vm.startSnapshotGas("Cid"); + (i, cid) = constantCidCbor.Cid(0); + vm.stopSnapshotGas(); } - function test_NullableCid_nullCbor() public pure { - (, CidSha256 nullCid) = nullCbor.NullableCid(0); + function test_NullableCid_nullCbor() public { + uint i; + CidSha256 nullCid; + + vm.startSnapshotGas("NullableCid_nullCbor"); + (i, nullCid) = nullCbor.NullableCid(0); + vm.stopSnapshotGas(); + assert(nullCid.isNull() == true); } - function test_Cid_random(uint256 randomHash) public pure { + function test_fuzz_Cid_random(uint256 randomHash) public pure { vm.assume(randomHash != 0); bytes memory randomCidCbor = abi.encodePacked(dagHead, randomHash); (uint i, CidSha256 rando) = randomCidCbor.Cid(0); @@ -38,7 +49,7 @@ contract CidSha256Test is Test { assert(CidSha256.unwrap(rando) == randomHash); } - function test_NullableCid_random(uint256 randomHash) public pure { + function test_fuzz_NullableCid_random(uint256 randomHash) public pure { bytes memory randomCidCbor = randomHash != 0 ? abi.encodePacked(dagHead, randomHash) : nullCbor; (uint i, CidSha256 rando) = randomCidCbor.NullableCid(0); assert(i == randomCidCbor.length); @@ -61,7 +72,12 @@ contract CidSha256Test is Test { zeroCidCbor.NullableCid(0); } - function test_Cid_multicodec_raw() public pure { - rawCidCbor.Cid(0, 0x55); + function test_Cid_multicodec_raw() public { + uint i; + CidSha256 cid; + + vm.startSnapshotGas("Cid_multicodec_raw"); + (i, cid) = rawCidCbor.Cid(0, 0x55); + vm.stopSnapshotGas(); } } From 5577cc61d8e8f5bb5b1ed9e8112a949bf6b7a4bb Mon Sep 17 00:00:00 2001 From: turbocrime Date: Fri, 3 Jan 2025 18:48:11 -0800 Subject: [PATCH 3/8] workflow --- .github/workflows/test.yml | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index add0128..c5132ba 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -39,12 +39,17 @@ jobs: forge build --sizes id: build - - name: Run Forge tests + - name: Confirm comparison snapshot + run: | + forge snapshot --match-path "test/comparison/*" --check + id: comparison-snapshot + + - name: Run all Forge tests run: | forge test -vvv id: test - - name: Run snapshot + - name: Check snapshots directory did not update run: | - forge snapshot --match-path "test/comparison/*" --check - id: test-committed \ No newline at end of file + git diff --exit-code snapshots + id: no-diff-snapshot \ No newline at end of file From 68194e52baa70dfc5f21a08b583e923c7df6efb2 Mon Sep 17 00:00:00 2001 From: turbocrime Date: Fri, 3 Jan 2025 19:06:31 -0800 Subject: [PATCH 4/8] confirm coverage --- .github/workflows/test.yml | 10 ++++-- lcov.info | 68 +++++++++++++++++++------------------- 2 files changed, 42 insertions(+), 36 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index c5132ba..1b8f80f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -49,7 +49,13 @@ jobs: forge test -vvv id: test - - name: Check snapshots directory did not update + - name: Confirm section snapshots run: | git diff --exit-code snapshots - id: no-diff-snapshot \ No newline at end of file + id: diff-section-snapshots + + - name: Confirm coverage + run: | + forge coverage --report lcov + git diff --exit-code lcov.info + id: diff-coverage \ No newline at end of file diff --git a/lcov.info b/lcov.info index 025b8fa..81c7659 100644 --- a/lcov.info +++ b/lcov.info @@ -1,32 +1,32 @@ TN: SF:src/ReadCbor.sol -DA:33,819 +DA:33,818 FN:33,ReadCbor.parseArg -FNDA:819,ReadCbor.parseArg -DA:34,819 +FNDA:818,ReadCbor.parseArg +DA:34,818 BRDA:34,0,0,541 -BRDA:34,0,1,257 +BRDA:34,0,1,256 DA:35,541 -DA:36,278 +DA:36,277 BRDA:36,1,0,3 -BRDA:36,1,1,257 +BRDA:36,1,1,256 DA:37,3 DA:38,3 BRDA:38,2,0,1 BRDA:38,2,1,2 -DA:39,275 +DA:39,274 BRDA:39,3,0,7 -BRDA:39,3,1,257 +BRDA:39,3,1,256 DA:40,7 -DA:41,268 +DA:41,267 BRDA:41,4,0,4 -BRDA:41,4,1,257 +BRDA:41,4,1,256 DA:42,4 -DA:43,264 +DA:43,263 BRDA:43,5,0,7 -BRDA:43,5,1,257 +BRDA:43,5,1,256 DA:44,7 -DA:46,257 +DA:46,256 DA:50,827 FN:50,ReadCbor.u8 FNDA:827,ReadCbor.u8 @@ -61,9 +61,9 @@ FNDA:540,ReadCbor.header DA:104,540 DA:105,540 DA:106,540 -BRDA:106,6,0,1 -BRDA:106,6,1,539 -DA:107,539 +BRDA:106,6,0,2 +BRDA:106,6,1,538 +DA:107,538 DA:118,10 FN:118,ReadCbor.header FNDA:10,ReadCbor.header @@ -273,23 +273,23 @@ DA:466,15 FN:466,ReadCbor.isTag FNDA:15,ReadCbor.isTag DA:468,15 -DA:477,772 +DA:477,770 FN:477,ReadCbor.isTag -FNDA:772,ReadCbor.isTag -DA:478,772 -DA:480,772 -DA:482,772 -BRDA:482,26,0,1 -DA:483,771 -DA:484,771 -DA:485,771 -BRDA:485,27,0,1 -DA:487,769 -DA:488,769 -DA:489,513 -DA:490,257 -DA:491,1 -DA:494,771 +FNDA:770,ReadCbor.isTag +DA:478,770 +DA:480,770 +DA:482,770 +BRDA:482,26,0,- +DA:483,770 +DA:484,770 +DA:485,770 +BRDA:485,27,0,- +DA:487,768 +DA:488,768 +DA:489,512 +DA:490,256 +DA:491,0 +DA:494,770 DA:504,7 FN:504,ReadCbor.Tag FNDA:7,ReadCbor.Tag @@ -387,9 +387,9 @@ DA:669,1 FNF:49 FNH:49 LF:229 -LH:229 +LH:228 BRF:57 -BRH:57 +BRH:55 end_of_record TN: SF:src/tags/ReadBignum.sol From 19e4d86882c5ee614c2a05ef12167cd1dc661f48 Mon Sep 17 00:00:00 2001 From: turbocrime Date: Fri, 3 Jan 2025 21:53:12 -0800 Subject: [PATCH 5/8] remove old reports --- .gas-snapshot | 16 - lcov.info | 766 ----------------------------------- snapshots/ArrayTest.json | 7 - snapshots/BignumTest.json | 11 - snapshots/BytesTest.json | 7 - snapshots/CidSha256Test.json | 5 - snapshots/IntTest.json | 8 - snapshots/MapTest.json | 6 - snapshots/NIntTest.json | 11 - snapshots/PeekTest.json | 28 -- snapshots/SimpleTest.json | 6 - snapshots/StringTest.json | 8 - snapshots/TagTest.json | 4 - snapshots/UIntTest.json | 11 - 14 files changed, 894 deletions(-) delete mode 100644 .gas-snapshot delete mode 100644 lcov.info delete mode 100644 snapshots/ArrayTest.json delete mode 100644 snapshots/BignumTest.json delete mode 100644 snapshots/BytesTest.json delete mode 100644 snapshots/CidSha256Test.json delete mode 100644 snapshots/IntTest.json delete mode 100644 snapshots/MapTest.json delete mode 100644 snapshots/NIntTest.json delete mode 100644 snapshots/PeekTest.json delete mode 100644 snapshots/SimpleTest.json delete mode 100644 snapshots/StringTest.json delete mode 100644 snapshots/TagTest.json delete mode 100644 snapshots/UIntTest.json diff --git a/.gas-snapshot b/.gas-snapshot deleted file mode 100644 index 31d13d9..0000000 --- a/.gas-snapshot +++ /dev/null @@ -1,16 +0,0 @@ -ComparisonTest:test_decodeArrayU8_CBORDecoder() (gas: 5274) -ComparisonTest:test_decodeArrayU8_ReadCbor() (gas: 2334) -ComparisonTest:test_decodeFalse_CBORDecoder() (gas: 916) -ComparisonTest:test_decodeFalse_ReadCbor() (gas: 425) -ComparisonTest:test_decodeFixedArray_CBORDecoder() (gas: 9207) -ComparisonTest:test_decodeFixedArray_ReadCbor() (gas: 4234) -ComparisonTest:test_decodeInteger_CBORDecoder() (gas: 884) -ComparisonTest:test_decodeInteger_ReadCbor() (gas: 554) -ComparisonTest:test_decodeNull_CBORDecoder() (gas: 396) -ComparisonTest:test_decodeNull_ReadCbor() (gas: 240) -ComparisonTest:test_decodeStringWithWeirdChar_CBORDecoder() (gas: 2356) -ComparisonTest:test_decodeStringWithWeirdChar_ReadCbor() (gas: 884) -ComparisonTest:test_decodeString_CBORDecoder() (gas: 3869) -ComparisonTest:test_decodeString_ReadCbor() (gas: 957) -ComparisonTest:test_decodeTrue_CBORDecoder() (gas: 937) -ComparisonTest:test_decodeTrue_ReadCbor() (gas: 483) \ No newline at end of file diff --git a/lcov.info b/lcov.info deleted file mode 100644 index 81c7659..0000000 --- a/lcov.info +++ /dev/null @@ -1,766 +0,0 @@ -TN: -SF:src/ReadCbor.sol -DA:33,818 -FN:33,ReadCbor.parseArg -FNDA:818,ReadCbor.parseArg -DA:34,818 -BRDA:34,0,0,541 -BRDA:34,0,1,256 -DA:35,541 -DA:36,277 -BRDA:36,1,0,3 -BRDA:36,1,1,256 -DA:37,3 -DA:38,3 -BRDA:38,2,0,1 -BRDA:38,2,1,2 -DA:39,274 -BRDA:39,3,0,7 -BRDA:39,3,1,256 -DA:40,7 -DA:41,267 -BRDA:41,4,0,4 -BRDA:41,4,1,256 -DA:42,4 -DA:43,263 -BRDA:43,5,0,7 -BRDA:43,5,1,256 -DA:44,7 -DA:46,256 -DA:50,827 -FN:50,ReadCbor.u8 -FNDA:827,ReadCbor.u8 -DA:53,827 -DA:54,827 -DA:58,7 -FN:58,ReadCbor.u16 -FNDA:7,ReadCbor.u16 -DA:61,7 -DA:62,7 -DA:66,4 -FN:66,ReadCbor.u32 -FNDA:4,ReadCbor.u32 -DA:69,4 -DA:70,4 -DA:74,7 -FN:74,ReadCbor.u64 -FNDA:7,ReadCbor.u64 -DA:77,7 -DA:78,7 -DA:88,274 -FN:88,ReadCbor.header -FNDA:274,ReadCbor.header -DA:89,274 -DA:90,274 -DA:91,274 -DA:92,274 -DA:93,274 -DA:103,540 -FN:103,ReadCbor.header -FNDA:540,ReadCbor.header -DA:104,540 -DA:105,540 -DA:106,540 -BRDA:106,6,0,2 -BRDA:106,6,1,538 -DA:107,538 -DA:118,10 -FN:118,ReadCbor.header -FNDA:10,ReadCbor.header -DA:123,10 -DA:124,10 -DA:125,10 -DA:126,10 -BRDA:126,7,0,2 -BRDA:126,7,1,8 -DA:127,8 -DA:128,8 -BRDA:128,8,0,2 -BRDA:128,8,1,6 -DA:129,6 -DA:139,591 -FN:139,ReadCbor.header8 -FNDA:591,ReadCbor.header8 -DA:140,591 -DA:143,591 -DA:144,591 -DA:145,591 -DA:146,591 -DA:149,591 -BRDA:149,9,0,1 -BRDA:149,9,1,590 -DA:151,590 -BRDA:151,10,0,535 -DA:152,535 -BRDA:152,11,0,2 -BRDA:152,11,1,533 -DA:154,533 -DA:155,533 -DA:157,533 -BRDA:157,12,0,2 -BRDA:157,12,1,531 -DA:160,586 -DA:170,45 -FN:170,ReadCbor.header32 -FNDA:45,ReadCbor.header32 -DA:171,45 -DA:174,45 -DA:175,45 -DA:176,45 -DA:177,45 -DA:180,45 -BRDA:180,13,0,2 -BRDA:180,13,1,43 -DA:182,43 -BRDA:182,14,0,2 -BRDA:182,14,1,1 -DA:184,2 -DA:185,2 -DA:187,2 -BRDA:187,15,0,1 -BRDA:187,15,1,1 -DA:188,41 -BRDA:188,16,0,3 -DA:189,3 -BRDA:189,17,0,1 -BRDA:189,17,1,2 -DA:190,2 -BRDA:190,18,0,1 -BRDA:190,18,1,1 -DA:192,1 -DA:193,1 -DA:195,1 -BRDA:195,19,0,1 -DA:197,1 -DA:198,1 -DA:203,41 -DA:210,263 -FN:210,ReadCbor.isNull -FNDA:263,ReadCbor.isNull -DA:212,263 -DA:221,2 -FN:221,ReadCbor.Null -FNDA:2,ReadCbor.Null -DA:222,2 -BRDA:222,20,0,1 -BRDA:222,20,1,1 -DA:223,1 -DA:230,4 -FN:230,ReadCbor.isUndefined -FNDA:4,ReadCbor.isUndefined -DA:232,4 -DA:241,2 -FN:241,ReadCbor.Undefined -FNDA:2,ReadCbor.Undefined -DA:242,2 -BRDA:242,21,0,1 -BRDA:242,21,1,1 -DA:243,1 -DA:250,3 -FN:250,ReadCbor.isBool -FNDA:3,ReadCbor.isBool -DA:252,3 -DA:253,3 -DA:267,5 -FN:267,ReadCbor.Bool -FNDA:5,ReadCbor.Bool -DA:268,5 -DA:270,5 -DA:271,5 -DA:272,5 -DA:273,5 -DA:275,5 -BRDA:275,22,0,1 -BRDA:275,22,1,4 -DA:282,2 -FN:282,ReadCbor.isArray -FNDA:2,ReadCbor.isArray -DA:284,2 -DA:293,15 -FN:293,ReadCbor.Array -FNDA:15,ReadCbor.Array -DA:296,15 -DA:303,2 -FN:303,ReadCbor.isMap -FNDA:2,ReadCbor.isMap -DA:305,2 -DA:314,9 -FN:314,ReadCbor.Map -FNDA:9,ReadCbor.Map -DA:318,9 -DA:325,2 -FN:325,ReadCbor.isString -FNDA:2,ReadCbor.isString -DA:327,2 -DA:336,10 -FN:336,ReadCbor.String -FNDA:10,ReadCbor.String -DA:337,10 -DA:338,10 -DA:340,10 -DA:342,10 -DA:343,10 -DA:344,10 -DA:345,10 -DA:357,14 -FN:357,ReadCbor.String32 -FNDA:14,ReadCbor.String32 -DA:358,14 -DA:359,13 -DA:360,13 -BRDA:360,23,0,1 -BRDA:360,23,1,12 -DA:363,12 -DA:364,12 -DA:365,12 -DA:369,2 -FN:369,ReadCbor.String32 -FNDA:2,ReadCbor.String32 -DA:370,2 -DA:379,2 -FN:379,ReadCbor.String1 -FNDA:2,ReadCbor.String1 -DA:380,2 -DA:382,2 -DA:383,2 -DA:384,2 -DA:385,2 -DA:387,2 -BRDA:387,24,0,1 -BRDA:387,24,1,1 -DA:394,2 -FN:394,ReadCbor.skipString -FNDA:2,ReadCbor.skipString -DA:395,2 -DA:396,2 -DA:397,1 -DA:404,2 -FN:404,ReadCbor.isBytes -FNDA:2,ReadCbor.isBytes -DA:406,2 -DA:415,3 -FN:415,ReadCbor.Bytes -FNDA:3,ReadCbor.Bytes -DA:416,3 -DA:417,3 -DA:419,3 -DA:421,3 -DA:422,3 -DA:423,3 -DA:424,3 -DA:436,3 -FN:436,ReadCbor.Bytes32 -FNDA:3,ReadCbor.Bytes32 -DA:437,3 -DA:438,2 -DA:439,2 -BRDA:439,25,0,1 -BRDA:439,25,1,1 -DA:442,1 -DA:443,1 -DA:444,1 -DA:448,2 -FN:448,ReadCbor.Bytes32 -FNDA:2,ReadCbor.Bytes32 -DA:449,2 -DA:456,2 -FN:456,ReadCbor.skipBytes -FNDA:2,ReadCbor.skipBytes -DA:457,2 -DA:458,2 -DA:459,1 -DA:466,15 -FN:466,ReadCbor.isTag -FNDA:15,ReadCbor.isTag -DA:468,15 -DA:477,770 -FN:477,ReadCbor.isTag -FNDA:770,ReadCbor.isTag -DA:478,770 -DA:480,770 -DA:482,770 -BRDA:482,26,0,- -DA:483,770 -DA:484,770 -DA:485,770 -BRDA:485,27,0,- -DA:487,768 -DA:488,768 -DA:489,512 -DA:490,256 -DA:491,0 -DA:494,770 -DA:504,7 -FN:504,ReadCbor.Tag -FNDA:7,ReadCbor.Tag -DA:505,7 -DA:514,530 -FN:514,ReadCbor.Tag -FNDA:530,ReadCbor.Tag -DA:515,530 -DA:516,530 -BRDA:516,28,0,1 -BRDA:516,28,1,529 -DA:517,529 -DA:524,2 -FN:524,ReadCbor.isUInt -FNDA:2,ReadCbor.isUInt -DA:526,2 -DA:535,1 -FN:535,ReadCbor.UInt -FNDA:1,ReadCbor.UInt -DA:536,1 -DA:544,40 -FN:544,ReadCbor.UInt8 -FNDA:40,ReadCbor.UInt8 -DA:545,40 -DA:553,2 -FN:553,ReadCbor.UInt16 -FNDA:2,ReadCbor.UInt16 -DA:554,2 -DA:555,2 -DA:556,1 -DA:564,1 -FN:564,ReadCbor.UInt32 -FNDA:1,ReadCbor.UInt32 -DA:565,1 -DA:566,1 -DA:567,1 -DA:575,1 -FN:575,ReadCbor.UInt64 -FNDA:1,ReadCbor.UInt64 -DA:576,1 -DA:583,2 -FN:583,ReadCbor.isNInt -FNDA:2,ReadCbor.isNInt -DA:585,2 -DA:594,1 -FN:594,ReadCbor.NInt -FNDA:1,ReadCbor.NInt -DA:595,1 -DA:596,1 -DA:597,1 -DA:605,7 -FN:605,ReadCbor.NInt8 -FNDA:7,ReadCbor.NInt8 -DA:606,7 -DA:607,7 -DA:608,5 -DA:616,3 -FN:616,ReadCbor.NInt16 -FNDA:3,ReadCbor.NInt16 -DA:617,3 -DA:618,3 -DA:619,1 -DA:627,1 -FN:627,ReadCbor.NInt32 -FNDA:1,ReadCbor.NInt32 -DA:628,1 -DA:629,1 -DA:630,1 -DA:638,1 -FN:638,ReadCbor.NInt64 -FNDA:1,ReadCbor.NInt64 -DA:639,1 -DA:640,1 -DA:641,1 -DA:648,3 -FN:648,ReadCbor.isInt -FNDA:3,ReadCbor.isInt -DA:650,3 -DA:651,3 -DA:660,16 -FN:660,ReadCbor.Int -FNDA:16,ReadCbor.Int -DA:661,16 -DA:662,16 -DA:663,16 -DA:664,16 -BRDA:664,29,0,8 -BRDA:664,29,1,1 -DA:665,8 -DA:666,8 -BRDA:666,30,0,7 -BRDA:666,30,1,1 -DA:667,7 -DA:669,1 -FNF:49 -FNH:49 -LF:229 -LH:228 -BRF:57 -BRH:55 -end_of_record -TN: -SF:src/tags/ReadBignum.sol -DA:12,263 -FN:12,ReadBignum.UInt256 -FNDA:263,ReadBignum.UInt256 -DA:13,263 -DA:14,263 -DA:15,263 -DA:16,263 -BRDA:16,0,0,1 -BRDA:16,0,1,262 -DA:19,262 -DA:26,262 -DA:30,265 -FN:30,ReadBignum.NInt256 -FNDA:265,ReadBignum.NInt256 -DA:31,265 -DA:32,265 -DA:33,265 -DA:34,265 -BRDA:34,1,0,1 -BRDA:34,1,1,264 -DA:36,264 -DA:38,264 -DA:45,264 -DA:48,264 -BRDA:48,2,0,2 -BRDA:48,2,1,262 -DA:49,262 -DA:52,5 -FN:52,ReadBignum.Int256 -FNDA:5,ReadBignum.Int256 -DA:53,5 -DA:54,5 -BRDA:54,3,0,2 -BRDA:54,3,1,1 -DA:55,2 -DA:56,2 -DA:57,2 -BRDA:57,4,0,1 -BRDA:57,4,1,1 -DA:58,1 -DA:59,3 -BRDA:59,5,0,2 -BRDA:59,5,1,1 -DA:60,2 -DA:62,1 -DA:66,13 -FN:66,ReadBignum.Integer -FNDA:13,ReadBignum.Integer -DA:67,13 -FNF:4 -FNH:4 -LF:29 -LH:29 -BRF:12 -BRH:12 -end_of_record -TN: -SF:src/tags/ReadCidSha256.sol -DA:66,512 -FN:66,ReadCidSha256.Cid -FNDA:512,ReadCidSha256.Cid -DA:67,512 -DA:70,513 -FN:70,ReadCidSha256.Cid -FNDA:513,ReadCidSha256.Cid -DA:71,513 -DA:72,513 -DA:75,513 -DA:81,513 -DA:82,513 -DA:83,513 -DA:86,513 -BRDA:86,0,0,1 -BRDA:86,0,1,512 -DA:87,512 -BRDA:87,1,0,2 -BRDA:87,1,1,510 -DA:97,258 -FN:97,ReadCidSha256.NullableCid -FNDA:258,ReadCidSha256.NullableCid -DA:98,258 -FNF:3 -FNH:3 -LF:13 -LH:13 -BRF:4 -BRH:4 -end_of_record -TN: -SF:test/comparison/CborDecode.sol -DA:55,1 -FN:55,CBORDecoder.isNullNext -FNDA:1,CBORDecoder.isNullNext -DA:56,1 -DA:63,2 -FN:63,CBORDecoder.readBool -FNDA:2,CBORDecoder.readBool -DA:64,2 -DA:65,2 -DA:67,2 -DA:68,2 -BRDA:68,0,0,- -BRDA:68,0,1,2 -DA:69,2 -DA:71,2 -DA:78,2 -FN:78,CBORDecoder.readFixedArray -FNDA:2,CBORDecoder.readFixedArray -DA:79,2 -DA:80,2 -DA:82,2 -DA:83,2 -BRDA:83,1,0,- -BRDA:83,1,1,2 -DA:85,2 -DA:92,3 -FN:92,CBORDecoder.readString -FNDA:3,CBORDecoder.readString -DA:93,3 -DA:94,3 -DA:96,3 -DA:97,3 -BRDA:97,2,0,- -BRDA:97,2,1,3 -DA:99,3 -DA:100,3 -DA:101,3 -DA:102,3 -DA:103,18 -DA:104,18 -DA:107,3 -DA:114,0 -FN:114,CBORDecoder.readBytes -FNDA:0,CBORDecoder.readBytes -DA:115,0 -DA:116,0 -DA:118,0 -DA:119,0 -BRDA:119,3,0,- -BRDA:119,3,1,- -DA:121,0 -BRDA:121,4,0,- -DA:122,0 -DA:123,0 -DA:126,0 -DA:127,0 -DA:128,0 -DA:129,0 -DA:130,0 -DA:131,0 -DA:134,0 -DA:141,0 -FN:141,CBORDecoder.readBytes32 -FNDA:0,CBORDecoder.readBytes32 -DA:142,0 -DA:143,0 -DA:145,0 -DA:146,0 -BRDA:146,5,0,- -BRDA:146,5,1,- -DA:148,0 -DA:149,0 -DA:150,0 -DA:151,0 -DA:152,0 -DA:153,0 -DA:156,0 -DA:163,0 -FN:163,CBORDecoder.readUInt256 -FNDA:0,CBORDecoder.readUInt256 -DA:164,0 -DA:165,0 -DA:167,0 -DA:168,0 -BRDA:168,6,0,- -BRDA:168,6,1,- -DA:170,0 -BRDA:170,7,0,- -DA:171,0 -BRDA:171,8,0,- -BRDA:171,8,1,- -DA:173,0 -DA:174,0 -DA:175,0 -BRDA:175,9,0,- -BRDA:175,9,1,- -DA:177,0 -BRDA:177,10,0,- -BRDA:177,10,1,- -DA:179,0 -DA:182,0 -DA:185,0 -DA:192,0 -FN:192,CBORDecoder.readInt256 -FNDA:0,CBORDecoder.readInt256 -DA:193,0 -DA:194,0 -DA:196,0 -DA:197,0 -BRDA:197,11,0,- -BRDA:197,11,1,- -DA:199,0 -BRDA:199,12,0,- -DA:200,0 -DA:202,0 -DA:203,0 -DA:204,0 -BRDA:204,13,0,- -BRDA:204,13,1,- -DA:206,0 -BRDA:206,14,0,- -BRDA:206,14,1,- -DA:208,0 -DA:211,0 -DA:214,0 -DA:221,0 -FN:221,CBORDecoder.readUInt64 -FNDA:0,CBORDecoder.readUInt64 -DA:222,0 -DA:223,0 -DA:225,0 -DA:226,0 -BRDA:226,15,0,- -BRDA:226,15,1,- -DA:228,0 -DA:235,0 -FN:235,CBORDecoder.readUInt32 -FNDA:0,CBORDecoder.readUInt32 -DA:236,0 -DA:237,0 -DA:239,0 -DA:240,0 -BRDA:240,16,0,- -BRDA:240,16,1,- -DA:242,0 -DA:249,0 -FN:249,CBORDecoder.readUInt16 -FNDA:0,CBORDecoder.readUInt16 -DA:250,0 -DA:251,0 -DA:253,0 -DA:254,0 -BRDA:254,17,0,- -BRDA:254,17,1,- -DA:256,0 -DA:263,16 -FN:263,CBORDecoder.readUInt8 -FNDA:16,CBORDecoder.readUInt8 -DA:264,16 -DA:265,16 -DA:267,16 -DA:268,16 -BRDA:268,18,0,- -BRDA:268,18,1,16 -DA:270,16 -DA:277,0 -FN:277,CBORDecoder.readInt64 -FNDA:0,CBORDecoder.readInt64 -DA:278,0 -DA:279,0 -DA:281,0 -DA:282,0 -BRDA:282,19,0,- -BRDA:282,19,1,- -DA:284,0 -DA:291,0 -FN:291,CBORDecoder.readInt32 -FNDA:0,CBORDecoder.readInt32 -DA:292,0 -DA:293,0 -DA:295,0 -DA:296,0 -BRDA:296,20,0,- -BRDA:296,20,1,- -DA:298,0 -DA:305,0 -FN:305,CBORDecoder.readInt16 -FNDA:0,CBORDecoder.readInt16 -DA:306,0 -DA:307,0 -DA:309,0 -DA:310,0 -BRDA:310,21,0,- -BRDA:310,21,1,- -DA:312,0 -DA:319,0 -FN:319,CBORDecoder.readInt8 -FNDA:0,CBORDecoder.readInt8 -DA:320,0 -DA:321,0 -DA:323,0 -DA:324,0 -BRDA:324,22,0,- -BRDA:324,22,1,- -DA:326,0 -DA:333,27 -FN:333,CBORDecoder.sliceUInt8 -FNDA:27,CBORDecoder.sliceUInt8 -DA:334,27 -BRDA:334,23,0,- -BRDA:334,23,1,27 -DA:335,27 -DA:342,0 -FN:342,CBORDecoder.sliceUInt16 -FNDA:0,CBORDecoder.sliceUInt16 -DA:343,0 -BRDA:343,24,0,- -BRDA:343,24,1,- -DA:344,0 -DA:346,0 -DA:348,0 -DA:355,0 -FN:355,CBORDecoder.sliceUInt32 -FNDA:0,CBORDecoder.sliceUInt32 -DA:356,0 -BRDA:356,25,0,- -BRDA:356,25,1,- -DA:357,0 -DA:359,0 -DA:361,0 -DA:368,0 -FN:368,CBORDecoder.sliceUInt64 -FNDA:0,CBORDecoder.sliceUInt64 -DA:369,0 -BRDA:369,26,0,- -BRDA:369,26,1,- -DA:370,0 -DA:372,0 -DA:374,0 -DA:381,23 -FN:381,CBORDecoder.parseCborHeader -FNDA:23,CBORDecoder.parseCborHeader -DA:382,23 -DA:383,23 -DA:384,23 -DA:385,23 -DA:387,23 -BRDA:387,27,0,- -BRDA:387,27,1,23 -DA:390,23 -BRDA:390,28,0,19 -DA:391,19 -DA:395,4 -BRDA:395,29,0,4 -DA:396,4 -DA:397,4 -DA:398,4 -BRDA:398,30,0,- -BRDA:398,30,1,4 -DA:399,4 -DA:403,0 -BRDA:403,31,0,- -DA:404,0 -DA:405,0 -DA:406,0 -DA:410,0 -BRDA:410,32,0,- -DA:411,0 -DA:412,0 -DA:413,0 -DA:417,0 -DA:418,0 -DA:419,0 -DA:420,0 -FNF:21 -FNH:7 -LF:173 -LH:49 -BRF:59 -BRH:9 -end_of_record diff --git a/snapshots/ArrayTest.json b/snapshots/ArrayTest.json deleted file mode 100644 index 2a87de9..0000000 --- a/snapshots/ArrayTest.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "Array_empty": "235", - "Array_large": "235", - "Array_mixed": "1722", - "Array_nested": "1960", - "Array_single": "628" -} \ No newline at end of file diff --git a/snapshots/BignumTest.json b/snapshots/BignumTest.json deleted file mode 100644 index 535509e..0000000 --- a/snapshots/BignumTest.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "Integer": "235", - "NInt256_max": "914", - "NInt256_middle": "235", - "NInt256_multi": "816", - "NInt256_single": "816", - "UInt256_max": "770", - "UInt256_middle": "672", - "UInt256_multi": "672", - "UInt256_single": "672" -} \ No newline at end of file diff --git a/snapshots/BytesTest.json b/snapshots/BytesTest.json deleted file mode 100644 index 1ff3fde..0000000 --- a/snapshots/BytesTest.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "Bytes32_short": "422", - "Bytes_empty": "408", - "Bytes_extended": "497", - "Bytes_short": "445", - "skipBytes": "306" -} \ No newline at end of file diff --git a/snapshots/CidSha256Test.json b/snapshots/CidSha256Test.json deleted file mode 100644 index a50b208..0000000 --- a/snapshots/CidSha256Test.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "Cid": "251", - "Cid_multicodec_raw": "202", - "NullableCid_nullCbor": "198" -} \ No newline at end of file diff --git a/snapshots/IntTest.json b/snapshots/IntTest.json deleted file mode 100644 index 3eafc68..0000000 --- a/snapshots/IntTest.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "Int_max": "495", - "Int_min": "630", - "Int_neg_one": "1111", - "Int_nint16": "572", - "Int_uint16": "437", - "Int_zero": "358" -} \ No newline at end of file diff --git a/snapshots/MapTest.json b/snapshots/MapTest.json deleted file mode 100644 index 397024c..0000000 --- a/snapshots/MapTest.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "Map_empty": "249", - "Map_nested": "6269", - "Map_nested2": "3236", - "Map_single": "1437" -} \ No newline at end of file diff --git a/snapshots/NIntTest.json b/snapshots/NIntTest.json deleted file mode 100644 index ab4aeef..0000000 --- a/snapshots/NIntTest.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "NInt": "556", - "NInt16": "536", - "NInt32": "565", - "NInt64": "600", - "NInt8_0": "332", - "NInt8_1": "332", - "NInt8_long": "431", - "NInt8_max": "430", - "NInt8_short": "333" -} \ No newline at end of file diff --git a/snapshots/PeekTest.json b/snapshots/PeekTest.json deleted file mode 100644 index e0e4374..0000000 --- a/snapshots/PeekTest.json +++ /dev/null @@ -1,28 +0,0 @@ -{ - "isArray_false": "0", - "isArray_true": "651", - "isBool_false_undefinedCbor": "0", - "isBool_true_falseCbor": "651", - "isBool_true_trueCbor": "648", - "isBytes_false": "0", - "isBytes_true": "651", - "isInt_false": "0", - "isInt_true_negativeCbor": "648", - "isInt_true_unsignedCbor": "699", - "isMap_false": "0", - "isMap_true": "651", - "isNInt_false": "60", - "isNInt_true": "651", - "isNull_false": "59", - "isNull_true": "651", - "isString_false": "0", - "isString_true": "651", - "isTag_expect_false": "181", - "isTag_expect_true": "794", - "isTag_false": "0", - "isTag_true": "651", - "isUInt_false": "0", - "isUInt_true": "681", - "isUndefined_false": "59", - "isUndefined_true": "651" -} \ No newline at end of file diff --git a/snapshots/SimpleTest.json b/snapshots/SimpleTest.json deleted file mode 100644 index 019d025..0000000 --- a/snapshots/SimpleTest.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "Boolean_false": "105", - "Boolean_true": "728", - "skipNull": "135", - "skipUndefined": "135" -} \ No newline at end of file diff --git a/snapshots/StringTest.json b/snapshots/StringTest.json deleted file mode 100644 index f49c4f6..0000000 --- a/snapshots/StringTest.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "String1": "97", - "String32_short": "422", - "String_empty": "408", - "String_extended": "445", - "String_short": "445", - "skipString": "306" -} \ No newline at end of file diff --git a/snapshots/TagTest.json b/snapshots/TagTest.json deleted file mode 100644 index 9f006fa..0000000 --- a/snapshots/TagTest.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "Tag": "293", - "Tag_expected": "314" -} \ No newline at end of file diff --git a/snapshots/UIntTest.json b/snapshots/UIntTest.json deleted file mode 100644 index 61c8b86..0000000 --- a/snapshots/UIntTest.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "UInt": "385", - "UInt16_max": "418", - "UInt32_max": "436", - "UInt64_max": "472", - "UInt8_0": "204", - "UInt8_1": "204", - "UInt8_extended": "303", - "UInt8_max": "302", - "UInt8_short": "205" -} \ No newline at end of file From e6050fd4c077b3a794d3e648f65ebb2f1073a948 Mon Sep 17 00:00:00 2001 From: turbocrime Date: Fri, 3 Jan 2025 22:52:20 -0800 Subject: [PATCH 6/8] create report scripts --- .github/workflows/test.yml | 34 +++++++++++++++++++++------------- foundry.toml | 22 +++++++++++----------- generate-snapshots.sh | 14 ++++++++++++++ 3 files changed, 46 insertions(+), 24 deletions(-) create mode 100644 generate-snapshots.sh diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1b8f80f..040c8ff 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -5,16 +5,17 @@ on: pull_request: workflow_dispatch: -env: - FOUNDRY_PROFILE: ci - jobs: check: strategy: fail-fast: true + matrix: + foundry_profile: ["test-via-ir", "test-no-ir"] name: Foundry project runs-on: ubuntu-latest + env: + FOUNDRY_PROFILE: ${{ matrix.foundry_profile }} steps: - uses: actions/checkout@v4 with: @@ -39,23 +40,30 @@ jobs: forge build --sizes id: build + # This `forge snapshot` command is only used for CBORDecoder comparison. + # https://book.getfoundry.sh/forge/gas-section-snapshots - name: Confirm comparison snapshot run: | - forge snapshot --match-path "test/comparison/*" --check + forge snapshot --check ${{ env.FOUNDRY_PROFILE }}.gas-snapshot \ + --match-path "test/comparison/*" id: comparison-snapshot - - name: Run all Forge tests + - name: Run remaining Forge tests, confirm section snapshots run: | - forge test -vvv + forge test -vvv \ + --no-match-path "test/comparison/*" + git diff --exit-code snapshots-${{ env.FOUNDRY_PROFILE }} id: test - - name: Confirm section snapshots - run: | - git diff --exit-code snapshots - id: diff-section-snapshots + # Coverage testing affects gas cost, and creates different snapshots. + # Only `lcov.info` is diffed to confirm coverage is checked in. Coverage + # doesn't use the 'comparison' tests. - name: Confirm coverage run: | - forge coverage --report lcov - git diff --exit-code lcov.info - id: diff-coverage \ No newline at end of file + forge coverage --report-file ${{ env.FOUNDRY_PROFILE }}.lcov.info \ + --report lcov --report summary \ + --no-match-path "test/comparison/*" \ + --no-match-coverage "test/comparison/*" + git diff --exit-code ${{ env.FOUNDRY_PROFILE }}.lcov.info + id: diff-coverage diff --git a/foundry.toml b/foundry.toml index 7c6fe95..3021958 100644 --- a/foundry.toml +++ b/foundry.toml @@ -1,17 +1,17 @@ [profile.default] -src = "src" -out = "out" -libs = ["lib"] -optimize = true +src = "src" +out = "out" +libs = ["lib"] +optimize = true optimizer_runs = 1000000 +[fmt] +int_types = "preserve" + [profile.test-no-ir] -via-ir = false +via-ir = false +snapshots = "snapshots-test-no-ir" [profile.test-via-ir] -via-ir = true - -# See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options - -[fmt] -int_types = "preserve" \ No newline at end of file +via-ir = true +snapshots = "snapshots-test-via-ir" diff --git a/generate-snapshots.sh b/generate-snapshots.sh new file mode 100644 index 0000000..c58defc --- /dev/null +++ b/generate-snapshots.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env sh + +set -euxo pipefail + +unset FORGE_GAS_REPORT +unset FOUNDRY_PROFILE +unset FOUNDRY_VIA_IR + +for test_profile in test-no-ir test-via-ir; do + export FOUNDRY_PROFILE=$test_profile + forge coverage --force --report-file $test_profile.lcov.info --report lcov --report summary --no-match-path "test/comparison/*" --no-match-coverage "test/comparison/*" + forge snapshot --force --snap $test_profile.gas-snapshot --match-path "test/comparison/*" + forge test --force -vvv --no-match-path "test/comparison/*" +done From ac167919d36fd73c85e532f4f7af9f4bf5dd8210 Mon Sep 17 00:00:00 2001 From: turbocrime Date: Fri, 3 Jan 2025 23:12:40 -0800 Subject: [PATCH 7/8] commit new reports --- snapshots-test-no-ir/ArrayTest.json | 7 + snapshots-test-no-ir/BignumTest.json | 11 + snapshots-test-no-ir/BytesTest.json | 7 + snapshots-test-no-ir/CidSha256Test.json | 5 + snapshots-test-no-ir/IntTest.json | 8 + snapshots-test-no-ir/MapTest.json | 6 + snapshots-test-no-ir/NIntTest.json | 11 + snapshots-test-no-ir/PeekTest.json | 28 ++ snapshots-test-no-ir/SimpleTest.json | 6 + snapshots-test-no-ir/StringTest.json | 8 + snapshots-test-no-ir/TagTest.json | 4 + snapshots-test-no-ir/UIntTest.json | 11 + snapshots-test-via-ir/ArrayTest.json | 7 + snapshots-test-via-ir/BignumTest.json | 11 + snapshots-test-via-ir/BytesTest.json | 7 + snapshots-test-via-ir/CidSha256Test.json | 5 + snapshots-test-via-ir/IntTest.json | 8 + snapshots-test-via-ir/MapTest.json | 6 + snapshots-test-via-ir/NIntTest.json | 11 + snapshots-test-via-ir/PeekTest.json | 28 ++ snapshots-test-via-ir/SimpleTest.json | 6 + snapshots-test-via-ir/StringTest.json | 8 + snapshots-test-via-ir/TagTest.json | 4 + snapshots-test-via-ir/UIntTest.json | 11 + test-no-ir.gas-snapshot | 16 + test-no-ir.lcov.info | 483 +++++++++++++++++++++++ test-via-ir.gas-snapshot | 16 + test-via-ir.lcov.info | 483 +++++++++++++++++++++++ 28 files changed, 1222 insertions(+) create mode 100644 snapshots-test-no-ir/ArrayTest.json create mode 100644 snapshots-test-no-ir/BignumTest.json create mode 100644 snapshots-test-no-ir/BytesTest.json create mode 100644 snapshots-test-no-ir/CidSha256Test.json create mode 100644 snapshots-test-no-ir/IntTest.json create mode 100644 snapshots-test-no-ir/MapTest.json create mode 100644 snapshots-test-no-ir/NIntTest.json create mode 100644 snapshots-test-no-ir/PeekTest.json create mode 100644 snapshots-test-no-ir/SimpleTest.json create mode 100644 snapshots-test-no-ir/StringTest.json create mode 100644 snapshots-test-no-ir/TagTest.json create mode 100644 snapshots-test-no-ir/UIntTest.json create mode 100644 snapshots-test-via-ir/ArrayTest.json create mode 100644 snapshots-test-via-ir/BignumTest.json create mode 100644 snapshots-test-via-ir/BytesTest.json create mode 100644 snapshots-test-via-ir/CidSha256Test.json create mode 100644 snapshots-test-via-ir/IntTest.json create mode 100644 snapshots-test-via-ir/MapTest.json create mode 100644 snapshots-test-via-ir/NIntTest.json create mode 100644 snapshots-test-via-ir/PeekTest.json create mode 100644 snapshots-test-via-ir/SimpleTest.json create mode 100644 snapshots-test-via-ir/StringTest.json create mode 100644 snapshots-test-via-ir/TagTest.json create mode 100644 snapshots-test-via-ir/UIntTest.json create mode 100644 test-no-ir.gas-snapshot create mode 100644 test-no-ir.lcov.info create mode 100644 test-via-ir.gas-snapshot create mode 100644 test-via-ir.lcov.info diff --git a/snapshots-test-no-ir/ArrayTest.json b/snapshots-test-no-ir/ArrayTest.json new file mode 100644 index 0000000..2a87de9 --- /dev/null +++ b/snapshots-test-no-ir/ArrayTest.json @@ -0,0 +1,7 @@ +{ + "Array_empty": "235", + "Array_large": "235", + "Array_mixed": "1722", + "Array_nested": "1960", + "Array_single": "628" +} \ No newline at end of file diff --git a/snapshots-test-no-ir/BignumTest.json b/snapshots-test-no-ir/BignumTest.json new file mode 100644 index 0000000..535509e --- /dev/null +++ b/snapshots-test-no-ir/BignumTest.json @@ -0,0 +1,11 @@ +{ + "Integer": "235", + "NInt256_max": "914", + "NInt256_middle": "235", + "NInt256_multi": "816", + "NInt256_single": "816", + "UInt256_max": "770", + "UInt256_middle": "672", + "UInt256_multi": "672", + "UInt256_single": "672" +} \ No newline at end of file diff --git a/snapshots-test-no-ir/BytesTest.json b/snapshots-test-no-ir/BytesTest.json new file mode 100644 index 0000000..1ff3fde --- /dev/null +++ b/snapshots-test-no-ir/BytesTest.json @@ -0,0 +1,7 @@ +{ + "Bytes32_short": "422", + "Bytes_empty": "408", + "Bytes_extended": "497", + "Bytes_short": "445", + "skipBytes": "306" +} \ No newline at end of file diff --git a/snapshots-test-no-ir/CidSha256Test.json b/snapshots-test-no-ir/CidSha256Test.json new file mode 100644 index 0000000..a50b208 --- /dev/null +++ b/snapshots-test-no-ir/CidSha256Test.json @@ -0,0 +1,5 @@ +{ + "Cid": "251", + "Cid_multicodec_raw": "202", + "NullableCid_nullCbor": "198" +} \ No newline at end of file diff --git a/snapshots-test-no-ir/IntTest.json b/snapshots-test-no-ir/IntTest.json new file mode 100644 index 0000000..3eafc68 --- /dev/null +++ b/snapshots-test-no-ir/IntTest.json @@ -0,0 +1,8 @@ +{ + "Int_max": "495", + "Int_min": "630", + "Int_neg_one": "1111", + "Int_nint16": "572", + "Int_uint16": "437", + "Int_zero": "358" +} \ No newline at end of file diff --git a/snapshots-test-no-ir/MapTest.json b/snapshots-test-no-ir/MapTest.json new file mode 100644 index 0000000..397024c --- /dev/null +++ b/snapshots-test-no-ir/MapTest.json @@ -0,0 +1,6 @@ +{ + "Map_empty": "249", + "Map_nested": "6269", + "Map_nested2": "3236", + "Map_single": "1437" +} \ No newline at end of file diff --git a/snapshots-test-no-ir/NIntTest.json b/snapshots-test-no-ir/NIntTest.json new file mode 100644 index 0000000..ab4aeef --- /dev/null +++ b/snapshots-test-no-ir/NIntTest.json @@ -0,0 +1,11 @@ +{ + "NInt": "556", + "NInt16": "536", + "NInt32": "565", + "NInt64": "600", + "NInt8_0": "332", + "NInt8_1": "332", + "NInt8_long": "431", + "NInt8_max": "430", + "NInt8_short": "333" +} \ No newline at end of file diff --git a/snapshots-test-no-ir/PeekTest.json b/snapshots-test-no-ir/PeekTest.json new file mode 100644 index 0000000..e0e4374 --- /dev/null +++ b/snapshots-test-no-ir/PeekTest.json @@ -0,0 +1,28 @@ +{ + "isArray_false": "0", + "isArray_true": "651", + "isBool_false_undefinedCbor": "0", + "isBool_true_falseCbor": "651", + "isBool_true_trueCbor": "648", + "isBytes_false": "0", + "isBytes_true": "651", + "isInt_false": "0", + "isInt_true_negativeCbor": "648", + "isInt_true_unsignedCbor": "699", + "isMap_false": "0", + "isMap_true": "651", + "isNInt_false": "60", + "isNInt_true": "651", + "isNull_false": "59", + "isNull_true": "651", + "isString_false": "0", + "isString_true": "651", + "isTag_expect_false": "181", + "isTag_expect_true": "794", + "isTag_false": "0", + "isTag_true": "651", + "isUInt_false": "0", + "isUInt_true": "681", + "isUndefined_false": "59", + "isUndefined_true": "651" +} \ No newline at end of file diff --git a/snapshots-test-no-ir/SimpleTest.json b/snapshots-test-no-ir/SimpleTest.json new file mode 100644 index 0000000..019d025 --- /dev/null +++ b/snapshots-test-no-ir/SimpleTest.json @@ -0,0 +1,6 @@ +{ + "Boolean_false": "105", + "Boolean_true": "728", + "skipNull": "135", + "skipUndefined": "135" +} \ No newline at end of file diff --git a/snapshots-test-no-ir/StringTest.json b/snapshots-test-no-ir/StringTest.json new file mode 100644 index 0000000..f49c4f6 --- /dev/null +++ b/snapshots-test-no-ir/StringTest.json @@ -0,0 +1,8 @@ +{ + "String1": "97", + "String32_short": "422", + "String_empty": "408", + "String_extended": "445", + "String_short": "445", + "skipString": "306" +} \ No newline at end of file diff --git a/snapshots-test-no-ir/TagTest.json b/snapshots-test-no-ir/TagTest.json new file mode 100644 index 0000000..9f006fa --- /dev/null +++ b/snapshots-test-no-ir/TagTest.json @@ -0,0 +1,4 @@ +{ + "Tag": "293", + "Tag_expected": "314" +} \ No newline at end of file diff --git a/snapshots-test-no-ir/UIntTest.json b/snapshots-test-no-ir/UIntTest.json new file mode 100644 index 0000000..61c8b86 --- /dev/null +++ b/snapshots-test-no-ir/UIntTest.json @@ -0,0 +1,11 @@ +{ + "UInt": "385", + "UInt16_max": "418", + "UInt32_max": "436", + "UInt64_max": "472", + "UInt8_0": "204", + "UInt8_1": "204", + "UInt8_extended": "303", + "UInt8_max": "302", + "UInt8_short": "205" +} \ No newline at end of file diff --git a/snapshots-test-via-ir/ArrayTest.json b/snapshots-test-via-ir/ArrayTest.json new file mode 100644 index 0000000..45ff96a --- /dev/null +++ b/snapshots-test-via-ir/ArrayTest.json @@ -0,0 +1,7 @@ +{ + "Array_empty": "210", + "Array_large": "210", + "Array_mixed": "1597", + "Array_nested": "1693", + "Array_single": "642" +} \ No newline at end of file diff --git a/snapshots-test-via-ir/BignumTest.json b/snapshots-test-via-ir/BignumTest.json new file mode 100644 index 0000000..ddc5752 --- /dev/null +++ b/snapshots-test-via-ir/BignumTest.json @@ -0,0 +1,11 @@ +{ + "Integer": "208", + "NInt256_max": "932", + "NInt256_middle": "207", + "NInt256_multi": "785", + "NInt256_single": "779", + "UInt256_max": "784", + "UInt256_middle": "641", + "UInt256_multi": "637", + "UInt256_single": "631" +} \ No newline at end of file diff --git a/snapshots-test-via-ir/BytesTest.json b/snapshots-test-via-ir/BytesTest.json new file mode 100644 index 0000000..35d14ef --- /dev/null +++ b/snapshots-test-via-ir/BytesTest.json @@ -0,0 +1,7 @@ +{ + "Bytes32_short": "260", + "Bytes_empty": "574", + "Bytes_extended": "640", + "Bytes_short": "580", + "skipBytes": "297" +} \ No newline at end of file diff --git a/snapshots-test-via-ir/CidSha256Test.json b/snapshots-test-via-ir/CidSha256Test.json new file mode 100644 index 0000000..cd3dc21 --- /dev/null +++ b/snapshots-test-via-ir/CidSha256Test.json @@ -0,0 +1,5 @@ +{ + "Cid": "272", + "Cid_multicodec_raw": "189", + "NullableCid_nullCbor": "227" +} \ No newline at end of file diff --git a/snapshots-test-via-ir/IntTest.json b/snapshots-test-via-ir/IntTest.json new file mode 100644 index 0000000..5eeb9f7 --- /dev/null +++ b/snapshots-test-via-ir/IntTest.json @@ -0,0 +1,8 @@ +{ + "Int_max": "311", + "Int_min": "361", + "Int_neg_one": "906", + "Int_nint16": "320", + "Int_uint16": "265", + "Int_zero": "189" +} \ No newline at end of file diff --git a/snapshots-test-via-ir/MapTest.json b/snapshots-test-via-ir/MapTest.json new file mode 100644 index 0000000..311db35 --- /dev/null +++ b/snapshots-test-via-ir/MapTest.json @@ -0,0 +1,6 @@ +{ + "Map_empty": "210", + "Map_nested": "4993", + "Map_nested2": "2599", + "Map_single": "1353" +} \ No newline at end of file diff --git a/snapshots-test-via-ir/NIntTest.json b/snapshots-test-via-ir/NIntTest.json new file mode 100644 index 0000000..713a6c7 --- /dev/null +++ b/snapshots-test-via-ir/NIntTest.json @@ -0,0 +1,11 @@ +{ + "NInt": "426", + "NInt16": "432", + "NInt32": "398", + "NInt64": "459", + "NInt8_0": "233", + "NInt8_1": "233", + "NInt8_long": "347", + "NInt8_max": "347", + "NInt8_short": "233" +} \ No newline at end of file diff --git a/snapshots-test-via-ir/PeekTest.json b/snapshots-test-via-ir/PeekTest.json new file mode 100644 index 0000000..f6d6645 --- /dev/null +++ b/snapshots-test-via-ir/PeekTest.json @@ -0,0 +1,28 @@ +{ + "isArray_false": "161", + "isArray_true": "832", + "isBool_false_undefinedCbor": "161", + "isBool_true_falseCbor": "847", + "isBool_true_trueCbor": "844", + "isBytes_false": "161", + "isBytes_true": "826", + "isInt_false": "152", + "isInt_true_negativeCbor": "841", + "isInt_true_unsignedCbor": "844", + "isMap_false": "167", + "isMap_true": "826", + "isNInt_false": "167", + "isNInt_true": "826", + "isNull_false": "167", + "isNull_true": "832", + "isString_false": "161", + "isString_true": "826", + "isTag_expect_false": "254", + "isTag_expect_true": "910", + "isTag_false": "167", + "isTag_true": "826", + "isUInt_false": "151", + "isUInt_true": "829", + "isUndefined_false": "155", + "isUndefined_true": "832" +} \ No newline at end of file diff --git a/snapshots-test-via-ir/SimpleTest.json b/snapshots-test-via-ir/SimpleTest.json new file mode 100644 index 0000000..1c56448 --- /dev/null +++ b/snapshots-test-via-ir/SimpleTest.json @@ -0,0 +1,6 @@ +{ + "Boolean_false": "132", + "Boolean_true": "794", + "skipNull": "91", + "skipUndefined": "96" +} \ No newline at end of file diff --git a/snapshots-test-via-ir/StringTest.json b/snapshots-test-via-ir/StringTest.json new file mode 100644 index 0000000..a31c940 --- /dev/null +++ b/snapshots-test-via-ir/StringTest.json @@ -0,0 +1,8 @@ +{ + "String1": "113", + "String32_short": "257", + "String_empty": "573", + "String_extended": "585", + "String_short": "585", + "skipString": "297" +} \ No newline at end of file diff --git a/snapshots-test-via-ir/TagTest.json b/snapshots-test-via-ir/TagTest.json new file mode 100644 index 0000000..7fb26f3 --- /dev/null +++ b/snapshots-test-via-ir/TagTest.json @@ -0,0 +1,4 @@ +{ + "Tag": "149", + "Tag_expected": "201" +} \ No newline at end of file diff --git a/snapshots-test-via-ir/UIntTest.json b/snapshots-test-via-ir/UIntTest.json new file mode 100644 index 0000000..e70ba0b --- /dev/null +++ b/snapshots-test-via-ir/UIntTest.json @@ -0,0 +1,11 @@ +{ + "UInt": "269", + "UInt16_max": "352", + "UInt32_max": "341", + "UInt64_max": "367", + "UInt8_0": "178", + "UInt8_1": "178", + "UInt8_extended": "277", + "UInt8_max": "277", + "UInt8_short": "178" +} \ No newline at end of file diff --git a/test-no-ir.gas-snapshot b/test-no-ir.gas-snapshot new file mode 100644 index 0000000..31d13d9 --- /dev/null +++ b/test-no-ir.gas-snapshot @@ -0,0 +1,16 @@ +ComparisonTest:test_decodeArrayU8_CBORDecoder() (gas: 5274) +ComparisonTest:test_decodeArrayU8_ReadCbor() (gas: 2334) +ComparisonTest:test_decodeFalse_CBORDecoder() (gas: 916) +ComparisonTest:test_decodeFalse_ReadCbor() (gas: 425) +ComparisonTest:test_decodeFixedArray_CBORDecoder() (gas: 9207) +ComparisonTest:test_decodeFixedArray_ReadCbor() (gas: 4234) +ComparisonTest:test_decodeInteger_CBORDecoder() (gas: 884) +ComparisonTest:test_decodeInteger_ReadCbor() (gas: 554) +ComparisonTest:test_decodeNull_CBORDecoder() (gas: 396) +ComparisonTest:test_decodeNull_ReadCbor() (gas: 240) +ComparisonTest:test_decodeStringWithWeirdChar_CBORDecoder() (gas: 2356) +ComparisonTest:test_decodeStringWithWeirdChar_ReadCbor() (gas: 884) +ComparisonTest:test_decodeString_CBORDecoder() (gas: 3869) +ComparisonTest:test_decodeString_ReadCbor() (gas: 957) +ComparisonTest:test_decodeTrue_CBORDecoder() (gas: 937) +ComparisonTest:test_decodeTrue_ReadCbor() (gas: 483) \ No newline at end of file diff --git a/test-no-ir.lcov.info b/test-no-ir.lcov.info new file mode 100644 index 0000000..51f5fac --- /dev/null +++ b/test-no-ir.lcov.info @@ -0,0 +1,483 @@ +TN: +SF:src/ReadCbor.sol +DA:33,818 +FN:33,ReadCbor.parseArg +FNDA:818,ReadCbor.parseArg +DA:34,818 +BRDA:34,0,0,541 +BRDA:34,0,1,256 +DA:35,541 +DA:36,277 +BRDA:36,1,0,3 +BRDA:36,1,1,256 +DA:37,3 +DA:38,3 +BRDA:38,2,0,1 +BRDA:38,2,1,2 +DA:39,274 +BRDA:39,3,0,7 +BRDA:39,3,1,256 +DA:40,7 +DA:41,267 +BRDA:41,4,0,4 +BRDA:41,4,1,256 +DA:42,4 +DA:43,263 +BRDA:43,5,0,7 +BRDA:43,5,1,256 +DA:44,7 +DA:46,256 +DA:50,827 +FN:50,ReadCbor.u8 +FNDA:827,ReadCbor.u8 +DA:53,827 +DA:54,827 +DA:58,7 +FN:58,ReadCbor.u16 +FNDA:7,ReadCbor.u16 +DA:61,7 +DA:62,7 +DA:66,4 +FN:66,ReadCbor.u32 +FNDA:4,ReadCbor.u32 +DA:69,4 +DA:70,4 +DA:74,7 +FN:74,ReadCbor.u64 +FNDA:7,ReadCbor.u64 +DA:77,7 +DA:78,7 +DA:88,274 +FN:88,ReadCbor.header +FNDA:274,ReadCbor.header +DA:89,274 +DA:90,274 +DA:91,274 +DA:92,274 +DA:93,274 +DA:103,540 +FN:103,ReadCbor.header +FNDA:540,ReadCbor.header +DA:104,540 +DA:105,540 +DA:106,540 +BRDA:106,6,0,2 +BRDA:106,6,1,538 +DA:107,538 +DA:118,10 +FN:118,ReadCbor.header +FNDA:10,ReadCbor.header +DA:123,10 +DA:124,10 +DA:125,10 +DA:126,10 +BRDA:126,7,0,2 +BRDA:126,7,1,8 +DA:127,8 +DA:128,8 +BRDA:128,8,0,2 +BRDA:128,8,1,6 +DA:129,6 +DA:139,575 +FN:139,ReadCbor.header8 +FNDA:575,ReadCbor.header8 +DA:140,575 +DA:143,575 +DA:144,575 +DA:145,575 +DA:146,575 +DA:149,575 +BRDA:149,9,0,1 +BRDA:149,9,1,574 +DA:151,574 +BRDA:151,10,0,531 +DA:152,531 +BRDA:152,11,0,2 +BRDA:152,11,1,529 +DA:154,529 +DA:155,529 +DA:157,529 +BRDA:157,12,0,2 +BRDA:157,12,1,527 +DA:160,570 +DA:170,40 +FN:170,ReadCbor.header32 +FNDA:40,ReadCbor.header32 +DA:171,40 +DA:174,40 +DA:175,40 +DA:176,40 +DA:177,40 +DA:180,40 +BRDA:180,13,0,2 +BRDA:180,13,1,38 +DA:182,38 +BRDA:182,14,0,2 +BRDA:182,14,1,1 +DA:184,2 +DA:185,2 +DA:187,2 +BRDA:187,15,0,1 +BRDA:187,15,1,1 +DA:188,36 +BRDA:188,16,0,3 +DA:189,3 +BRDA:189,17,0,1 +BRDA:189,17,1,2 +DA:190,2 +BRDA:190,18,0,1 +BRDA:190,18,1,1 +DA:192,1 +DA:193,1 +DA:195,1 +BRDA:195,19,0,1 +DA:197,1 +DA:198,1 +DA:203,36 +DA:210,262 +FN:210,ReadCbor.isNull +FNDA:262,ReadCbor.isNull +DA:212,262 +DA:221,2 +FN:221,ReadCbor.Null +FNDA:2,ReadCbor.Null +DA:222,2 +BRDA:222,20,0,1 +BRDA:222,20,1,1 +DA:223,1 +DA:230,4 +FN:230,ReadCbor.isUndefined +FNDA:4,ReadCbor.isUndefined +DA:232,4 +DA:241,2 +FN:241,ReadCbor.Undefined +FNDA:2,ReadCbor.Undefined +DA:242,2 +BRDA:242,21,0,1 +BRDA:242,21,1,1 +DA:243,1 +DA:250,3 +FN:250,ReadCbor.isBool +FNDA:3,ReadCbor.isBool +DA:252,3 +DA:253,3 +DA:267,3 +FN:267,ReadCbor.Bool +FNDA:3,ReadCbor.Bool +DA:268,3 +DA:270,3 +DA:271,3 +DA:272,3 +DA:273,3 +DA:275,3 +BRDA:275,22,0,1 +BRDA:275,22,1,2 +DA:282,2 +FN:282,ReadCbor.isArray +FNDA:2,ReadCbor.isArray +DA:284,2 +DA:293,13 +FN:293,ReadCbor.Array +FNDA:13,ReadCbor.Array +DA:296,13 +DA:303,2 +FN:303,ReadCbor.isMap +FNDA:2,ReadCbor.isMap +DA:305,2 +DA:314,9 +FN:314,ReadCbor.Map +FNDA:9,ReadCbor.Map +DA:318,9 +DA:325,2 +FN:325,ReadCbor.isString +FNDA:2,ReadCbor.isString +DA:327,2 +DA:336,7 +FN:336,ReadCbor.String +FNDA:7,ReadCbor.String +DA:337,7 +DA:338,7 +DA:340,7 +DA:342,7 +DA:343,7 +DA:344,7 +DA:345,7 +DA:357,14 +FN:357,ReadCbor.String32 +FNDA:14,ReadCbor.String32 +DA:358,14 +DA:359,13 +DA:360,13 +BRDA:360,23,0,1 +BRDA:360,23,1,12 +DA:363,12 +DA:364,12 +DA:365,12 +DA:369,2 +FN:369,ReadCbor.String32 +FNDA:2,ReadCbor.String32 +DA:370,2 +DA:379,2 +FN:379,ReadCbor.String1 +FNDA:2,ReadCbor.String1 +DA:380,2 +DA:382,2 +DA:383,2 +DA:384,2 +DA:385,2 +DA:387,2 +BRDA:387,24,0,1 +BRDA:387,24,1,1 +DA:394,2 +FN:394,ReadCbor.skipString +FNDA:2,ReadCbor.skipString +DA:395,2 +DA:396,2 +DA:397,1 +DA:404,2 +FN:404,ReadCbor.isBytes +FNDA:2,ReadCbor.isBytes +DA:406,2 +DA:415,3 +FN:415,ReadCbor.Bytes +FNDA:3,ReadCbor.Bytes +DA:416,3 +DA:417,3 +DA:419,3 +DA:421,3 +DA:422,3 +DA:423,3 +DA:424,3 +DA:436,3 +FN:436,ReadCbor.Bytes32 +FNDA:3,ReadCbor.Bytes32 +DA:437,3 +DA:438,2 +DA:439,2 +BRDA:439,25,0,1 +BRDA:439,25,1,1 +DA:442,1 +DA:443,1 +DA:444,1 +DA:448,2 +FN:448,ReadCbor.Bytes32 +FNDA:2,ReadCbor.Bytes32 +DA:449,2 +DA:456,2 +FN:456,ReadCbor.skipBytes +FNDA:2,ReadCbor.skipBytes +DA:457,2 +DA:458,2 +DA:459,1 +DA:466,15 +FN:466,ReadCbor.isTag +FNDA:15,ReadCbor.isTag +DA:468,15 +DA:477,770 +FN:477,ReadCbor.isTag +FNDA:770,ReadCbor.isTag +DA:478,770 +DA:480,770 +DA:482,770 +BRDA:482,26,0,- +DA:483,770 +DA:484,770 +DA:485,770 +BRDA:485,27,0,- +DA:487,768 +DA:488,768 +DA:489,512 +DA:490,256 +DA:491,0 +DA:494,770 +DA:504,7 +FN:504,ReadCbor.Tag +FNDA:7,ReadCbor.Tag +DA:505,7 +DA:514,530 +FN:514,ReadCbor.Tag +FNDA:530,ReadCbor.Tag +DA:515,530 +DA:516,530 +BRDA:516,28,0,1 +BRDA:516,28,1,529 +DA:517,529 +DA:524,2 +FN:524,ReadCbor.isUInt +FNDA:2,ReadCbor.isUInt +DA:526,2 +DA:535,1 +FN:535,ReadCbor.UInt +FNDA:1,ReadCbor.UInt +DA:536,1 +DA:544,24 +FN:544,ReadCbor.UInt8 +FNDA:24,ReadCbor.UInt8 +DA:545,24 +DA:553,2 +FN:553,ReadCbor.UInt16 +FNDA:2,ReadCbor.UInt16 +DA:554,2 +DA:555,2 +DA:556,1 +DA:564,1 +FN:564,ReadCbor.UInt32 +FNDA:1,ReadCbor.UInt32 +DA:565,1 +DA:566,1 +DA:567,1 +DA:575,1 +FN:575,ReadCbor.UInt64 +FNDA:1,ReadCbor.UInt64 +DA:576,1 +DA:583,2 +FN:583,ReadCbor.isNInt +FNDA:2,ReadCbor.isNInt +DA:585,2 +DA:594,1 +FN:594,ReadCbor.NInt +FNDA:1,ReadCbor.NInt +DA:595,1 +DA:596,1 +DA:597,1 +DA:605,7 +FN:605,ReadCbor.NInt8 +FNDA:7,ReadCbor.NInt8 +DA:606,7 +DA:607,7 +DA:608,5 +DA:616,3 +FN:616,ReadCbor.NInt16 +FNDA:3,ReadCbor.NInt16 +DA:617,3 +DA:618,3 +DA:619,1 +DA:627,1 +FN:627,ReadCbor.NInt32 +FNDA:1,ReadCbor.NInt32 +DA:628,1 +DA:629,1 +DA:630,1 +DA:638,1 +FN:638,ReadCbor.NInt64 +FNDA:1,ReadCbor.NInt64 +DA:639,1 +DA:640,1 +DA:641,1 +DA:648,3 +FN:648,ReadCbor.isInt +FNDA:3,ReadCbor.isInt +DA:650,3 +DA:651,3 +DA:660,16 +FN:660,ReadCbor.Int +FNDA:16,ReadCbor.Int +DA:661,16 +DA:662,16 +DA:663,16 +DA:664,16 +BRDA:664,29,0,8 +BRDA:664,29,1,1 +DA:665,8 +DA:666,8 +BRDA:666,30,0,7 +BRDA:666,30,1,1 +DA:667,7 +DA:669,1 +FNF:49 +FNH:49 +LF:229 +LH:228 +BRF:57 +BRH:55 +end_of_record +TN: +SF:src/tags/ReadBignum.sol +DA:12,263 +FN:12,ReadBignum.UInt256 +FNDA:263,ReadBignum.UInt256 +DA:13,263 +DA:14,263 +DA:15,263 +DA:16,263 +BRDA:16,0,0,1 +BRDA:16,0,1,262 +DA:19,262 +DA:26,262 +DA:30,265 +FN:30,ReadBignum.NInt256 +FNDA:265,ReadBignum.NInt256 +DA:31,265 +DA:32,265 +DA:33,265 +DA:34,265 +BRDA:34,1,0,1 +BRDA:34,1,1,264 +DA:36,264 +DA:38,264 +DA:45,264 +DA:48,264 +BRDA:48,2,0,2 +BRDA:48,2,1,262 +DA:49,262 +DA:52,5 +FN:52,ReadBignum.Int256 +FNDA:5,ReadBignum.Int256 +DA:53,5 +DA:54,5 +BRDA:54,3,0,2 +BRDA:54,3,1,1 +DA:55,2 +DA:56,2 +DA:57,2 +BRDA:57,4,0,1 +BRDA:57,4,1,1 +DA:58,1 +DA:59,3 +BRDA:59,5,0,2 +BRDA:59,5,1,1 +DA:60,2 +DA:62,1 +DA:66,13 +FN:66,ReadBignum.Integer +FNDA:13,ReadBignum.Integer +DA:67,13 +FNF:4 +FNH:4 +LF:29 +LH:29 +BRF:12 +BRH:12 +end_of_record +TN: +SF:src/tags/ReadCidSha256.sol +DA:66,512 +FN:66,ReadCidSha256.Cid +FNDA:512,ReadCidSha256.Cid +DA:67,512 +DA:70,513 +FN:70,ReadCidSha256.Cid +FNDA:513,ReadCidSha256.Cid +DA:71,513 +DA:72,513 +DA:75,513 +DA:81,513 +DA:82,513 +DA:83,513 +DA:86,513 +BRDA:86,0,0,1 +BRDA:86,0,1,512 +DA:87,512 +BRDA:87,1,0,2 +BRDA:87,1,1,510 +DA:97,258 +FN:97,ReadCidSha256.NullableCid +FNDA:258,ReadCidSha256.NullableCid +DA:98,258 +FNF:3 +FNH:3 +LF:13 +LH:13 +BRF:4 +BRH:4 +end_of_record diff --git a/test-via-ir.gas-snapshot b/test-via-ir.gas-snapshot new file mode 100644 index 0000000..4b038ba --- /dev/null +++ b/test-via-ir.gas-snapshot @@ -0,0 +1,16 @@ +ComparisonTest:test_decodeArrayU8_CBORDecoder() (gas: 5298) +ComparisonTest:test_decodeArrayU8_ReadCbor() (gas: 2177) +ComparisonTest:test_decodeFalse_CBORDecoder() (gas: 1028) +ComparisonTest:test_decodeFalse_ReadCbor() (gas: 480) +ComparisonTest:test_decodeFixedArray_CBORDecoder() (gas: 9100) +ComparisonTest:test_decodeFixedArray_ReadCbor() (gas: 4056) +ComparisonTest:test_decodeInteger_CBORDecoder() (gas: 1125) +ComparisonTest:test_decodeInteger_ReadCbor() (gas: 757) +ComparisonTest:test_decodeNull_CBORDecoder() (gas: 462) +ComparisonTest:test_decodeNull_ReadCbor() (gas: 499) +ComparisonTest:test_decodeStringWithWeirdChar_CBORDecoder() (gas: 2804) +ComparisonTest:test_decodeStringWithWeirdChar_ReadCbor() (gas: 1047) +ComparisonTest:test_decodeString_CBORDecoder() (gas: 4715) +ComparisonTest:test_decodeString_ReadCbor() (gas: 1326) +ComparisonTest:test_decodeTrue_CBORDecoder() (gas: 1105) +ComparisonTest:test_decodeTrue_ReadCbor() (gas: 487) \ No newline at end of file diff --git a/test-via-ir.lcov.info b/test-via-ir.lcov.info new file mode 100644 index 0000000..51f5fac --- /dev/null +++ b/test-via-ir.lcov.info @@ -0,0 +1,483 @@ +TN: +SF:src/ReadCbor.sol +DA:33,818 +FN:33,ReadCbor.parseArg +FNDA:818,ReadCbor.parseArg +DA:34,818 +BRDA:34,0,0,541 +BRDA:34,0,1,256 +DA:35,541 +DA:36,277 +BRDA:36,1,0,3 +BRDA:36,1,1,256 +DA:37,3 +DA:38,3 +BRDA:38,2,0,1 +BRDA:38,2,1,2 +DA:39,274 +BRDA:39,3,0,7 +BRDA:39,3,1,256 +DA:40,7 +DA:41,267 +BRDA:41,4,0,4 +BRDA:41,4,1,256 +DA:42,4 +DA:43,263 +BRDA:43,5,0,7 +BRDA:43,5,1,256 +DA:44,7 +DA:46,256 +DA:50,827 +FN:50,ReadCbor.u8 +FNDA:827,ReadCbor.u8 +DA:53,827 +DA:54,827 +DA:58,7 +FN:58,ReadCbor.u16 +FNDA:7,ReadCbor.u16 +DA:61,7 +DA:62,7 +DA:66,4 +FN:66,ReadCbor.u32 +FNDA:4,ReadCbor.u32 +DA:69,4 +DA:70,4 +DA:74,7 +FN:74,ReadCbor.u64 +FNDA:7,ReadCbor.u64 +DA:77,7 +DA:78,7 +DA:88,274 +FN:88,ReadCbor.header +FNDA:274,ReadCbor.header +DA:89,274 +DA:90,274 +DA:91,274 +DA:92,274 +DA:93,274 +DA:103,540 +FN:103,ReadCbor.header +FNDA:540,ReadCbor.header +DA:104,540 +DA:105,540 +DA:106,540 +BRDA:106,6,0,2 +BRDA:106,6,1,538 +DA:107,538 +DA:118,10 +FN:118,ReadCbor.header +FNDA:10,ReadCbor.header +DA:123,10 +DA:124,10 +DA:125,10 +DA:126,10 +BRDA:126,7,0,2 +BRDA:126,7,1,8 +DA:127,8 +DA:128,8 +BRDA:128,8,0,2 +BRDA:128,8,1,6 +DA:129,6 +DA:139,575 +FN:139,ReadCbor.header8 +FNDA:575,ReadCbor.header8 +DA:140,575 +DA:143,575 +DA:144,575 +DA:145,575 +DA:146,575 +DA:149,575 +BRDA:149,9,0,1 +BRDA:149,9,1,574 +DA:151,574 +BRDA:151,10,0,531 +DA:152,531 +BRDA:152,11,0,2 +BRDA:152,11,1,529 +DA:154,529 +DA:155,529 +DA:157,529 +BRDA:157,12,0,2 +BRDA:157,12,1,527 +DA:160,570 +DA:170,40 +FN:170,ReadCbor.header32 +FNDA:40,ReadCbor.header32 +DA:171,40 +DA:174,40 +DA:175,40 +DA:176,40 +DA:177,40 +DA:180,40 +BRDA:180,13,0,2 +BRDA:180,13,1,38 +DA:182,38 +BRDA:182,14,0,2 +BRDA:182,14,1,1 +DA:184,2 +DA:185,2 +DA:187,2 +BRDA:187,15,0,1 +BRDA:187,15,1,1 +DA:188,36 +BRDA:188,16,0,3 +DA:189,3 +BRDA:189,17,0,1 +BRDA:189,17,1,2 +DA:190,2 +BRDA:190,18,0,1 +BRDA:190,18,1,1 +DA:192,1 +DA:193,1 +DA:195,1 +BRDA:195,19,0,1 +DA:197,1 +DA:198,1 +DA:203,36 +DA:210,262 +FN:210,ReadCbor.isNull +FNDA:262,ReadCbor.isNull +DA:212,262 +DA:221,2 +FN:221,ReadCbor.Null +FNDA:2,ReadCbor.Null +DA:222,2 +BRDA:222,20,0,1 +BRDA:222,20,1,1 +DA:223,1 +DA:230,4 +FN:230,ReadCbor.isUndefined +FNDA:4,ReadCbor.isUndefined +DA:232,4 +DA:241,2 +FN:241,ReadCbor.Undefined +FNDA:2,ReadCbor.Undefined +DA:242,2 +BRDA:242,21,0,1 +BRDA:242,21,1,1 +DA:243,1 +DA:250,3 +FN:250,ReadCbor.isBool +FNDA:3,ReadCbor.isBool +DA:252,3 +DA:253,3 +DA:267,3 +FN:267,ReadCbor.Bool +FNDA:3,ReadCbor.Bool +DA:268,3 +DA:270,3 +DA:271,3 +DA:272,3 +DA:273,3 +DA:275,3 +BRDA:275,22,0,1 +BRDA:275,22,1,2 +DA:282,2 +FN:282,ReadCbor.isArray +FNDA:2,ReadCbor.isArray +DA:284,2 +DA:293,13 +FN:293,ReadCbor.Array +FNDA:13,ReadCbor.Array +DA:296,13 +DA:303,2 +FN:303,ReadCbor.isMap +FNDA:2,ReadCbor.isMap +DA:305,2 +DA:314,9 +FN:314,ReadCbor.Map +FNDA:9,ReadCbor.Map +DA:318,9 +DA:325,2 +FN:325,ReadCbor.isString +FNDA:2,ReadCbor.isString +DA:327,2 +DA:336,7 +FN:336,ReadCbor.String +FNDA:7,ReadCbor.String +DA:337,7 +DA:338,7 +DA:340,7 +DA:342,7 +DA:343,7 +DA:344,7 +DA:345,7 +DA:357,14 +FN:357,ReadCbor.String32 +FNDA:14,ReadCbor.String32 +DA:358,14 +DA:359,13 +DA:360,13 +BRDA:360,23,0,1 +BRDA:360,23,1,12 +DA:363,12 +DA:364,12 +DA:365,12 +DA:369,2 +FN:369,ReadCbor.String32 +FNDA:2,ReadCbor.String32 +DA:370,2 +DA:379,2 +FN:379,ReadCbor.String1 +FNDA:2,ReadCbor.String1 +DA:380,2 +DA:382,2 +DA:383,2 +DA:384,2 +DA:385,2 +DA:387,2 +BRDA:387,24,0,1 +BRDA:387,24,1,1 +DA:394,2 +FN:394,ReadCbor.skipString +FNDA:2,ReadCbor.skipString +DA:395,2 +DA:396,2 +DA:397,1 +DA:404,2 +FN:404,ReadCbor.isBytes +FNDA:2,ReadCbor.isBytes +DA:406,2 +DA:415,3 +FN:415,ReadCbor.Bytes +FNDA:3,ReadCbor.Bytes +DA:416,3 +DA:417,3 +DA:419,3 +DA:421,3 +DA:422,3 +DA:423,3 +DA:424,3 +DA:436,3 +FN:436,ReadCbor.Bytes32 +FNDA:3,ReadCbor.Bytes32 +DA:437,3 +DA:438,2 +DA:439,2 +BRDA:439,25,0,1 +BRDA:439,25,1,1 +DA:442,1 +DA:443,1 +DA:444,1 +DA:448,2 +FN:448,ReadCbor.Bytes32 +FNDA:2,ReadCbor.Bytes32 +DA:449,2 +DA:456,2 +FN:456,ReadCbor.skipBytes +FNDA:2,ReadCbor.skipBytes +DA:457,2 +DA:458,2 +DA:459,1 +DA:466,15 +FN:466,ReadCbor.isTag +FNDA:15,ReadCbor.isTag +DA:468,15 +DA:477,770 +FN:477,ReadCbor.isTag +FNDA:770,ReadCbor.isTag +DA:478,770 +DA:480,770 +DA:482,770 +BRDA:482,26,0,- +DA:483,770 +DA:484,770 +DA:485,770 +BRDA:485,27,0,- +DA:487,768 +DA:488,768 +DA:489,512 +DA:490,256 +DA:491,0 +DA:494,770 +DA:504,7 +FN:504,ReadCbor.Tag +FNDA:7,ReadCbor.Tag +DA:505,7 +DA:514,530 +FN:514,ReadCbor.Tag +FNDA:530,ReadCbor.Tag +DA:515,530 +DA:516,530 +BRDA:516,28,0,1 +BRDA:516,28,1,529 +DA:517,529 +DA:524,2 +FN:524,ReadCbor.isUInt +FNDA:2,ReadCbor.isUInt +DA:526,2 +DA:535,1 +FN:535,ReadCbor.UInt +FNDA:1,ReadCbor.UInt +DA:536,1 +DA:544,24 +FN:544,ReadCbor.UInt8 +FNDA:24,ReadCbor.UInt8 +DA:545,24 +DA:553,2 +FN:553,ReadCbor.UInt16 +FNDA:2,ReadCbor.UInt16 +DA:554,2 +DA:555,2 +DA:556,1 +DA:564,1 +FN:564,ReadCbor.UInt32 +FNDA:1,ReadCbor.UInt32 +DA:565,1 +DA:566,1 +DA:567,1 +DA:575,1 +FN:575,ReadCbor.UInt64 +FNDA:1,ReadCbor.UInt64 +DA:576,1 +DA:583,2 +FN:583,ReadCbor.isNInt +FNDA:2,ReadCbor.isNInt +DA:585,2 +DA:594,1 +FN:594,ReadCbor.NInt +FNDA:1,ReadCbor.NInt +DA:595,1 +DA:596,1 +DA:597,1 +DA:605,7 +FN:605,ReadCbor.NInt8 +FNDA:7,ReadCbor.NInt8 +DA:606,7 +DA:607,7 +DA:608,5 +DA:616,3 +FN:616,ReadCbor.NInt16 +FNDA:3,ReadCbor.NInt16 +DA:617,3 +DA:618,3 +DA:619,1 +DA:627,1 +FN:627,ReadCbor.NInt32 +FNDA:1,ReadCbor.NInt32 +DA:628,1 +DA:629,1 +DA:630,1 +DA:638,1 +FN:638,ReadCbor.NInt64 +FNDA:1,ReadCbor.NInt64 +DA:639,1 +DA:640,1 +DA:641,1 +DA:648,3 +FN:648,ReadCbor.isInt +FNDA:3,ReadCbor.isInt +DA:650,3 +DA:651,3 +DA:660,16 +FN:660,ReadCbor.Int +FNDA:16,ReadCbor.Int +DA:661,16 +DA:662,16 +DA:663,16 +DA:664,16 +BRDA:664,29,0,8 +BRDA:664,29,1,1 +DA:665,8 +DA:666,8 +BRDA:666,30,0,7 +BRDA:666,30,1,1 +DA:667,7 +DA:669,1 +FNF:49 +FNH:49 +LF:229 +LH:228 +BRF:57 +BRH:55 +end_of_record +TN: +SF:src/tags/ReadBignum.sol +DA:12,263 +FN:12,ReadBignum.UInt256 +FNDA:263,ReadBignum.UInt256 +DA:13,263 +DA:14,263 +DA:15,263 +DA:16,263 +BRDA:16,0,0,1 +BRDA:16,0,1,262 +DA:19,262 +DA:26,262 +DA:30,265 +FN:30,ReadBignum.NInt256 +FNDA:265,ReadBignum.NInt256 +DA:31,265 +DA:32,265 +DA:33,265 +DA:34,265 +BRDA:34,1,0,1 +BRDA:34,1,1,264 +DA:36,264 +DA:38,264 +DA:45,264 +DA:48,264 +BRDA:48,2,0,2 +BRDA:48,2,1,262 +DA:49,262 +DA:52,5 +FN:52,ReadBignum.Int256 +FNDA:5,ReadBignum.Int256 +DA:53,5 +DA:54,5 +BRDA:54,3,0,2 +BRDA:54,3,1,1 +DA:55,2 +DA:56,2 +DA:57,2 +BRDA:57,4,0,1 +BRDA:57,4,1,1 +DA:58,1 +DA:59,3 +BRDA:59,5,0,2 +BRDA:59,5,1,1 +DA:60,2 +DA:62,1 +DA:66,13 +FN:66,ReadBignum.Integer +FNDA:13,ReadBignum.Integer +DA:67,13 +FNF:4 +FNH:4 +LF:29 +LH:29 +BRF:12 +BRH:12 +end_of_record +TN: +SF:src/tags/ReadCidSha256.sol +DA:66,512 +FN:66,ReadCidSha256.Cid +FNDA:512,ReadCidSha256.Cid +DA:67,512 +DA:70,513 +FN:70,ReadCidSha256.Cid +FNDA:513,ReadCidSha256.Cid +DA:71,513 +DA:72,513 +DA:75,513 +DA:81,513 +DA:82,513 +DA:83,513 +DA:86,513 +BRDA:86,0,0,1 +BRDA:86,0,1,512 +DA:87,512 +BRDA:87,1,0,2 +BRDA:87,1,1,510 +DA:97,258 +FN:97,ReadCidSha256.NullableCid +FNDA:258,ReadCidSha256.NullableCid +DA:98,258 +FNF:3 +FNH:3 +LF:13 +LH:13 +BRF:4 +BRH:4 +end_of_record From 13be99a4148353a7e6a3b6414c3f78f73f2f306c Mon Sep 17 00:00:00 2001 From: turbocrime Date: Fri, 3 Jan 2025 23:29:36 -0800 Subject: [PATCH 8/8] deduplicate workflow execution --- .github/workflows/test.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 040c8ff..6b36d8e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -2,6 +2,8 @@ name: CI on: push: + branches: + - main pull_request: workflow_dispatch: