Skip to content

Commit

Permalink
chore: add ci and license
Browse files Browse the repository at this point in the history
  • Loading branch information
kopy-kat committed May 21, 2024
1 parent bd0c0f4 commit 32f52ad
Show file tree
Hide file tree
Showing 7 changed files with 72 additions and 46 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
on:
workflow_dispatch:
push:
branches:
- "main"
pull_request:

jobs:
lint:
uses: "rhinestonewtf/reusable-workflows/.github/workflows/forge-lint.yaml@main"

build:
uses: "rhinestonewtf/reusable-workflows/.github/workflows/forge-build.yaml@main"

test:
needs: ["lint", "build"]
uses: "rhinestonewtf/reusable-workflows/.github/workflows/forge-test.yaml@main"
with:
foundry-fuzz-runs: 5000
foundry-profile: "test"
match-path: "test/**/*.sol"
34 changes: 0 additions & 34 deletions .github/workflows/test.yml

This file was deleted.

20 changes: 20 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Copyright (c) 2024 Rhinestone

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
12 changes: 11 additions & 1 deletion foundry.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
[profile.default]
emv_version = "paris"
src = "src"
out = "out"
script = "script"
libs = ["node_modules"]

# See more config options https://github.com/foundry-rs/foundry/blob/master/crates/config/README.md#all-options
[fmt]
bracket_spacing = true
int_types = "long"
line_length = 100
multiline_func_header = "all"
number_underscore = "thousands"
quote_style = "double"
tab_width = 4
wrap_comments = true
6 changes: 5 additions & 1 deletion src/BytesLib.sol
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,11 @@ library AssociatedBytesLib {
INTERNAL
//////////////////////////////////////////////////////////////////////////*/

function toArray(bytes memory data) internal pure returns (uint256 totalLength, bytes32[] memory dataList) {
function toArray(bytes memory data)
internal
pure
returns (uint256 totalLength, bytes32[] memory dataList)
{
// Find 32 bytes segments nb
totalLength = data.length;
if (totalLength > 32 * 10) revert();
Expand Down
12 changes: 7 additions & 5 deletions test/BytesLib.t.sol
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;

import {Test} from "forge-std/Test.sol";
import {AssociatedBytesLib} from "../src/BytesLib.sol";
import { Test } from "forge-std/Test.sol";
import { AssociatedBytesLib } from "../src/BytesLib.sol";

contract BytesLibTest is Test {
using AssociatedBytesLib for AssociatedBytesLib.Bytes;
Expand All @@ -11,10 +11,11 @@ contract BytesLibTest is Test {
AssociatedBytesLib.Bytes data;
mapping(address account => AssociatedBytesLib.Bytes) internal dataMapping;

function setUp() public {}
function setUp() public { }

function testStore() public {
bytes memory _data = hex"424141414141414141414141414141414141414141414141414141414141414141414143";
bytes memory _data =
hex"424141414141414141414141414141414141414141414141414141414141414141414143";

vm.record();
data.store(_data);
Expand All @@ -32,7 +33,8 @@ contract BytesLibTest is Test {
}

function testStore_WhenUsing_Mapping() public {
bytes memory _data = hex"424141414141414141414141414141414141414141414141414141414141414141414143";
bytes memory _data =
hex"424141414141414141414141414141414141414141414141414141414141414141414143";

vm.record();
dataMapping[address(2)].store(_data);
Expand Down
13 changes: 8 additions & 5 deletions test/GasTest.t.sol
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;

import {Test, console2} from "forge-std/Test.sol";
import {AssociatedBytesLib} from "../src/BytesLib.sol";
import { Test, console2 } from "forge-std/Test.sol";
import { AssociatedBytesLib } from "../src/BytesLib.sol";

contract GasTest is Test {
using AssociatedBytesLib for AssociatedBytesLib.Bytes;

bytes _data;
AssociatedBytesLib.Bytes _bytesData;

function setUp() public {}
function setUp() public { }

function gasDiff(bytes memory d) public {
uint256 gasSplit = gasleft();
Expand All @@ -28,7 +28,8 @@ contract GasTest is Test {
}

function testGas_Short() public {
bytes memory d = hex"424141414141414141414141414141414141414141414141414141414141414141414143";
bytes memory d =
hex"424141414141414141414141414141414141414141414141414141414141414141414143";
gasDiff(d);
}

Expand All @@ -41,7 +42,9 @@ contract GasTest is Test {
function testGas_Long() public {
bytes memory d;
for (uint256 i = 0; i < 5; i++) {
d = abi.encodePacked(d, hex"424141414141414141414141414141414141414141414141414141414141414141414143");
d = abi.encodePacked(
d, hex"424141414141414141414141414141414141414141414141414141414141414141414143"
);
}
gasDiff(d);
}
Expand Down

0 comments on commit 32f52ad

Please sign in to comment.