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
pragma solidity ^0.8.0;
pragma solidity ^0.8.28;
/**
* @title Propellerheads PrefixLengthEncoded Byte Array Library

View File

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