Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save CipherShi/3a5b119890ae623b04058d5d6dcc5e08 to your computer and use it in GitHub Desktop.
Save CipherShi/3a5b119890ae623b04058d5d6dcc5e08 to your computer and use it in GitHub Desktop.
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.8.18+commit.87f61d96.js&optimize=false&runs=200&gist=
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.4.22 <0.9.0;
library TestsAccounts {
function getAccount(uint index) pure public returns (address) {
address[15] memory accounts;
accounts[0] = 0x5B38Da6a701c568545dCfcB03FcB875f56beddC4;
accounts[1] = 0xAb8483F64d9C6d1EcF9b849Ae677dD3315835cb2;
accounts[2] = 0x4B20993Bc481177ec7E8f571ceCaE8A9e22C02db;
accounts[3] = 0x78731D3Ca6b7E34aC0F824c42a7cC18A495cabaB;
accounts[4] = 0x617F2E2fD72FD9D5503197092aC168c91465E7f2;
accounts[5] = 0x17F6AD8Ef982297579C203069C1DbfFE4348c372;
accounts[6] = 0x5c6B0f7Bf3E7ce046039Bd8FABdfD3f9F5021678;
accounts[7] = 0x03C6FcED478cBbC9a4FAB34eF9f40767739D1Ff7;
accounts[8] = 0x1aE0EA34a72D944a8C7603FfB3eC30a6669E454C;
accounts[9] = 0x0A098Eda01Ce92ff4A4CCb7A4fFFb5A43EBC70DC;
accounts[10] = 0xCA35b7d915458EF540aDe6068dFe2F44E8fa733c;
accounts[11] = 0x14723A09ACff6D2A60DcdF7aA4AFf308FDDC160C;
accounts[12] = 0x4B0897b0513fdC7C541B6d9D7E929C4e5364D2dB;
accounts[13] = 0x583031D1113aD414F02576BD6afaBfb302140225;
accounts[14] = 0xdD870fA1b7C4700F2BD7f44238821C26f7392148;
return accounts[index];
}
}
// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.4.22 <0.9.0;
library Assert {
event AssertionEvent(
bool passed,
string message,
string methodName
);
event AssertionEventUint(
bool passed,
string message,
string methodName,
uint256 returned,
uint256 expected
);
event AssertionEventInt(
bool passed,
string message,
string methodName,
int256 returned,
int256 expected
);
event AssertionEventBool(
bool passed,
string message,
string methodName,
bool returned,
bool expected
);
event AssertionEventAddress(
bool passed,
string message,
string methodName,
address returned,
address expected
);
event AssertionEventBytes32(
bool passed,
string message,
string methodName,
bytes32 returned,
bytes32 expected
);
event AssertionEventString(
bool passed,
string message,
string methodName,
string returned,
string expected
);
event AssertionEventUintInt(
bool passed,
string message,
string methodName,
uint256 returned,
int256 expected
);
event AssertionEventIntUint(
bool passed,
string message,
string methodName,
int256 returned,
uint256 expected
);
function ok(bool a, string memory message) public returns (bool result) {
result = a;
emit AssertionEvent(result, message, "ok");
}
function equal(uint256 a, uint256 b, string memory message) public returns (bool result) {
result = (a == b);
emit AssertionEventUint(result, message, "equal", a, b);
}
function equal(int256 a, int256 b, string memory message) public returns (bool result) {
result = (a == b);
emit AssertionEventInt(result, message, "equal", a, b);
}
function equal(bool a, bool b, string memory message) public returns (bool result) {
result = (a == b);
emit AssertionEventBool(result, message, "equal", a, b);
}
// TODO: only for certain versions of solc
//function equal(fixed a, fixed b, string message) public returns (bool result) {
// result = (a == b);
// emit AssertionEvent(result, message);
//}
// TODO: only for certain versions of solc
//function equal(ufixed a, ufixed b, string message) public returns (bool result) {
// result = (a == b);
// emit AssertionEvent(result, message);
//}
function equal(address a, address b, string memory message) public returns (bool result) {
result = (a == b);
emit AssertionEventAddress(result, message, "equal", a, b);
}
function equal(bytes32 a, bytes32 b, string memory message) public returns (bool result) {
result = (a == b);
emit AssertionEventBytes32(result, message, "equal", a, b);
}
function equal(string memory a, string memory b, string memory message) public returns (bool result) {
result = (keccak256(abi.encodePacked(a)) == keccak256(abi.encodePacked(b)));
emit AssertionEventString(result, message, "equal", a, b);
}
function notEqual(uint256 a, uint256 b, string memory message) public returns (bool result) {
result = (a != b);
emit AssertionEventUint(result, message, "notEqual", a, b);
}
function notEqual(int256 a, int256 b, string memory message) public returns (bool result) {
result = (a != b);
emit AssertionEventInt(result, message, "notEqual", a, b);
}
function notEqual(bool a, bool b, string memory message) public returns (bool result) {
result = (a != b);
emit AssertionEventBool(result, message, "notEqual", a, b);
}
// TODO: only for certain versions of solc
//function notEqual(fixed a, fixed b, string message) public returns (bool result) {
// result = (a != b);
// emit AssertionEvent(result, message);
//}
// TODO: only for certain versions of solc
//function notEqual(ufixed a, ufixed b, string message) public returns (bool result) {
// result = (a != b);
// emit AssertionEvent(result, message);
//}
function notEqual(address a, address b, string memory message) public returns (bool result) {
result = (a != b);
emit AssertionEventAddress(result, message, "notEqual", a, b);
}
function notEqual(bytes32 a, bytes32 b, string memory message) public returns (bool result) {
result = (a != b);
emit AssertionEventBytes32(result, message, "notEqual", a, b);
}
function notEqual(string memory a, string memory b, string memory message) public returns (bool result) {
result = (keccak256(abi.encodePacked(a)) != keccak256(abi.encodePacked(b)));
emit AssertionEventString(result, message, "notEqual", a, b);
}
/*----------------- Greater than --------------------*/
function greaterThan(uint256 a, uint256 b, string memory message) public returns (bool result) {
result = (a > b);
emit AssertionEventUint(result, message, "greaterThan", a, b);
}
function greaterThan(int256 a, int256 b, string memory message) public returns (bool result) {
result = (a > b);
emit AssertionEventInt(result, message, "greaterThan", a, b);
}
// TODO: safely compare between uint and int
function greaterThan(uint256 a, int256 b, string memory message) public returns (bool result) {
if(b < int(0)) {
// int is negative uint "a" always greater
result = true;
} else {
result = (a > uint(b));
}
emit AssertionEventUintInt(result, message, "greaterThan", a, b);
}
function greaterThan(int256 a, uint256 b, string memory message) public returns (bool result) {
if(a < int(0)) {
// int is negative uint "b" always greater
result = false;
} else {
result = (uint(a) > b);
}
emit AssertionEventIntUint(result, message, "greaterThan", a, b);
}
/*----------------- Lesser than --------------------*/
function lesserThan(uint256 a, uint256 b, string memory message) public returns (bool result) {
result = (a < b);
emit AssertionEventUint(result, message, "lesserThan", a, b);
}
function lesserThan(int256 a, int256 b, string memory message) public returns (bool result) {
result = (a < b);
emit AssertionEventInt(result, message, "lesserThan", a, b);
}
// TODO: safely compare between uint and int
function lesserThan(uint256 a, int256 b, string memory message) public returns (bool result) {
if(b < int(0)) {
// int is negative int "b" always lesser
result = false;
} else {
result = (a < uint(b));
}
emit AssertionEventUintInt(result, message, "lesserThan", a, b);
}
function lesserThan(int256 a, uint256 b, string memory message) public returns (bool result) {
if(a < int(0)) {
// int is negative int "a" always lesser
result = true;
} else {
result = (uint(a) < b);
}
emit AssertionEventIntUint(result, message, "lesserThan", a, b);
}
}
[core]
repositoryformatversion = 0
filemode = false
bare = false
logallrefupdates = true
symlinks = false
ignorecase = true
ref: refs/heads/main
DIRCd1��0���d1��0���&����-�k�����uw����,�&$.deps/remix-tests/remix_accounts.sold1��,X�d1��,X�������b 2�H"��(���,�Dz!.deps/remix-tests/remix_tests.sold1��9��d1��9��(�����o#q{K���Sc��X�W�n.prettierrc.json�N� ˏ��jk�
�BKb
x���A� @Qלb�F3�P���c �
�)�b��M��*s� Q�z��Q��^����&4�5��M~� ���6�RM��� gn=�wb&��w�\����ɢ3f,�qD����Z���3�1'h��z�g��Z�PC�
x�+)JMU0�`01�����
ݒ��b��_ݯn�;�9�{'��ey����Y�:�
x�+)JMU��d040031Q(J�ͬ�OLN�/�+)�+��a8xD�d��7��ͻ_Z��_�}�_j(�KR��Jw�Ɯ�`��C��Q�o�<?� w�*�
x����
�0 �=�)F�2ă��-D��xh�L��)m&�ػ�6�1�9%��|��"�m�E�M1|��2����?�U���
�<��+��%� I�m>\�R�Y�to�t���E�oF������^p�`�pR�J$������hx��8��~������N񯌇���=ꐶ������5��/�̢�
x�͖]O�@���_q�5�]��`�FcH�j�����=� �e;S�����JiK?���t8��9�f9��}99��Ǜ��{��Ͱ?5��Ԥ�^���}�t0�t�.�-0Ǣ�+�� g��������ӱ��w׌�����W�*�PǾ����h�c���'F�0�R{ d��0�/��,PD�ˬĿh��A�YF_��E�v� ���u�F.ȴ �T�2?���1��nC��B׆�=�S� Q$�kNJ#;5Б Q�)a�˓��>J�& ��@��4rZӧ���43�����l]2�3W�]Io�x�= �Ta�i��� �p4�gqUȝ�&�� �K�tG��5�u-�u�]U����?��\`E�Z#�
��45���>V�'��L� �a��Ց���ח袼¦�n.����� �HE� ��2���cJ���ʼn�L����\� ,Z�H�M>(p�õ 㭫���r|�1 ���@'*rܪC��\^jB{�����ᵊ�U1G]'s!h
��m�1��s4���Ĝ�����5 �OP�~�ᷭ;�Q���
������~Q��ȇ�p�L�Z�.��8�ޱ��6�NE��m:H���v�2cѢ���L)�ߦ�6���fR�K�5⸟������ ��ذ�X|�O�ݛ˟��V�誂�ز_��� )?ݏ2�cZȈ�B ug�$.��� ����6d^V�RS�`,S)Cu�J�J������.���ȊEP��M㮇A�>-���m���X�K�NH�6�9#��q�7R�oھ��D4kO���5v*37-?]�r�2oQY��խ�ʸ��lвE%�ߞ��§�,�꒒���(����̅�imA�|>�' N�Z��d\GL����� }��
x�]�M�\)�g��.�EW�z���$���0�E`�4��3\�
� !�=&u'L� ��=��=�i�����5��}�x�n)mwlw�Զ;-}i�?������-l6���sb���R��W�� lq+� �v ���Ӓ��}h��ѕ�?�NG�m����]9-���N����;�eWۗW����Ɩ����t>��e��Ў�W�?�z���#{n��!�V��͋�����a�EM҄�/J���^&��L�TW:�Z=���� �A#��j��|.ю�&�AJ��T%�kX\`�X+���s�Vh6]/ͧ�8ۄ� j���&C���4KL�XP$*��V���t �֜��E$b�A)��X�<צX�Z��o�Vx��3wk����z��<�g�h��X��.z�NS�3��Aک��ڃ�6*\������:�9 �2eoNb��#�h����NװY�N3�nt�D���x�O�y IkmgT�a�*;�f� �oV����ǘ�C9O� ��|��wRe���p�9*��mjl""�IYn�5cIȡ�|�:�!�)9t�K01���j�K��z�
��� 4[a=6%5Qor�ה���hιL9F��t�i�Y��P7�� Aw<�G�b
��4Fp/t���ٗy�=��F����L�|��v�=�
x�+)JMU07c01��Ԃb!u�@������C Vi�{��s��������^AQjIIfjQQ�^Vq~æ��ʅ�޳�Y�'/�q,�\���
013290d0a7fea3e573b06ea4df983d293006659f
{
"overrides": [
{
"files": "*.sol",
"options": {
"printWidth": 80,
"tabWidth": 4,
"useTabs": false,
"singleQuote": false,
"bracketSpacing": false
}
},
{
"files": "*.yml",
"options": {}
},
{
"files": "*.yaml",
"options": {}
},
{
"files": "*.toml",
"options": {}
},
{
"files": "*.json",
"options": {}
},
{
"files": "*.js",
"options": {}
},
{
"files": "*.ts",
"options": {}
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment