forked from erc6900/reference-implementation
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathModuleEntityLib.t.sol
More file actions
40 lines (34 loc) · 1.4 KB
/
ModuleEntityLib.t.sol
File metadata and controls
40 lines (34 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.20;
import {Test} from "forge-std/Test.sol";
import {ModuleEntity} from "../../src/interfaces/IERC6900Account.sol";
import {ModuleEntityLib} from "../../src/libraries/ModuleEntityLib.sol";
contract ModuleEntityLibTest is Test {
using ModuleEntityLib for ModuleEntity;
function testFuzz_moduleEntity_packing(address addr, uint32 entityId) public {
// console.log("addr: ", addr);
// console.log("entityId: ", vm.toString(entityId));
ModuleEntity fr = ModuleEntityLib.pack(addr, entityId);
// console.log("packed: ", vm.toString(ModuleEntity.unwrap(fr)));
(address addr2, uint32 entityId2) = ModuleEntityLib.unpack(fr);
// console.log("addr2: ", addr2);
// console.log("entityId2: ", vm.toString(entityId2));
assertEq(addr, addr2);
assertEq(entityId, entityId2);
}
function testFuzz_moduleEntity_operators(ModuleEntity a, ModuleEntity b) public {
assertTrue(a.eq(a));
assertTrue(b.eq(b));
if (ModuleEntity.unwrap(a) == ModuleEntity.unwrap(b)) {
assertTrue(a.eq(b));
assertTrue(b.eq(a));
assertFalse(a.notEq(b));
assertFalse(b.notEq(a));
} else {
assertTrue(a.notEq(b));
assertTrue(b.notEq(a));
assertFalse(a.eq(b));
assertFalse(b.eq(a));
}
}
}