diff --git a/script/test/Merkle.s.t.sol b/script/test/Merkle.s.t.sol index db1b0bf..11a03a9 100644 --- a/script/test/Merkle.s.t.sol +++ b/script/test/Merkle.s.t.sol @@ -22,7 +22,7 @@ contract MerkleScriptOutputTest is Test, ScriptHelper { uint256 value = 10000; uint256 index = 1; - function testAbiEncode(address a, uint256 b, uint256 c) public { + function testAbiEncode(address a, uint256 b, uint256 c) public pure { vm.assume(a != address(0)); vm.assume(b != 0); vm.assume(c != 0); @@ -39,24 +39,24 @@ contract MerkleScriptOutputTest is Test, ScriptHelper { assertEq(abi.encode(a, b, c), ltrim64(abi.encode(_bytes))); } - function testComputeLeaf() public { + function testComputeLeaf() public view { bytes32 computedLeaf = keccak256(bytes.concat(keccak256(abi.encode(addr, value, index)))); assertEq(computedLeaf, leaf); } - function testVerify() public { + function testVerify() public view { bytes32 computedLeaf = keccak256(bytes.concat(keccak256(abi.encode(addr, value, index)))); assertTrue(MerkleProof.verify(proof, root, computedLeaf)); } - function testFalseAddress(address a) public { + function testFalseAddress(address a) public view { vm.assume(a != addr); bytes32 computedLeaf = keccak256(bytes.concat(keccak256(abi.encode(a, value, index)))); assertFalse(MerkleProof.verify(proof, root, computedLeaf)); } - function testFalseValue(uint256 b, uint256 c) public { + function testFalseValue(uint256 b, uint256 c) public view { vm.assume(b != value); vm.assume(c != index); diff --git a/src/test/CompleteMerkle.t.sol b/src/test/CompleteMerkle.t.sol index 9bbdd03..50ac99f 100644 --- a/src/test/CompleteMerkle.t.sol +++ b/src/test/CompleteMerkle.t.sol @@ -57,15 +57,6 @@ contract GasComparisonTests is Test { assertTrue(MerkleProof.verify(proof, root, valueToProve)); } - // function testVerifyProofOzForGasComparison(bytes32[] memory data, uint256 node) public view { - // vm.assume(data.length > 1); - // vm.assume(node < data.length); - // bytes32 root = m.getRoot(data); - // bytes32[] memory proof = m.getProof(data, node); - // bytes32 valueToProve = data[node]; - // assertTrue(MerkleProof.verify(proof, root, valueToProve)); - // } - function testWontGetRootSingleLeaf() public { bytes32[] memory data = new bytes32[](1); data[0] = bytes32(0x0); diff --git a/src/test/Merkle.t.sol b/src/test/Merkle.t.sol index fae0fe7..08fb0c7 100644 --- a/src/test/Merkle.t.sol +++ b/src/test/Merkle.t.sol @@ -12,7 +12,7 @@ contract ContractTest is Test { m = new Merkle(); } - function testHashes(bytes32 left, bytes32 right) public { + function testHashes(bytes32 left, bytes32 right) public view { bytes32 hAssem = m.hashLeafPairs(left, right); bytes memory packed; if (left <= right) { @@ -24,7 +24,7 @@ contract ContractTest is Test { assertEq(hAssem, hNaive); } - function testGenerateProof(bytes32[] memory data, uint256 node) public { + function testGenerateProof(bytes32[] memory data, uint256 node) public view { vm.assume(data.length > 1); vm.assume(node < data.length); bytes32 root = m.getRoot(data); @@ -38,7 +38,7 @@ contract ContractTest is Test { assertEq(rollingHash, root); } - function testVerifyProof(bytes32[] memory data, uint256 node) public { + function testVerifyProof(bytes32[] memory data, uint256 node) public view { vm.assume(data.length > 1); vm.assume(node < data.length); bytes32 root = m.getRoot(data); @@ -47,7 +47,7 @@ contract ContractTest is Test { assertTrue(m.verifyProof(root, proof, valueToProve)); } - function testFailVerifyProof(bytes32[] memory data, bytes32 valueToProve, uint256 node) public { + function testFailVerifyProof(bytes32[] memory data, bytes32 valueToProve, uint256 node) public view { vm.assume(data.length > 1); vm.assume(node < data.length); vm.assume(valueNotInArray(data, valueToProve)); @@ -56,7 +56,7 @@ contract ContractTest is Test { assertTrue(m.verifyProof(root, proof, valueToProve)); } - function testVerifyProofOzForGasComparison(bytes32[] memory data, uint256 node) public { + function testVerifyProofOzForGasComparison(bytes32[] memory data, uint256 node) public view { vm.assume(data.length > 1); vm.assume(node < data.length); bytes32 root = m.getRoot(data); diff --git a/src/test/MurkyBase.t.sol b/src/test/MurkyBase.t.sol index db38c5d..f1dea57 100644 --- a/src/test/MurkyBase.t.sol +++ b/src/test/MurkyBase.t.sol @@ -19,11 +19,11 @@ contract MurkyBaseTest is Test, MurkyBase { this.log2ceilBitMagic(x); } - function testLogCeil_KnownPowerOf2() public { + function testLogCeil_KnownPowerOf2() public view { assertEq(3, this.log2ceilBitMagic(8)); } - function testLogCeil_Known() public { + function testLogCeil_Known() public view { assertEq(8, this.log2ceilBitMagic((129))); } } diff --git a/src/test/Xorkle.t.sol b/src/test/Xorkle.t.sol index d37ac39..a3643f8 100644 --- a/src/test/Xorkle.t.sol +++ b/src/test/Xorkle.t.sol @@ -11,13 +11,13 @@ contract ContractTest is Test { m = new Xorkle(); } - function testHashes(bytes32 left, bytes32 right) public { + function testHashes(bytes32 left, bytes32 right) public view { bytes32 hAssem = m.hashLeafPairs(left, right); bytes32 hNaive = keccak256(abi.encode(left ^ right)); assertEq(hAssem, hNaive); } - function testGenerateProof(bytes32[] memory data, uint256 node) public { + function testGenerateProof(bytes32[] memory data, uint256 node) public view { vm.assume(data.length > 1); vm.assume(node < data.length); bytes32 root = m.getRoot(data); @@ -31,7 +31,7 @@ contract ContractTest is Test { assertEq(rollingHash, root); } - function testVerifyProof(bytes32[] memory data, uint256 node) public { + function testVerifyProof(bytes32[] memory data, uint256 node) public view { vm.assume(data.length > 1); vm.assume(node < data.length); bytes32 root = m.getRoot(data); @@ -40,7 +40,7 @@ contract ContractTest is Test { assertTrue(m.verifyProof(root, proof, valueToProve)); } - function testFailVerifyProof(bytes32[] memory data, bytes32 valueToProve, uint256 node) public { + function testFailVerifyProof(bytes32[] memory data, bytes32 valueToProve, uint256 node) public view { vm.assume(data.length > 1); vm.assume(node < data.length); vm.assume(valueNotInArray(data, valueToProve));