chore: fmt and slither

This commit is contained in:
royvardhan
2025-01-23 19:03:42 +05:30
parent ae662d0026
commit ef2600b7f8
2 changed files with 22 additions and 18 deletions

View File

@@ -1,5 +1,5 @@
// SPDX-License-Identifier: UNLICENSED // SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.0; pragma solidity ^0.8.28;
/** /**
* @title Propellerheads PrefixLengthEncoded Byte Array Library * @title Propellerheads PrefixLengthEncoded Byte Array Library

View File

@@ -2,7 +2,8 @@
pragma solidity ^0.8.0; pragma solidity ^0.8.0;
import {Test} from "forge-std/Test.sol"; import {Test} from "forge-std/Test.sol";
import {LibPrefixLengthEncodedByteArray} from "../src/lib/LibPrefixLengthEncodedByteArray.sol"; import {LibPrefixLengthEncodedByteArray} from
"../src/lib/LibPrefixLengthEncodedByteArray.sol";
contract LibPrefixLengthEncodedByteArrayTest is Test { contract LibPrefixLengthEncodedByteArrayTest is Test {
using LibPrefixLengthEncodedByteArray for bytes; using LibPrefixLengthEncodedByteArray for bytes;
@@ -53,13 +54,13 @@ contract LibPrefixLengthEncodedByteArrayTest is Test {
function testFailInvalidLength() public { function testFailInvalidLength() public {
// Length prefix larger than remaining data // Length prefix larger than remaining data
bytes memory invalid = hex"0004414243"; bytes memory invalid = hex"0004414243";
this.next(invalid); (bytes memory elem, bytes memory remaining) = this.next(invalid);
} }
function testFailIncompletePrefix() public { function testFailIncompletePrefix() public {
// Only 1 byte instead of 2 bytes prefix // Only 1 byte instead of 2 bytes prefix
bytes memory invalid = hex"01"; bytes memory invalid = hex"01";
this.next(invalid); (bytes memory elem, bytes memory remaining) = this.next(invalid);
} }
function testLargeElement() public { function testLargeElement() public {
@@ -69,7 +70,7 @@ contract LibPrefixLengthEncodedByteArrayTest is Test {
large[1] = bytes1(uint8(0xe8)); // E8 (1000 in hex) large[1] = bytes1(uint8(0xe8)); // E8 (1000 in hex)
// Fill data bytes // Fill data bytes
for (uint i = 2; i < large.length; i++) { for (uint256 i = 2; i < large.length; i++) {
large[i] = bytes1(uint8(0x01)); large[i] = bytes1(uint8(0x01));
} }
@@ -93,12 +94,15 @@ contract LibPrefixLengthEncodedByteArrayTest is Test {
assertEq(this.size(data), 2); assertEq(this.size(data), 2);
} }
function next(bytes calldata data) external pure returns (bytes memory, bytes memory) { function next(bytes calldata data)
return data.next(); external
pure
returns (bytes memory elem, bytes memory remaining)
{
(elem, remaining) = data.next();
} }
function size(bytes calldata data) external pure returns (uint256) { function size(bytes calldata data) external pure returns (uint256 s) {
return data.size(); s = data.size();
} }
} }