-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
P-872 basic tests for contracts #2845
Changes from 39 commits
d3ea195
2e88fc5
dfa6209
0fcdfbb
0985212
4b2f338
a754ddc
517247e
f89dc9b
11f5120
43e08ac
cc9a2e6
93b1b6a
40d28e3
652c31a
1d610d6
d3a51bf
55b5b31
e564c68
0b5e07c
02fdf52
96b6e12
4528895
cbb53d2
0db373c
7222141
5b8d21d
ec52653
1ffe7eb
3be94c5
cc0ef83
553e23a
083a692
23e74d8
11301ba
291d52f
96a8370
1a1a00e
c278f1d
546f2e6
57f9ca1
7575924
7a47838
e6127d8
fc8a2a2
bfca5e3
fd93583
53dcc06
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
services: | ||
lit-assertion-contracts-test: | ||
image: litentry/identity-cli:latest | ||
container_name: lit-assertion-contracts-test | ||
volumes: | ||
- ../ts-tests:/ts-tests | ||
- ../client-api:/client-api | ||
- ../cli:/usr/local/worker-cli | ||
- ../litentry/core/assertion-build/src/dynamic/contracts:/assertion-contracts | ||
|
||
build: | ||
context: .. | ||
dockerfile: build.Dockerfile | ||
target: deployed-client | ||
depends_on: | ||
litentry-node: | ||
condition: service_healthy | ||
litentry-worker-1: | ||
condition: service_healthy | ||
networks: | ||
- litentry-test-network | ||
entrypoint: "bash -c '/usr/local/worker-cli/lit_ts_integration_test.sh assertion_contracts.test.ts 2>&1' " | ||
restart: "no" | ||
networks: | ||
litentry-test-network: | ||
driver: bridge |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,7 @@ | |
|
||
pragma solidity ^0.8.8; | ||
|
||
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v4.9.0/contracts/utils/Strings.sol"; | ||
import "./openzeppelin/Strings.sol"; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Any benefit to hard code this imported code in our repo instead keeping them imported from remote during build time? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Contracts import via http cannot be decoded and compiled by any compiler, so the contract will be flattened here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Will flattened code break the solc-related complier? Will it break hardhat compiler too (if not we could use hardhat to test and remain the import from source maybe)? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hardhat does not support compiling with HTTP imports, only ESM import mode is supported. |
||
import "./libraries/AssertionLogic.sol"; | ||
import "./libraries/Http.sol"; | ||
import "./libraries/Identities.sol"; | ||
|
0xverin marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
// SPDX-License-Identifier: MIT | ||
// OpenZeppelin Contracts (last updated v4.9.0) (utils/Strings.sol) | ||
|
||
pragma solidity ^0.8.0; | ||
|
||
import "./math/Math.sol"; | ||
import "./math/SignedMath.sol"; | ||
|
||
/** | ||
* @dev String operations. | ||
*/ | ||
library Strings { | ||
bytes16 private constant _SYMBOLS = "0123456789abcdef"; | ||
uint8 private constant _ADDRESS_LENGTH = 20; | ||
|
||
/** | ||
* @dev Converts a `uint256` to its ASCII `string` decimal representation. | ||
*/ | ||
function toString(uint256 value) internal pure returns (string memory) { | ||
unchecked { | ||
uint256 length = Math.log10(value) + 1; | ||
string memory buffer = new string(length); | ||
uint256 ptr; | ||
/// @solidity memory-safe-assembly | ||
assembly { | ||
ptr := add(buffer, add(32, length)) | ||
} | ||
while (true) { | ||
ptr--; | ||
/// @solidity memory-safe-assembly | ||
assembly { | ||
mstore8(ptr, byte(mod(value, 10), _SYMBOLS)) | ||
} | ||
value /= 10; | ||
if (value == 0) break; | ||
} | ||
return buffer; | ||
} | ||
} | ||
|
||
/** | ||
* @dev Converts a `int256` to its ASCII `string` decimal representation. | ||
*/ | ||
function toString(int256 value) internal pure returns (string memory) { | ||
return string(abi.encodePacked(value < 0 ? "-" : "", toString(SignedMath.abs(value)))); | ||
} | ||
|
||
/** | ||
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. | ||
*/ | ||
function toHexString(uint256 value) internal pure returns (string memory) { | ||
unchecked { | ||
return toHexString(value, Math.log256(value) + 1); | ||
} | ||
} | ||
|
||
/** | ||
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. | ||
*/ | ||
function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { | ||
bytes memory buffer = new bytes(2 * length + 2); | ||
buffer[0] = "0"; | ||
buffer[1] = "x"; | ||
for (uint256 i = 2 * length + 1; i > 1; --i) { | ||
buffer[i] = _SYMBOLS[value & 0xf]; | ||
value >>= 4; | ||
} | ||
require(value == 0, "Strings: hex length insufficient"); | ||
return string(buffer); | ||
} | ||
|
||
/** | ||
* @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation. | ||
*/ | ||
function toHexString(address addr) internal pure returns (string memory) { | ||
return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH); | ||
} | ||
|
||
/** | ||
* @dev Returns true if the two strings are equal. | ||
*/ | ||
function equal(string memory a, string memory b) internal pure returns (bool) { | ||
return keccak256(bytes(a)) == keccak256(bytes(b)); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it safe to run foreign script that can be changed anytime inside CI ? will it be executed on our hosted runner used for releasing also?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It won't be executed in releasing, plus we don't use a self-hosted runner now : )
But still, should we move the installation part to cli image?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, moving it into cli image would make the scripts cleaner.