forked from ethereum/solidity
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: Move hashing algorithm tests to semanticTests
- Loading branch information
Showing
8 changed files
with
77 additions
and
196 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
test/libsolidity/semanticTests/builtinFunctions/keccak256.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
contract C { | ||
function f(int256 input) public returns (bytes32 sha256hash) { | ||
return keccak256(abi.encodePacked(bytes32(uint256(input)))); | ||
} | ||
} | ||
// ---- | ||
// f(int256): 4 -> 0x8a35acfbc15ff81a39ae7d344fd709f28e8600b4aa8c65c6b64bfe7fe36bd19b | ||
// f(int256): 5 -> 0x036b6384b5eca791c62761152d0c79bb0604c104a5fb6f4eb0703f3154bb3db0 | ||
// f(int256): -1 -> 0xa9c584056064687e149968cbab758a3376d22aedc6a55823d1b3ecbee81b8fb9 |
12 changes: 12 additions & 0 deletions
12
test/libsolidity/semanticTests/builtinFunctions/keccak256_packed.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
contract C { | ||
function f(int256 _input) public returns (bytes32 hash) { | ||
uint24 b = 65536; | ||
uint c = 256; | ||
bytes32 input = bytes32(uint256(_input)); | ||
return keccak256(abi.encodePacked(uint8(8), input, b, input, c)); | ||
} | ||
} | ||
// ---- | ||
// f(int256): 4 -> 0xd270285b9966fefc715561efcd09d5b6a8deb15596f7c53cb4a1bb73aa55ac3a | ||
// f(int256): 5 -> 0xf2f92566c5653600c1e527a7073e5d881576d12bb51887c0b8f3e1f81865b03d | ||
// f(int256): -1 -> 0xbc78b45e0db67af5af72e4ab62757c67aefa7388cdf0c4e74f8b5fe9dd5d9d13 |
14 changes: 14 additions & 0 deletions
14
test/libsolidity/semanticTests/builtinFunctions/keccak256_packed_complex_types.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
contract C { | ||
uint120[3] x; | ||
function f() public returns (bytes32 hash1, bytes32 hash2, bytes32 hash3) { | ||
uint120[] memory y = new uint120[](3); | ||
x[0] = y[0] = uint120(type(uint).max - 1); | ||
x[1] = y[1] = uint120(type(uint).max - 2); | ||
x[2] = y[2] = uint120(type(uint).max - 3); | ||
hash1 = keccak256(abi.encodePacked(x)); | ||
hash2 = keccak256(abi.encodePacked(y)); | ||
hash3 = keccak256(abi.encodePacked(this.f)); | ||
} | ||
} | ||
// ---- | ||
// f() -> 0xba4f20407251e4607cd66b90bfea19ec6971699c03e4a4f3ea737d5818ac27ae, 0xba4f20407251e4607cd66b90bfea19ec6971699c03e4a4f3ea737d5818ac27ae, 0x0e9229fb1d2cd02cee4b6c9f25497777014a8766e3479666d1c619066d2887ec |
9 changes: 9 additions & 0 deletions
9
test/libsolidity/semanticTests/builtinFunctions/ripemd160.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
contract C { | ||
function f(int256 input) public returns (bytes32 sha256hash) { | ||
return ripemd160(abi.encodePacked(bytes32(uint256(input)))); | ||
} | ||
} | ||
// ---- | ||
// f(int256): 4 -> 0x1b0f3c404d12075c68c938f9f60ebea4f74941a0000000000000000000000000 | ||
// f(int256): 5 -> 0xee54aa84fc32d8fed5a5fe160442ae84626829d9000000000000000000000000 | ||
// f(int256): -1 -> 0x1cf4e77f5966e13e109703cd8a0df7ceda7f3dc3000000000000000000000000 |
12 changes: 12 additions & 0 deletions
12
test/libsolidity/semanticTests/builtinFunctions/ripemd160_packed.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
contract C { | ||
function f(int256 _input) public returns (bytes32 hash) { | ||
uint24 b = 65536; | ||
uint c = 256; | ||
bytes32 input = bytes32(uint256(_input)); | ||
return ripemd160(abi.encodePacked(uint8(8), input, b, input, c)); | ||
} | ||
} | ||
// ---- | ||
// f(int256): 4 -> 0xf93175303eba2a7b372174fc9330237f5ad202fc000000000000000000000000 | ||
// f(int256): 5 -> 0x04f4fc112e2bfbe0d38f896a46629e08e2fcfad5000000000000000000000000 | ||
// f(int256): -1 -> 0xc0a2e4b1f3ff766a9a0089e7a410391730872495000000000000000000000000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
contract C { | ||
function f(int256 input) public returns (bytes32 sha256hash) { | ||
return sha256(abi.encodePacked(bytes32(uint256(input)))); | ||
} | ||
} | ||
// ---- | ||
// f(int256): 4 -> 0xe38990d0c7fc009880a9c07c23842e886c6bbdc964ce6bdd5817ad357335ee6f | ||
// f(int256): 5 -> 0x96de8fc8c256fa1e1556d41af431cace7dca68707c78dd88c3acab8b17164c47 | ||
// f(int256): -1 -> 0xaf9613760f72635fbdb44a5a0a63c39f12af30f950a6ee5c971be188e89c4051 |
12 changes: 12 additions & 0 deletions
12
test/libsolidity/semanticTests/builtinFunctions/sha256_packed.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
contract C { | ||
function f(int256 _input) public returns (bytes32 hash) { | ||
uint24 b = 65536; | ||
uint c = 256; | ||
bytes32 input = bytes32(uint256(_input)); | ||
return sha256(abi.encodePacked(uint8(8), input, b, input, c)); | ||
} | ||
} | ||
// ---- | ||
// f(int256): 4 -> 0x804e0d7003cfd70fc925dc103174d9f898ebb142ecc2a286da1abd22ac2ce3ac | ||
// f(int256): 5 -> 0xe94921945f9068726c529a290a954f412bcac53184bb41224208a31edbf63cf0 | ||
// f(int256): -1 -> 0xf14def4d07cd185ddd8b10a81b2238326196a38867e6e6adbcc956dc913488c7 |