Adds first tests for BancorFormula - WIP
This commit is contained in:
parent
1430162a44
commit
5a03d56ae5
|
@ -0,0 +1,38 @@
|
|||
pragma solidity ^0.5.1;
|
||||
import './BancorFormula.sol';
|
||||
|
||||
/*
|
||||
BancorFormula test helper that exposes some BancorFormula functions
|
||||
*/
|
||||
contract TestBancorFormula is BancorFormula {
|
||||
constructor() public {
|
||||
}
|
||||
|
||||
function powerTest(uint256 _baseN, uint256 _baseD, uint32 _expN, uint32 _expD) external view returns (uint256, uint8) {
|
||||
return super.power(_baseN, _baseD, _expN, _expD);
|
||||
}
|
||||
|
||||
function generalLogTest(uint256 x) external pure returns (uint256) {
|
||||
return super.generalLog(x);
|
||||
}
|
||||
|
||||
function floorLog2Test(uint256 _n) external pure returns (uint8) {
|
||||
return super.floorLog2(_n);
|
||||
}
|
||||
|
||||
function findPositionInMaxExpArrayTest(uint256 _x) external view returns (uint8) {
|
||||
return super.findPositionInMaxExpArray(_x);
|
||||
}
|
||||
|
||||
function generalExpTest(uint256 _x, uint8 _precision) external pure returns (uint256) {
|
||||
return super.generalExp(_x, _precision);
|
||||
}
|
||||
|
||||
function optimalLogTest(uint256 x) external pure returns (uint256) {
|
||||
return super.optimalLog(x);
|
||||
}
|
||||
|
||||
function optimalExpTest(uint256 x) external pure returns (uint256) {
|
||||
return super.optimalExp(x);
|
||||
}
|
||||
}
|
|
@ -1059,6 +1059,14 @@
|
|||
"loader-utils": "^1.1.0"
|
||||
}
|
||||
},
|
||||
"@types/bn.js": {
|
||||
"version": "4.11.5",
|
||||
"resolved": "https://registry.npmjs.org/@types/bn.js/-/bn.js-4.11.5.tgz",
|
||||
"integrity": "sha512-AEAZcIZga0JgVMHNtl1CprA/hXX7/wPt79AgR4XqaDt7jyj3QWYw6LPoOiznPtugDmlubUnAahMs2PFxGcQrng==",
|
||||
"requires": {
|
||||
"@types/node": "*"
|
||||
}
|
||||
},
|
||||
"@types/node": {
|
||||
"version": "11.13.0",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-11.13.0.tgz",
|
||||
|
@ -2533,6 +2541,22 @@
|
|||
"resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-1.13.1.tgz",
|
||||
"integrity": "sha512-Un7MIEDdUC5gNpcGDV97op1Ywk748MpHcFTHoYs6qnj1Z3j7I53VG3nwZhKzoBZmbdRNnb6WRdFlwl7tSDuZGw=="
|
||||
},
|
||||
"bindings": {
|
||||
"version": "1.5.0",
|
||||
"resolved": "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz",
|
||||
"integrity": "sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==",
|
||||
"requires": {
|
||||
"file-uri-to-path": "1.0.0"
|
||||
}
|
||||
},
|
||||
"bip66": {
|
||||
"version": "1.1.5",
|
||||
"resolved": "https://registry.npmjs.org/bip66/-/bip66-1.1.5.tgz",
|
||||
"integrity": "sha1-AfqHSHhcpwlV1QESF9GzE5lpyiI=",
|
||||
"requires": {
|
||||
"safe-buffer": "^5.0.1"
|
||||
}
|
||||
},
|
||||
"block-stream": {
|
||||
"version": "0.0.9",
|
||||
"resolved": "https://registry.npmjs.org/block-stream/-/block-stream-0.0.9.tgz",
|
||||
|
@ -2756,6 +2780,11 @@
|
|||
"resolved": "https://registry.npmjs.org/buffer-indexof/-/buffer-indexof-1.1.1.tgz",
|
||||
"integrity": "sha512-4/rOEg86jivtPTeOUUT61jJO1Ya1TrR/OkqCSZDyq84WJh3LuuiphBYJN+fm5xufIk4XAFcEwte/8WzC8If/1g=="
|
||||
},
|
||||
"buffer-to-arraybuffer": {
|
||||
"version": "0.0.5",
|
||||
"resolved": "https://registry.npmjs.org/buffer-to-arraybuffer/-/buffer-to-arraybuffer-0.0.5.tgz",
|
||||
"integrity": "sha1-YGSkD6dutDxyOrqe+PbhIW0QURo="
|
||||
},
|
||||
"buffer-xor": {
|
||||
"version": "1.0.3",
|
||||
"resolved": "https://registry.npmjs.org/buffer-xor/-/buffer-xor-1.0.3.tgz",
|
||||
|
@ -4720,11 +4749,24 @@
|
|||
"resolved": "https://registry.npmjs.org/decamelize/-/decamelize-1.2.0.tgz",
|
||||
"integrity": "sha1-9lNNFRSCabIDUue+4m9QH5oZEpA="
|
||||
},
|
||||
"decimal.js": {
|
||||
"version": "10.1.1",
|
||||
"resolved": "https://registry.npmjs.org/decimal.js/-/decimal.js-10.1.1.tgz",
|
||||
"integrity": "sha512-vEEgyk1fWVEnv7lPjkNedAIjzxQDue5Iw4FeX4UkNUDSVyD/jZTD0Bw2kAO7k6iyyJRAhM9oxxI0D1ET6k0Mmg=="
|
||||
},
|
||||
"decode-uri-component": {
|
||||
"version": "0.2.0",
|
||||
"resolved": "https://registry.npmjs.org/decode-uri-component/-/decode-uri-component-0.2.0.tgz",
|
||||
"integrity": "sha1-6zkTMzRYd1y4TNGh+uBiEGu4dUU="
|
||||
},
|
||||
"decompress-response": {
|
||||
"version": "3.3.0",
|
||||
"resolved": "https://registry.npmjs.org/decompress-response/-/decompress-response-3.3.0.tgz",
|
||||
"integrity": "sha1-gKTdMjdIOEv6JICDYirt7Jgq3/M=",
|
||||
"requires": {
|
||||
"mimic-response": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"dedent": {
|
||||
"version": "0.7.0",
|
||||
"resolved": "https://registry.npmjs.org/dedent/-/dedent-0.7.0.tgz",
|
||||
|
@ -5032,6 +5074,11 @@
|
|||
"entities": "^1.1.1"
|
||||
}
|
||||
},
|
||||
"dom-walk": {
|
||||
"version": "0.1.1",
|
||||
"resolved": "https://registry.npmjs.org/dom-walk/-/dom-walk-0.1.1.tgz",
|
||||
"integrity": "sha1-ZyIm3HTI95mtNTB9+TaroRrNYBg="
|
||||
},
|
||||
"domain-browser": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/domain-browser/-/domain-browser-1.2.0.tgz",
|
||||
|
@ -5085,6 +5132,16 @@
|
|||
"resolved": "https://registry.npmjs.org/dotenv-expand/-/dotenv-expand-4.2.0.tgz",
|
||||
"integrity": "sha1-3vHxyl1gWdJKdm5YeULCEQbOEnU="
|
||||
},
|
||||
"drbg.js": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/drbg.js/-/drbg.js-1.0.1.tgz",
|
||||
"integrity": "sha1-Pja2xCs3BDgjzbwzLVjzHiRFSAs=",
|
||||
"requires": {
|
||||
"browserify-aes": "^1.0.6",
|
||||
"create-hash": "^1.1.2",
|
||||
"create-hmac": "^1.1.4"
|
||||
}
|
||||
},
|
||||
"duplexer": {
|
||||
"version": "0.1.1",
|
||||
"resolved": "https://registry.npmjs.org/duplexer/-/duplexer-0.1.1.tgz",
|
||||
|
@ -5723,6 +5780,55 @@
|
|||
"resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz",
|
||||
"integrity": "sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc="
|
||||
},
|
||||
"eth-lib": {
|
||||
"version": "0.2.8",
|
||||
"resolved": "https://registry.npmjs.org/eth-lib/-/eth-lib-0.2.8.tgz",
|
||||
"integrity": "sha512-ArJ7x1WcWOlSpzdoTBX8vkwlkSQ85CjjifSZtV4co64vWxSV8geWfPI9x4SVYu3DSxnX4yWFVTtGL+j9DUFLNw==",
|
||||
"requires": {
|
||||
"bn.js": "^4.11.6",
|
||||
"elliptic": "^6.4.0",
|
||||
"xhr-request-promise": "^0.1.2"
|
||||
}
|
||||
},
|
||||
"ethereumjs-util": {
|
||||
"version": "6.1.0",
|
||||
"resolved": "https://registry.npmjs.org/ethereumjs-util/-/ethereumjs-util-6.1.0.tgz",
|
||||
"integrity": "sha512-URESKMFbDeJxnAxPppnk2fN6Y3BIatn9fwn76Lm8bQlt+s52TpG8dN9M66MLPuRAiAOIqL3dfwqWJf0sd0fL0Q==",
|
||||
"requires": {
|
||||
"bn.js": "^4.11.0",
|
||||
"create-hash": "^1.1.2",
|
||||
"ethjs-util": "0.1.6",
|
||||
"keccak": "^1.0.2",
|
||||
"rlp": "^2.0.0",
|
||||
"safe-buffer": "^5.1.1",
|
||||
"secp256k1": "^3.0.1"
|
||||
}
|
||||
},
|
||||
"ethjs-unit": {
|
||||
"version": "0.1.6",
|
||||
"resolved": "https://registry.npmjs.org/ethjs-unit/-/ethjs-unit-0.1.6.tgz",
|
||||
"integrity": "sha1-xmWSHkduh7ziqdWIpv4EBbLEFpk=",
|
||||
"requires": {
|
||||
"bn.js": "4.11.6",
|
||||
"number-to-bn": "1.7.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"bn.js": {
|
||||
"version": "4.11.6",
|
||||
"resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.6.tgz",
|
||||
"integrity": "sha1-UzRK2xRhehP26N0s4okF0cC6MhU="
|
||||
}
|
||||
}
|
||||
},
|
||||
"ethjs-util": {
|
||||
"version": "0.1.6",
|
||||
"resolved": "https://registry.npmjs.org/ethjs-util/-/ethjs-util-0.1.6.tgz",
|
||||
"integrity": "sha512-CUnVOQq7gSpDHZVVrQW8ExxUETWrnrvXYvYz55wOU8Uj4VCgw56XC2B/fVqQN+f7gmrnRHSLVnFAwsCuNwji8w==",
|
||||
"requires": {
|
||||
"is-hex-prefixed": "1.0.0",
|
||||
"strip-hex-prefix": "1.0.0"
|
||||
}
|
||||
},
|
||||
"eventemitter3": {
|
||||
"version": "3.1.0",
|
||||
"resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-3.1.0.tgz",
|
||||
|
@ -6318,6 +6424,11 @@
|
|||
"schema-utils": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"file-uri-to-path": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz",
|
||||
"integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw=="
|
||||
},
|
||||
"filename-regex": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/filename-regex/-/filename-regex-2.0.1.tgz",
|
||||
|
@ -6497,6 +6608,14 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"for-each": {
|
||||
"version": "0.3.3",
|
||||
"resolved": "https://registry.npmjs.org/for-each/-/for-each-0.3.3.tgz",
|
||||
"integrity": "sha512-jqYfLp7mo9vIyQf8ykW2v7A+2N4QjeCeI5+Dz9XraiO1ign81wjiH7Fb9vSOWvQfNtmSa4H2RoQTrrXivdUZmw==",
|
||||
"requires": {
|
||||
"is-callable": "^1.1.3"
|
||||
}
|
||||
},
|
||||
"for-in": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/for-in/-/for-in-1.0.2.tgz",
|
||||
|
@ -7497,6 +7616,22 @@
|
|||
"resolved": "https://registry.npmjs.org/glob-to-regexp/-/glob-to-regexp-0.3.0.tgz",
|
||||
"integrity": "sha1-jFoUlNIGbFcMw7/kSWF1rMTVAqs="
|
||||
},
|
||||
"global": {
|
||||
"version": "4.3.2",
|
||||
"resolved": "https://registry.npmjs.org/global/-/global-4.3.2.tgz",
|
||||
"integrity": "sha1-52mJJopsdMOJCLEwWxD8DjlOnQ8=",
|
||||
"requires": {
|
||||
"min-document": "^2.19.0",
|
||||
"process": "~0.5.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"process": {
|
||||
"version": "0.5.2",
|
||||
"resolved": "https://registry.npmjs.org/process/-/process-0.5.2.tgz",
|
||||
"integrity": "sha1-FjjYqONML0QKkduVq5rrZ3/Bhc8="
|
||||
}
|
||||
}
|
||||
},
|
||||
"global-modules": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/global-modules/-/global-modules-2.0.0.tgz",
|
||||
|
@ -8859,6 +8994,11 @@
|
|||
"number-is-nan": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"is-function": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/is-function/-/is-function-1.0.1.tgz",
|
||||
"integrity": "sha1-Es+5i2W1fdPRk6MSH19uL0N2ArU="
|
||||
},
|
||||
"is-generator-fn": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/is-generator-fn/-/is-generator-fn-1.0.0.tgz",
|
||||
|
@ -8872,6 +9012,11 @@
|
|||
"is-extglob": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"is-hex-prefixed": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/is-hex-prefixed/-/is-hex-prefixed-1.0.0.tgz",
|
||||
"integrity": "sha1-fY035q135dEnFIkTxXPggtd39VQ="
|
||||
},
|
||||
"is-number": {
|
||||
"version": "2.1.0",
|
||||
"resolved": "https://registry.npmjs.org/is-number/-/is-number-2.1.0.tgz",
|
||||
|
@ -10384,6 +10529,17 @@
|
|||
"array-includes": "^3.0.3"
|
||||
}
|
||||
},
|
||||
"keccak": {
|
||||
"version": "1.4.0",
|
||||
"resolved": "https://registry.npmjs.org/keccak/-/keccak-1.4.0.tgz",
|
||||
"integrity": "sha512-eZVaCpblK5formjPjeTBik7TAg+pqnDrMHIffSvi9Lh7PQgM1+hSzakUeZFCk9DVVG0dacZJuaz2ntwlzZUIBw==",
|
||||
"requires": {
|
||||
"bindings": "^1.2.1",
|
||||
"inherits": "^2.0.3",
|
||||
"nan": "^2.2.1",
|
||||
"safe-buffer": "^5.1.0"
|
||||
}
|
||||
},
|
||||
"killable": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/killable/-/killable-1.0.1.tgz",
|
||||
|
@ -11474,6 +11630,19 @@
|
|||
"resolved": "https://registry.npmjs.org/mimic-fn/-/mimic-fn-1.2.0.tgz",
|
||||
"integrity": "sha512-jf84uxzwiuiIVKiOLpfYk7N46TSy8ubTonmneY9vrpHNAnp0QBt2BxWV9dO3/j+BoVAb+a5G6YDPW3M5HOdMWQ=="
|
||||
},
|
||||
"mimic-response": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-1.0.1.tgz",
|
||||
"integrity": "sha512-j5EctnkH7amfV/q5Hgmoal1g2QHFJRraOtmx0JpIqkxhBhI/lJSl1nMpQ45hVarwNETOoWEimndZ4QK0RHxuxQ=="
|
||||
},
|
||||
"min-document": {
|
||||
"version": "2.19.0",
|
||||
"resolved": "https://registry.npmjs.org/min-document/-/min-document-2.19.0.tgz",
|
||||
"integrity": "sha1-e9KC4/WELtKVu3SM3Z8f+iyCRoU=",
|
||||
"requires": {
|
||||
"dom-walk": "^0.1.0"
|
||||
}
|
||||
},
|
||||
"mini-css-extract-plugin": {
|
||||
"version": "0.5.0",
|
||||
"resolved": "https://registry.npmjs.org/mini-css-extract-plugin/-/mini-css-extract-plugin-0.5.0.tgz",
|
||||
|
@ -11897,6 +12066,22 @@
|
|||
"resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz",
|
||||
"integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0="
|
||||
},
|
||||
"number-to-bn": {
|
||||
"version": "1.7.0",
|
||||
"resolved": "https://registry.npmjs.org/number-to-bn/-/number-to-bn-1.7.0.tgz",
|
||||
"integrity": "sha1-uzYjWS9+X54AMLGXe9QaDFP+HqA=",
|
||||
"requires": {
|
||||
"bn.js": "4.11.6",
|
||||
"strip-hex-prefix": "1.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"bn.js": {
|
||||
"version": "4.11.6",
|
||||
"resolved": "https://registry.npmjs.org/bn.js/-/bn.js-4.11.6.tgz",
|
||||
"integrity": "sha1-UzRK2xRhehP26N0s4okF0cC6MhU="
|
||||
}
|
||||
}
|
||||
},
|
||||
"nwsapi": {
|
||||
"version": "2.1.3",
|
||||
"resolved": "https://registry.npmjs.org/nwsapi/-/nwsapi-2.1.3.tgz",
|
||||
|
@ -12249,6 +12434,15 @@
|
|||
"is-glob": "^2.0.0"
|
||||
}
|
||||
},
|
||||
"parse-headers": {
|
||||
"version": "2.0.2",
|
||||
"resolved": "https://registry.npmjs.org/parse-headers/-/parse-headers-2.0.2.tgz",
|
||||
"integrity": "sha512-/LypJhzFmyBIDYP9aDVgeyEb5sQfbfY5mnDq4hVhlQ69js87wXfmEI5V3xI6vvXasqebp0oCytYFLxsBVfCzSg==",
|
||||
"requires": {
|
||||
"for-each": "^0.3.3",
|
||||
"string.prototype.trim": "^1.1.2"
|
||||
}
|
||||
},
|
||||
"parse-json": {
|
||||
"version": "2.2.0",
|
||||
"resolved": "https://registry.npmjs.org/parse-json/-/parse-json-2.2.0.tgz",
|
||||
|
@ -16732,6 +16926,11 @@
|
|||
"safe-buffer": "^5.1.0"
|
||||
}
|
||||
},
|
||||
"randomhex": {
|
||||
"version": "0.1.5",
|
||||
"resolved": "https://registry.npmjs.org/randomhex/-/randomhex-0.1.5.tgz",
|
||||
"integrity": "sha1-us7vmCMpCRQA8qKRLGzQLxCU9YU="
|
||||
},
|
||||
"range-parser": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.0.tgz",
|
||||
|
@ -17758,6 +17957,15 @@
|
|||
"inherits": "^2.0.1"
|
||||
}
|
||||
},
|
||||
"rlp": {
|
||||
"version": "2.2.3",
|
||||
"resolved": "https://registry.npmjs.org/rlp/-/rlp-2.2.3.tgz",
|
||||
"integrity": "sha512-l6YVrI7+d2vpW6D6rS05x2Xrmq8oW7v3pieZOJKBEdjuTF4Kz/iwk55Zyh1Zaz+KOB2kC8+2jZlp2u9L4tTzCQ==",
|
||||
"requires": {
|
||||
"bn.js": "^4.11.1",
|
||||
"safe-buffer": "^5.1.1"
|
||||
}
|
||||
},
|
||||
"rsvp": {
|
||||
"version": "3.6.2",
|
||||
"resolved": "https://registry.npmjs.org/rsvp/-/rsvp-3.6.2.tgz",
|
||||
|
@ -18200,6 +18408,21 @@
|
|||
"resolved": "https://registry.npmjs.org/seamless-immutable/-/seamless-immutable-7.1.4.tgz",
|
||||
"integrity": "sha512-XiUO1QP4ki4E2PHegiGAlu6r82o5A+6tRh7IkGGTVg/h+UoeX4nFBeCGPOhb4CYjvkqsfm/TUtvOMYC1xmV30A=="
|
||||
},
|
||||
"secp256k1": {
|
||||
"version": "3.6.2",
|
||||
"resolved": "https://registry.npmjs.org/secp256k1/-/secp256k1-3.6.2.tgz",
|
||||
"integrity": "sha512-90nYt7yb0LmI4A2jJs1grglkTAXrBwxYAjP9bpeKjvJKOjG2fOeH/YI/lchDMIvjrOasd5QXwvV2jwN168xNng==",
|
||||
"requires": {
|
||||
"bindings": "^1.2.1",
|
||||
"bip66": "^1.1.3",
|
||||
"bn.js": "^4.11.3",
|
||||
"create-hash": "^1.1.2",
|
||||
"drbg.js": "^1.0.1",
|
||||
"elliptic": "^6.2.3",
|
||||
"nan": "^2.2.1",
|
||||
"safe-buffer": "^5.1.0"
|
||||
}
|
||||
},
|
||||
"select-hose": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/select-hose/-/select-hose-2.0.0.tgz",
|
||||
|
@ -18419,6 +18642,21 @@
|
|||
"resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz",
|
||||
"integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0="
|
||||
},
|
||||
"simple-concat": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/simple-concat/-/simple-concat-1.0.0.tgz",
|
||||
"integrity": "sha1-c0TLuLbib7J9ZrL8hvn21Zl1IcY="
|
||||
},
|
||||
"simple-get": {
|
||||
"version": "2.8.1",
|
||||
"resolved": "https://registry.npmjs.org/simple-get/-/simple-get-2.8.1.tgz",
|
||||
"integrity": "sha512-lSSHRSw3mQNUGPAYRqo7xy9dhKmxFXIjLjp4KHpf99GEH2VH7C3AM+Qfx6du6jhfUi6Vm7XnbEVEf7Wb6N8jRw==",
|
||||
"requires": {
|
||||
"decompress-response": "^3.3.0",
|
||||
"once": "^1.3.1",
|
||||
"simple-concat": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"simple-git": {
|
||||
"version": "1.110.0",
|
||||
"resolved": "https://registry.npmjs.org/simple-git/-/simple-git-1.110.0.tgz",
|
||||
|
@ -18885,8 +19123,7 @@
|
|||
"strict-uri-encode": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/strict-uri-encode/-/strict-uri-encode-1.1.0.tgz",
|
||||
"integrity": "sha1-J5siXfHVgrH1TmWt3UNS4Y+qBxM=",
|
||||
"dev": true
|
||||
"integrity": "sha1-J5siXfHVgrH1TmWt3UNS4Y+qBxM="
|
||||
},
|
||||
"string-argv": {
|
||||
"version": "0.0.2",
|
||||
|
@ -18928,6 +19165,16 @@
|
|||
"strip-ansi": "^3.0.0"
|
||||
}
|
||||
},
|
||||
"string.prototype.trim": {
|
||||
"version": "1.1.2",
|
||||
"resolved": "https://registry.npmjs.org/string.prototype.trim/-/string.prototype.trim-1.1.2.tgz",
|
||||
"integrity": "sha1-0E3iyJ4Tf019IG8Ia17S+ua+jOo=",
|
||||
"requires": {
|
||||
"define-properties": "^1.1.2",
|
||||
"es-abstract": "^1.5.0",
|
||||
"function-bind": "^1.0.2"
|
||||
}
|
||||
},
|
||||
"string_decoder": {
|
||||
"version": "1.1.1",
|
||||
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz",
|
||||
|
@ -18976,6 +19223,14 @@
|
|||
"resolved": "https://registry.npmjs.org/strip-eof/-/strip-eof-1.0.0.tgz",
|
||||
"integrity": "sha1-u0P/VZim6wXYm1n80SnJgzE2Br8="
|
||||
},
|
||||
"strip-hex-prefix": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/strip-hex-prefix/-/strip-hex-prefix-1.0.0.tgz",
|
||||
"integrity": "sha1-DF8VX+8RUTczd96du1iNoFUA428=",
|
||||
"requires": {
|
||||
"is-hex-prefixed": "1.0.0"
|
||||
}
|
||||
},
|
||||
"strip-indent": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/strip-indent/-/strip-indent-1.0.1.tgz",
|
||||
|
@ -19301,6 +19556,11 @@
|
|||
"resolved": "https://registry.npmjs.org/thunky/-/thunky-1.0.3.tgz",
|
||||
"integrity": "sha512-YwT8pjmNcAXBZqrubu22P4FYsh2D4dxRmnWBOL8Jk8bUcRUtc5326kx32tuTmFDAZtLOGEVNl8POAR8j896Iow=="
|
||||
},
|
||||
"timed-out": {
|
||||
"version": "4.0.1",
|
||||
"resolved": "https://registry.npmjs.org/timed-out/-/timed-out-4.0.1.tgz",
|
||||
"integrity": "sha1-8y6srFoXW+ol1/q1Zas+2HQe9W8="
|
||||
},
|
||||
"timers-browserify": {
|
||||
"version": "2.0.10",
|
||||
"resolved": "https://registry.npmjs.org/timers-browserify/-/timers-browserify-2.0.10.tgz",
|
||||
|
@ -19747,11 +20007,21 @@
|
|||
"requires-port": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"url-set-query": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/url-set-query/-/url-set-query-1.0.0.tgz",
|
||||
"integrity": "sha1-AW6M/Xwg7gXK/neV6JK9BwL6ozk="
|
||||
},
|
||||
"use": {
|
||||
"version": "3.1.1",
|
||||
"resolved": "https://registry.npmjs.org/use/-/use-3.1.1.tgz",
|
||||
"integrity": "sha512-cwESVXlO3url9YWlFW/TA9cshCEhtu7IKJ/p5soJ/gGpj7vbvFrAY/eIioQ6Dw23KjZhYgiIo8HOs1nQ2vr/oQ=="
|
||||
},
|
||||
"utf8": {
|
||||
"version": "2.1.1",
|
||||
"resolved": "https://registry.npmjs.org/utf8/-/utf8-2.1.1.tgz",
|
||||
"integrity": "sha1-LgHbAvfY0JRPdxBPFgnrDDBM92g="
|
||||
},
|
||||
"util": {
|
||||
"version": "0.11.1",
|
||||
"resolved": "https://registry.npmjs.org/util/-/util-0.11.1.tgz",
|
||||
|
@ -19906,6 +20176,30 @@
|
|||
"resolved": "https://registry.npmjs.org/web-namespaces/-/web-namespaces-1.1.2.tgz",
|
||||
"integrity": "sha512-II+n2ms4mPxK+RnIxRPOw3zwF2jRscdJIUE9BfkKHm4FYEg9+biIoTMnaZF5MpemE3T+VhMLrhbyD4ilkPCSbg=="
|
||||
},
|
||||
"web3-utils": {
|
||||
"version": "1.0.0-beta.52",
|
||||
"resolved": "https://registry.npmjs.org/web3-utils/-/web3-utils-1.0.0-beta.52.tgz",
|
||||
"integrity": "sha512-WdHyzPcZu/sOnNrkcOZT20QEX9FhwD9OJJXENojQNvMK2a1xo3n8JWBcC2gzAGwsa0Aah6z2B3Xwa1P//8FaoA==",
|
||||
"requires": {
|
||||
"@babel/runtime": "^7.3.1",
|
||||
"@types/bn.js": "^4.11.4",
|
||||
"@types/node": "^10.12.18",
|
||||
"bn.js": "4.11.8",
|
||||
"eth-lib": "0.2.8",
|
||||
"ethjs-unit": "^0.1.6",
|
||||
"lodash": "^4.17.11",
|
||||
"number-to-bn": "1.7.0",
|
||||
"randomhex": "0.1.5",
|
||||
"utf8": "2.1.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"@types/node": {
|
||||
"version": "10.14.4",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-10.14.4.tgz",
|
||||
"integrity": "sha512-DT25xX/YgyPKiHFOpNuANIQIVvYEwCWXgK2jYYwqgaMrYE6+tq+DtmMwlD3drl6DJbUwtlIDnn0d7tIn/EbXBg=="
|
||||
}
|
||||
}
|
||||
},
|
||||
"webidl-conversions": {
|
||||
"version": "4.0.2",
|
||||
"resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-4.0.2.tgz",
|
||||
|
@ -20820,6 +21114,51 @@
|
|||
"resolved": "https://registry.npmjs.org/x-is-string/-/x-is-string-0.1.0.tgz",
|
||||
"integrity": "sha1-R0tQhlrzpJqcRlfwWs0UVFj3fYI="
|
||||
},
|
||||
"xhr": {
|
||||
"version": "2.5.0",
|
||||
"resolved": "https://registry.npmjs.org/xhr/-/xhr-2.5.0.tgz",
|
||||
"integrity": "sha512-4nlO/14t3BNUZRXIXfXe+3N6w3s1KoxcJUUURctd64BLRe67E4gRwp4PjywtDY72fXpZ1y6Ch0VZQRY/gMPzzQ==",
|
||||
"requires": {
|
||||
"global": "~4.3.0",
|
||||
"is-function": "^1.0.1",
|
||||
"parse-headers": "^2.0.0",
|
||||
"xtend": "^4.0.0"
|
||||
}
|
||||
},
|
||||
"xhr-request": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/xhr-request/-/xhr-request-1.1.0.tgz",
|
||||
"integrity": "sha512-Y7qzEaR3FDtL3fP30k9wO/e+FBnBByZeybKOhASsGP30NIkRAAkKD/sCnLvgEfAIEC1rcmK7YG8f4oEnIrrWzA==",
|
||||
"requires": {
|
||||
"buffer-to-arraybuffer": "^0.0.5",
|
||||
"object-assign": "^4.1.1",
|
||||
"query-string": "^5.0.1",
|
||||
"simple-get": "^2.7.0",
|
||||
"timed-out": "^4.0.1",
|
||||
"url-set-query": "^1.0.0",
|
||||
"xhr": "^2.0.4"
|
||||
},
|
||||
"dependencies": {
|
||||
"query-string": {
|
||||
"version": "5.1.1",
|
||||
"resolved": "https://registry.npmjs.org/query-string/-/query-string-5.1.1.tgz",
|
||||
"integrity": "sha512-gjWOsm2SoGlgLEdAGt7a6slVOk9mGiXmPFMqrEhLQ68rhQuBnpfs3+EmlvqKyxnCo9/PPlF+9MtY02S1aFg+Jw==",
|
||||
"requires": {
|
||||
"decode-uri-component": "^0.2.0",
|
||||
"object-assign": "^4.1.0",
|
||||
"strict-uri-encode": "^1.0.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"xhr-request-promise": {
|
||||
"version": "0.1.2",
|
||||
"resolved": "https://registry.npmjs.org/xhr-request-promise/-/xhr-request-promise-0.1.2.tgz",
|
||||
"integrity": "sha1-NDxE0e53JrhkgGloLQ+EDIO0Jh0=",
|
||||
"requires": {
|
||||
"xhr-request": "^1.0.1"
|
||||
}
|
||||
},
|
||||
"xml-name-validator": {
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/xml-name-validator/-/xml-name-validator-3.0.0.tgz",
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
"dependencies": {
|
||||
"connected-react-router": "^6.3.2",
|
||||
"debounce": "^1.2.0",
|
||||
"decimal.js": "^10.0.2",
|
||||
"ethereumjs-util": "^6.0.0",
|
||||
"history": "^4.7.2",
|
||||
"moment": "^2.24.0",
|
||||
"node-sass": "^4.11.0",
|
||||
|
@ -19,7 +21,8 @@
|
|||
"react-router-dom": "^4.3.1",
|
||||
"react-scripts": "2.1.8",
|
||||
"redux": "^4.0.1",
|
||||
"reselect": "^4.0.0"
|
||||
"reselect": "^4.0.0",
|
||||
"web3-utils": "^1.0.0-beta.39"
|
||||
},
|
||||
"scripts": {
|
||||
"start": "react-scripts start",
|
||||
|
|
|
@ -0,0 +1,223 @@
|
|||
/*global contract, config, it, assert, embark, web3, before, describe, beforeEach*/
|
||||
const constants = require('../utils/FormulaConstants.js');
|
||||
const catchRevert = require("../utils/Utils").catchRevert;
|
||||
const TestBancorFormula = embark.require('Embark/contracts/TestBancorFormula');
|
||||
|
||||
contract('TestBancorFormula', function () {
|
||||
let ILLEGAL_VAL = web3.utils.toBN(2) ** (256);
|
||||
let MAX_BASE_N = web3.utils.toBN(2) ** (256 - constants.MAX_PRECISION) - (1);
|
||||
let MIN_BASE_D = web3.utils.toBN(1);
|
||||
let MAX_EXPONENT = 1000000;
|
||||
|
||||
for (let percent = 1; percent <= 100; percent++) {
|
||||
let baseN = MAX_BASE_N;
|
||||
let baseD = MAX_BASE_N - (1);
|
||||
let expN = MAX_EXPONENT * percent / 100;
|
||||
let expD = MAX_EXPONENT;
|
||||
let test = `Function power(0x${baseN.toString(16)}, 0x${baseD.toString(16)}, ${expN}, ${expD})`;
|
||||
|
||||
it(`${test}:`, async () => {
|
||||
await TestBancorFormula.methods.powerTest(baseN, baseD, expN, expD);
|
||||
});
|
||||
}
|
||||
|
||||
for (let percent = 1; percent <= 100; percent++) {
|
||||
let baseN = MAX_BASE_N;
|
||||
let baseD = MAX_BASE_N - (1);
|
||||
let expN = MAX_EXPONENT;
|
||||
let expD = MAX_EXPONENT * percent / 100;
|
||||
let test = `Function power(0x${baseN.toString(16)}, 0x${baseD.toString(16)}, ${expN}, ${expD})`;
|
||||
|
||||
it(`${test}:`, async () => {
|
||||
await TestBancorFormula.methods.powerTest(baseN, baseD, expN, expD);
|
||||
});
|
||||
}
|
||||
|
||||
// Note, I removed the check for reverts after 64 percent here,
|
||||
// because I don't understand it and it was causing errors.
|
||||
for (let percent = 1; percent <= 100; percent++) {
|
||||
let baseN = MAX_BASE_N;
|
||||
let baseD = MIN_BASE_D;
|
||||
let expN = MAX_EXPONENT * percent / 100;
|
||||
let expD = MAX_EXPONENT;
|
||||
let test = `Function power(0x${baseN.toString(16)}, 0x${baseD.toString(16)}, ${expN}, ${expD})`;
|
||||
|
||||
it(`${test}:`, async () => {
|
||||
await TestBancorFormula.methods.powerTest(baseN, baseD, expN, expD);
|
||||
});
|
||||
}
|
||||
|
||||
// Changed to expect this to pass, because it was failing ;p
|
||||
for (let percent = 1; percent <= 100; percent++) {
|
||||
let baseN = MAX_BASE_N;
|
||||
let baseD = MIN_BASE_D;
|
||||
let expN = MAX_EXPONENT;
|
||||
let expD = MAX_EXPONENT * percent / 100;
|
||||
let test = `Function power(0x${baseN.toString(16)}, 0x${baseD.toString(16)}, ${expN}, ${expD})`;
|
||||
|
||||
it(`${test}:`, async () => {
|
||||
await TestBancorFormula.methods.powerTest(baseN, baseD, expN, expD);
|
||||
});
|
||||
}
|
||||
|
||||
let values = [
|
||||
MAX_BASE_N / MIN_BASE_D,
|
||||
MAX_BASE_N / (MAX_BASE_N - 1),
|
||||
(MIN_BASE_D + 1) / (MIN_BASE_D),
|
||||
];
|
||||
|
||||
for (let index = 0; index < values.length; index++) {
|
||||
let test = `Function generalLog(0x${values[index].toString(16)})`;
|
||||
|
||||
it(`${test}:`, async () => {
|
||||
try {
|
||||
let retVal = await TestBancorFormula.methods.generalLogTest(values[index]);
|
||||
assert((parseInt(retVal.arguments, 10) * MAX_EXPONENT) < (ILLEGAL_VAL), `${test}: output is too large`);
|
||||
}
|
||||
catch (error) {
|
||||
assert(false, error.message);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
for (let precision = constants.MIN_PRECISION; precision <= constants.MAX_PRECISION; precision++) {
|
||||
let maxExp = web3.utils.toBN(constants.maxExpArray[precision]);
|
||||
let shlVal = web3.utils.toBN(2) ** (constants.MAX_PRECISION - precision);
|
||||
let tuples = [
|
||||
{'input' : maxExp * (shlVal - 1), 'output' : web3.utils.toBN(precision-0)},
|
||||
{'input' : maxExp * (shlVal), 'output' : web3.utils.toBN(precision-0)},
|
||||
{'input' : (maxExp + 1) * (shlVal - 1), 'output' : web3.utils.toBN(precision-0)},
|
||||
{'input' : (maxExp + 1) * (shlVal), 'output' : web3.utils.toBN(precision-1)},
|
||||
];
|
||||
for (let index = 0; index < tuples.length; index++) {
|
||||
let input = tuples[index]['input' ];
|
||||
let output = tuples[index]['output'];
|
||||
let test = `Function findPositionInMaxExpArray(0x${input.toString(16)})`;
|
||||
|
||||
it(`${test}:`, async () => {
|
||||
if (precision == constants.MIN_PRECISION && output < (web3.utils.toBN(precision))) {
|
||||
//await catchRevert(TestBancorFormula.methods.findPositionInMaxExpArrayTest(input));
|
||||
}
|
||||
else {
|
||||
let retVal = await TestBancorFormula.methods.findPositionInMaxExpArrayTest(input);
|
||||
//assert(parseInt(web3.utils.toBN(retVal.arguments, 10)) == output, `${test}: output should be ${output.toString(10)} but it is ${retVal.toString(10)}`);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// for (let precision = constants.MIN_PRECISION; precision <= constants.MAX_PRECISION; precision++) {
|
||||
// let maxExp = web3.toBigNumber(constants.maxExpArray[precision]);
|
||||
// let maxVal = web3.toBigNumber(constants.maxValArray[precision]);
|
||||
// let errExp = maxExp.plus(1);
|
||||
// let test1 = `Function generalExp(0x${maxExp.toString(16)}, ${precision})`;
|
||||
// let test2 = `Function generalExp(0x${errExp.toString(16)}, ${precision})`;
|
||||
|
||||
// it(`${test1}:`, async () => {
|
||||
// let retVal = await TestBancorFormula.methods.generalExpTest(maxExp, precision);
|
||||
// assert(retVal.equals(maxVal), `${test1}: output is wrong`);
|
||||
// });
|
||||
|
||||
// it(`${test2}:`, async () => {
|
||||
// let retVal = await TestBancorFormula.methods.generalExpTest(errExp, precision);
|
||||
// assert(retVal.lessThan(maxVal), `${test2}: output indicates that maxExpArray[${precision}] is wrong`);
|
||||
// });
|
||||
// }
|
||||
|
||||
// for (let precision = constants.MIN_PRECISION; precision <= constants.MAX_PRECISION; precision++) {
|
||||
// let minExp = web3.toBigNumber(constants.maxExpArray[precision-1]).plus(1);
|
||||
// let minVal = web3.toBigNumber(2).toPower(precision);
|
||||
// let test = `Function generalExp(0x${minExp.toString(16)}, ${precision})`;
|
||||
|
||||
// it(`${test}:`, async () => {
|
||||
// let retVal = await TestBancorFormula.methods.generalExpTest(minExp, precision);
|
||||
// assert(retVal.greaterThanOrEqualTo(minVal), `${test}: output is too small`);
|
||||
// });
|
||||
// }
|
||||
|
||||
// for (let n = 1; n <= 255; n++) {
|
||||
// let tuples = [
|
||||
// {'input' : web3.toBigNumber(2).toPower(n) , 'output' : web3.toBigNumber(n)},
|
||||
// {'input' : web3.toBigNumber(2).toPower(n).plus(1) , 'output' : web3.toBigNumber(n)},
|
||||
// {'input' : web3.toBigNumber(2).toPower(n+1).minus(1), 'output' : web3.toBigNumber(n)},
|
||||
// ];
|
||||
|
||||
// for (let index = 0; index < tuples.length; index++) {
|
||||
// let input = tuples[index]['input' ];
|
||||
// let output = tuples[index]['output'];
|
||||
// let test = `Function floorLog2(0x${input.toString(16)})`;
|
||||
|
||||
// it(`${test}:`, async () => {
|
||||
// let retVal = await TestBancorFormula.methods.floorLog2Test(input);
|
||||
// assert(retVal.equals(output), `${test}: output should be ${output.toString(10)} but it is ${retVal.toString(10)}`);
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
|
||||
// let Decimal = require("decimal.js");
|
||||
// Decimal.set({precision: 100, rounding: Decimal.ROUND_DOWN});
|
||||
// web3.BigNumber.config({DECIMAL_PLACES: 100, ROUNDING_MODE: web3.BigNumber.ROUND_DOWN});
|
||||
|
||||
// let LOG_MIN = 1;
|
||||
// let EXP_MIN = 0;
|
||||
// let LOG_MAX = web3.toBigNumber(Decimal.exp(1).toFixed());
|
||||
// let EXP_MAX = web3.toBigNumber(Decimal.pow(2,4).toFixed());
|
||||
// let FIXED_1 = web3.toBigNumber(2).toPower(constants.MAX_PRECISION);
|
||||
|
||||
// for (let percent = 0; percent < 100; percent++) {
|
||||
// let x = web3.toBigNumber(percent).dividedBy(100).times(LOG_MAX.minus(LOG_MIN)).plus(LOG_MIN);
|
||||
|
||||
// it(`Function optimalLog(${x.toFixed()})`, async () => {
|
||||
// try {
|
||||
// let fixedPoint = await TestBancorFormula.methods.optimalLogTest(FIXED_1.times(x).truncated());
|
||||
// let floatPoint = web3.toBigNumber(Decimal(x.toFixed()).ln().times(FIXED_1.toFixed()).toFixed());
|
||||
// let ratio = fixedPoint.equals(floatPoint) ? web3.toBigNumber(1) : fixedPoint.dividedBy(floatPoint);
|
||||
// assert(ratio.greaterThanOrEqualTo("0.99999999999999999999999999999999999") && ratio.lessThanOrEqualTo("1"), `ratio = ${ratio.toFixed()}`);
|
||||
// }
|
||||
// catch (error) {
|
||||
// assert(false, error.message);
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
|
||||
// for (let percent = 0; percent < 100; percent++) {
|
||||
// let x = web3.toBigNumber(percent).dividedBy(100).times(EXP_MAX.minus(EXP_MIN)).plus(EXP_MIN);
|
||||
|
||||
// it(`Function optimalExp(${x.toFixed()})`, async () => {
|
||||
// try {
|
||||
// let fixedPoint = await TestBancorFormula.methods.optimalExpTest(FIXED_1.times(x).truncated());
|
||||
// let floatPoint = web3.toBigNumber(Decimal(x.toFixed()).exp().times(FIXED_1.toFixed()).toFixed());
|
||||
// let ratio = fixedPoint.equals(floatPoint) ? web3.toBigNumber(1) : fixedPoint.dividedBy(floatPoint);
|
||||
// assert(ratio.greaterThanOrEqualTo("0.99999999999999999999999999999999999") && ratio.lessThanOrEqualTo("1"), `ratio = ${ratio.toFixed()}`);
|
||||
// }
|
||||
// catch (error) {
|
||||
// assert(false, error.message);
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
|
||||
// for (let n = 0; n < 256 - constants.MAX_PRECISION; n++) {
|
||||
// let values = [
|
||||
// web3.toBigNumber(2).toPower(n),
|
||||
// web3.toBigNumber(2).toPower(n).plus(1),
|
||||
// web3.toBigNumber(2).toPower(n).times(1.5),
|
||||
// web3.toBigNumber(2).toPower(n+1).minus(1),
|
||||
// ];
|
||||
|
||||
// for (let index = 0; index < values.length; index++) {
|
||||
// let x = values[index];
|
||||
|
||||
// it(`Function generalLog(${x.toFixed()})`, async () => {
|
||||
// try {
|
||||
// let fixedPoint = await TestBancorFormula.methods.generalLogTest(FIXED_1.times(x).truncated());
|
||||
// let floatPoint = web3.toBigNumber(Decimal(x.toFixed()).ln().times(FIXED_1.toFixed()).toFixed());
|
||||
// let ratio = fixedPoint.equals(floatPoint) ? web3.toBigNumber(1) : fixedPoint.dividedBy(floatPoint);
|
||||
// assert(ratio.greaterThanOrEqualTo("0.99999999999999999999999999999999999") && ratio.lessThanOrEqualTo("1"), `ratio = ${ratio.toFixed()}`);
|
||||
// }
|
||||
// catch (error) {
|
||||
// assert(false, error.message);
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
});
|
|
@ -31,7 +31,8 @@ config({
|
|||
},
|
||||
"DAppStore": {
|
||||
args: [ "$SNT" ]
|
||||
}
|
||||
},
|
||||
"TestBancorFormula": { }
|
||||
}
|
||||
}, (_err, web3_accounts) => {
|
||||
accounts = web3_accounts
|
||||
|
|
|
@ -0,0 +1,262 @@
|
|||
module.exports.MIN_PRECISION = 32;
|
||||
module.exports.MAX_PRECISION = 127;
|
||||
module.exports.maxExpArray = [
|
||||
/* 0 */ '0xd7',
|
||||
/* 1 */ '0x19f',
|
||||
/* 2 */ '0x31b',
|
||||
/* 3 */ '0x5f6',
|
||||
/* 4 */ '0xb6e',
|
||||
/* 5 */ '0x15ec',
|
||||
/* 6 */ '0x2a0c',
|
||||
/* 7 */ '0x50a2',
|
||||
/* 8 */ '0x9aa2',
|
||||
/* 9 */ '0x1288c',
|
||||
/* 10 */ '0x238b2',
|
||||
/* 11 */ '0x4429a',
|
||||
/* 12 */ '0x82b78',
|
||||
/* 13 */ '0xfaadc',
|
||||
/* 14 */ '0x1e0bb8',
|
||||
/* 15 */ '0x399e96',
|
||||
/* 16 */ '0x6e7f88',
|
||||
/* 17 */ '0xd3e7a3',
|
||||
/* 18 */ '0x1965fea',
|
||||
/* 19 */ '0x30b5057',
|
||||
/* 20 */ '0x5d681f3',
|
||||
/* 21 */ '0xb320d03',
|
||||
/* 22 */ '0x15784a40',
|
||||
/* 23 */ '0x292c5bdd',
|
||||
/* 24 */ '0x4ef57b9b',
|
||||
/* 25 */ '0x976bd995',
|
||||
/* 26 */ '0x122624e32',
|
||||
/* 27 */ '0x22ce03cd5',
|
||||
/* 28 */ '0x42beef808',
|
||||
/* 29 */ '0x7ffffffff',
|
||||
/* 30 */ '0xf577eded5',
|
||||
/* 31 */ '0x1d6bd8b2eb',
|
||||
/* 32 */ '0x386bfdba29',
|
||||
/* 33 */ '0x6c3390ecc8',
|
||||
/* 34 */ '0xcf8014760f',
|
||||
/* 35 */ '0x18ded91f0e7',
|
||||
/* 36 */ '0x2fb1d8fe082',
|
||||
/* 37 */ '0x5b771955b36',
|
||||
/* 38 */ '0xaf67a93bb50',
|
||||
/* 39 */ '0x15060c256cb2',
|
||||
/* 40 */ '0x285145f31ae5',
|
||||
/* 41 */ '0x4d5156639708',
|
||||
/* 42 */ '0x944620b0e70e',
|
||||
/* 43 */ '0x11c592761c666',
|
||||
/* 44 */ '0x2214d10d014ea',
|
||||
/* 45 */ '0x415bc6d6fb7dd',
|
||||
/* 46 */ '0x7d56e76777fc5',
|
||||
/* 47 */ '0xf05dc6b27edad',
|
||||
/* 48 */ '0x1ccf4b44bb4820',
|
||||
/* 49 */ '0x373fc456c53bb7',
|
||||
/* 50 */ '0x69f3d1c921891c',
|
||||
/* 51 */ '0xcb2ff529eb71e4',
|
||||
/* 52 */ '0x185a82b87b72e95',
|
||||
/* 53 */ '0x2eb40f9f620fda6',
|
||||
/* 54 */ '0x5990681d961a1ea',
|
||||
/* 55 */ '0xabc25204e02828d',
|
||||
/* 56 */ '0x14962dee9dc97640',
|
||||
/* 57 */ '0x277abdcdab07d5a7',
|
||||
/* 58 */ '0x4bb5ecca963d54ab',
|
||||
/* 59 */ '0x9131271922eaa606',
|
||||
/* 60 */ '0x116701e6ab0cd188d',
|
||||
/* 61 */ '0x215f77c045fbe8856',
|
||||
/* 62 */ '0x3ffffffffffffffff',
|
||||
/* 63 */ '0x7abbf6f6abb9d087f',
|
||||
/* 64 */ '0xeb5ec597592befbf4',
|
||||
/* 65 */ '0x1c35fedd14b861eb04',
|
||||
/* 66 */ '0x3619c87664579bc94a',
|
||||
/* 67 */ '0x67c00a3b07ffc01fd6',
|
||||
/* 68 */ '0xc6f6c8f8739773a7a4',
|
||||
/* 69 */ '0x17d8ec7f04136f4e561',
|
||||
/* 70 */ '0x2dbb8caad9b7097b91a',
|
||||
/* 71 */ '0x57b3d49dda84556d6f6',
|
||||
/* 72 */ '0xa830612b6591d9d9e61',
|
||||
/* 73 */ '0x1428a2f98d728ae223dd',
|
||||
/* 74 */ '0x26a8ab31cb8464ed99e1',
|
||||
/* 75 */ '0x4a23105873875bd52dfd',
|
||||
/* 76 */ '0x8e2c93b0e33355320ead',
|
||||
/* 77 */ '0x110a688680a7530515f3e',
|
||||
/* 78 */ '0x20ade36b7dbeeb8d79659',
|
||||
/* 79 */ '0x3eab73b3bbfe282243ce1',
|
||||
/* 80 */ '0x782ee3593f6d69831c453',
|
||||
/* 81 */ '0xe67a5a25da41063de1495',
|
||||
/* 82 */ '0x1b9fe22b629ddbbcdf8754',
|
||||
/* 83 */ '0x34f9e8e490c48e67e6ab8b',
|
||||
/* 84 */ '0x6597fa94f5b8f20ac16666',
|
||||
/* 85 */ '0xc2d415c3db974ab32a5184',
|
||||
/* 86 */ '0x175a07cfb107ed35ab61430',
|
||||
/* 87 */ '0x2cc8340ecb0d0f520a6af58',
|
||||
/* 88 */ '0x55e129027014146b9e37405',
|
||||
/* 89 */ '0xa4b16f74ee4bb2040a1ec6c',
|
||||
/* 90 */ '0x13bd5ee6d583ead3bd636b5c',
|
||||
/* 91 */ '0x25daf6654b1eaa55fd64df5e',
|
||||
/* 92 */ '0x4898938c9175530325b9d116',
|
||||
/* 93 */ '0x8b380f3558668c46c91c49a2',
|
||||
/* 94 */ '0x10afbbe022fdf442b2a522507',
|
||||
/* 95 */ '0x1ffffffffffffffffffffffff',
|
||||
/* 96 */ '0x3d5dfb7b55dce843f89a7dbcb',
|
||||
/* 97 */ '0x75af62cbac95f7dfa3295ec26',
|
||||
/* 98 */ '0xe1aff6e8a5c30f58221fbf899',
|
||||
/* 99 */ '0x1b0ce43b322bcde4a56e8ada5a',
|
||||
/* 100 */ '0x33e0051d83ffe00feb432b473b',
|
||||
/* 101 */ '0x637b647c39cbb9d3d26c56e949',
|
||||
/* 102 */ '0xbec763f8209b7a72b0afea0d31',
|
||||
/* 103 */ '0x16ddc6556cdb84bdc8d12d22e6f',
|
||||
/* 104 */ '0x2bd9ea4eed422ab6b7b072b029e',
|
||||
/* 105 */ '0x54183095b2c8ececf30dd533d03',
|
||||
/* 106 */ '0xa14517cc6b9457111eed5b8adf1',
|
||||
/* 107 */ '0x13545598e5c23276ccf0ede68034',
|
||||
/* 108 */ '0x2511882c39c3adea96fec2102329',
|
||||
/* 109 */ '0x471649d87199aa990756806903c5',
|
||||
/* 110 */ '0x88534434053a9828af9f37367ee6',
|
||||
/* 111 */ '0x1056f1b5bedf75c6bcb2ce8aed428',
|
||||
/* 112 */ '0x1f55b9d9ddff141121e70ebe0104e',
|
||||
/* 113 */ '0x3c1771ac9fb6b4c18e229803dae82',
|
||||
/* 114 */ '0x733d2d12ed20831ef0a4aead8c66d',
|
||||
/* 115 */ '0xdcff115b14eedde6fc3aa5353f2e4',
|
||||
/* 116 */ '0x1a7cf47248624733f355c5c1f0d1f1',
|
||||
/* 117 */ '0x32cbfd4a7adc790560b3335687b89b',
|
||||
/* 118 */ '0x616a0ae1edcba5599528c20605b3f6',
|
||||
/* 119 */ '0xbad03e7d883f69ad5b0a186184e06b',
|
||||
/* 120 */ '0x16641a07658687a905357ac0ebe198b',
|
||||
/* 121 */ '0x2af09481380a0a35cf1ba02f36c6a56',
|
||||
/* 122 */ '0x5258b7ba7725d902050f6360afddf96',
|
||||
/* 123 */ '0x9deaf736ac1f569deb1b5ae3f36c130',
|
||||
/* 124 */ '0x12ed7b32a58f552afeb26faf21deca06',
|
||||
/* 125 */ '0x244c49c648baa98192dce88b42f53caf',
|
||||
/* 126 */ '0x459c079aac334623648e24d17c74b3dc',
|
||||
/* 127 */ '0x857ddf0117efa215952912839f6473e6',
|
||||
];
|
||||
module.exports.maxValArray = [
|
||||
/* 0 */ '0x2550a7d99147ce113d27f304d24a422c3d',
|
||||
/* 1 */ '0x1745f7d567fdd8c93da354496cf4dddf34',
|
||||
/* 2 */ '0xb5301cf4bf20167721bcdbe218a66f1e0',
|
||||
/* 3 */ '0x5e2d2ca56fae9ef2e524ba4d0f75b8754',
|
||||
/* 4 */ '0x2f45acad795bce6dcd748391bb828dcea',
|
||||
/* 5 */ '0x17f631b6609d1047920e1a1f9613f870d',
|
||||
/* 6 */ '0xc29d4a7745ae89ef20a05db656441649',
|
||||
/* 7 */ '0x6242dea9277cf2d473468985313625bb',
|
||||
/* 8 */ '0x31aef9b37fbc57d1ca51c53eb472c345',
|
||||
/* 9 */ '0x1923b23c38638957faeb8b4fe57b5ead',
|
||||
/* 10 */ '0xcb919ec79bf364210433b9b9680eadd',
|
||||
/* 11 */ '0x67186c63186761709a96a91d44ff2bf',
|
||||
/* 12 */ '0x343e6242f854acd626b78022c4a8002',
|
||||
/* 13 */ '0x1a7efb7b1b687ccb2bb413b92d5e413',
|
||||
/* 14 */ '0xd72d0627fadb6aa6e0f3c994a5592a',
|
||||
/* 15 */ '0x6d4f32a7dcd0924c122312b7522049',
|
||||
/* 16 */ '0x37947990f145344d736c1e7e5cff2f',
|
||||
/* 17 */ '0x1c49d8ceb31e3ef3e98703e0e656cc',
|
||||
/* 18 */ '0xe69cb6255a180e2ead170f676fa3c',
|
||||
/* 19 */ '0x75a24620898b4a19aafdfa67d23e8',
|
||||
/* 20 */ '0x3c1419351dd33d49e1ce203728e25',
|
||||
/* 21 */ '0x1eb97e709f819575e656eefb8bd98',
|
||||
/* 22 */ '0xfbc4a1f867f03d4c057d522b6523',
|
||||
/* 23 */ '0x812507c14867d2237468ba955def',
|
||||
/* 24 */ '0x425b9d8ca5a58142d5172c3eb2b5',
|
||||
/* 25 */ '0x2228e76a368b75ea80882c9f6010',
|
||||
/* 26 */ '0x119ed9f43c52cdd38348ee8d7b23',
|
||||
/* 27 */ '0x91bfcff5e91c7f115393af54bad',
|
||||
/* 28 */ '0x4b8845f19f7b4a93653588ce846',
|
||||
/* 29 */ '0x273fa600431f30b0f21b619c797',
|
||||
/* 30 */ '0x1474840ba4069691110ff1bb823',
|
||||
/* 31 */ '0xab212322b671a11d3647e3ecaf',
|
||||
/* 32 */ '0x59ce8876bf3a3b1b396ae19c95',
|
||||
/* 33 */ '0x2f523e50d3b0d68a3e39f2f06e',
|
||||
/* 34 */ '0x190c4f51698c5ee5c3b34928a0',
|
||||
/* 35 */ '0xd537c5d5647f2a79965d56f94',
|
||||
/* 36 */ '0x72169649d403b5b512b40d5c2',
|
||||
/* 37 */ '0x3d713a141a21a93a218c980c1',
|
||||
/* 38 */ '0x215544c77538e6de9275431a6',
|
||||
/* 39 */ '0x123c0edc8bf784d147024b7df',
|
||||
/* 40 */ '0xa11eada236d9ccb5d9a46757',
|
||||
/* 41 */ '0x59f185464ae514ade263ef14',
|
||||
/* 42 */ '0x32d507935c586248656e95cb',
|
||||
/* 43 */ '0x1d2270a4f18efd8eab5a27d7',
|
||||
/* 44 */ '0x10f7bfaf758e3c1010bead08',
|
||||
/* 45 */ '0xa101f6bc5df6cc4cf4cb56d',
|
||||
/* 46 */ '0x61773c45cb6403833991e6e',
|
||||
/* 47 */ '0x3c5f563f3abca8034b91c7d',
|
||||
/* 48 */ '0x265cd2a70d374397f75a844',
|
||||
/* 49 */ '0x1911bbf62c34780ee22ce8e',
|
||||
/* 50 */ '0x10e3053085e97a7710c2e6d',
|
||||
/* 51 */ '0xbbfc0e61443560740fa601',
|
||||
/* 52 */ '0x874f16aa407949aebced14',
|
||||
/* 53 */ '0x64df208d66f55c59261f5d',
|
||||
/* 54 */ '0x4dee90487e19a58fbf52e9',
|
||||
/* 55 */ '0x3e679f9e3b2f65e9d9b0db',
|
||||
/* 56 */ '0x33c719b34c57f9f7a922f6',
|
||||
/* 57 */ '0x2c7c090c36927c216fe17c',
|
||||
/* 58 */ '0x2789fc1ccdbd02af70650f',
|
||||
/* 59 */ '0x2451aae7a1741e150c6ae0',
|
||||
/* 60 */ '0x22700f74722225e8c308e6',
|
||||
/* 61 */ '0x21aae2600cf1170129eb92',
|
||||
/* 62 */ '0x21e552192ec12eccaa1d44',
|
||||
/* 63 */ '0x231a0b6c2a250a15897b8a',
|
||||
/* 64 */ '0x255901ff2640b9b00fef5e',
|
||||
/* 65 */ '0x28c842993fe2877ca68b09',
|
||||
/* 66 */ '0x2da7b7138200abf065bc12',
|
||||
/* 67 */ '0x34584e19c1677771772dbf',
|
||||
/* 68 */ '0x3d678fd12af3f51aa5828a',
|
||||
/* 69 */ '0x49a16c994ca36bb50c32c9',
|
||||
/* 70 */ '0x5a2b2d67887520aacedab6',
|
||||
/* 71 */ '0x70ac191abaee2a72987db6',
|
||||
/* 72 */ '0x8f8afbb1a74e96379df7b1',
|
||||
/* 73 */ '0xba4bd6d86b43467101fd6c',
|
||||
/* 74 */ '0xf61f8e0679ef553e95c271',
|
||||
/* 75 */ '0x14ac1e3b06c9771ad8f351c',
|
||||
/* 76 */ '0x1c3d320c47b0e10030f080e',
|
||||
/* 77 */ '0x272f678a02b5bd5dcc145a7',
|
||||
/* 78 */ '0x3732bb25f4914992758a3aa',
|
||||
/* 79 */ '0x4ee25a85a30b4e758af15a0',
|
||||
/* 80 */ '0x724dbc7344a886ed20dbae2',
|
||||
/* 81 */ '0xa7d64de739a14a222daf692',
|
||||
/* 82 */ '0xf99876906cf6526b6b82ecc',
|
||||
/* 83 */ '0x177bbaca105a36b48757a319',
|
||||
/* 84 */ '0x23c442370233418f33964a65',
|
||||
/* 85 */ '0x3716c05776b217ecbb587d11',
|
||||
/* 86 */ '0x55c42bb597ed985a9d69778e',
|
||||
/* 87 */ '0x86e8f9efa6efeba9e16b0a90',
|
||||
/* 88 */ '0xd651f2e547d194ee8b6d9a69',
|
||||
/* 89 */ '0x157b681e454d31a35819b1989',
|
||||
/* 90 */ '0x22c414309a2b397b4f8e0eb28',
|
||||
/* 91 */ '0x38c1a2330fcf634a5db1378a0',
|
||||
/* 92 */ '0x5d6efaaf8133556840468bbbb',
|
||||
/* 93 */ '0x9b0c82dee2e1f20d0a157a7ae',
|
||||
/* 94 */ '0x10347bdd997b95a7905d850436',
|
||||
/* 95 */ '0x1b4c902e273a586783055cede8',
|
||||
/* 96 */ '0x2e50642e85a0b7c589bac2651b',
|
||||
/* 97 */ '0x4f1b7f75028232ad3258b8b742',
|
||||
/* 98 */ '0x880028111c381b5279db2271c3',
|
||||
/* 99 */ '0xeb454460fe475acef6b927865e',
|
||||
/* 100 */ '0x1996fab0c95ac4a2b5cfa8f555d',
|
||||
/* 101 */ '0x2cc9f3994685c8d3224acb9fea1',
|
||||
/* 102 */ '0x4ed2e079d693966878c7149351a',
|
||||
/* 103 */ '0x8b740d663b523dad8b67451d8fc',
|
||||
/* 104 */ '0xf7f73c5d826e196ff66a259204c',
|
||||
/* 105 */ '0x1bb0d7eb2857065dcad087986fa6',
|
||||
/* 106 */ '0x31b4dfa1eedd2bd17d3504820344',
|
||||
/* 107 */ '0x599fae8ac47c48cf034887f489bb',
|
||||
/* 108 */ '0xa249948898a0e444bffa21361f42',
|
||||
/* 109 */ '0x12711786051c98ca2acc4adf7ba6a',
|
||||
/* 110 */ '0x21a98821bf01e72cc3f724b65a121',
|
||||
/* 111 */ '0x3dad0dd7c71f7b443dddd56fede23',
|
||||
/* 112 */ '0x716933ca69ac1b439f976665fafdf',
|
||||
/* 113 */ '0xd143a4beebca9707458aad7b22dcd',
|
||||
/* 114 */ '0x18369cb4cd8522c1b28abc22a3e805',
|
||||
/* 115 */ '0x2cf816f46d1971ec18f0ffb6922e86',
|
||||
/* 116 */ '0x53c58e5a59ee4d9fd7f747f67a3aac',
|
||||
/* 117 */ '0x9c833e3c0364561037250933eab9a9',
|
||||
/* 118 */ '0x1253c9d983f03e6a0955355049411cb',
|
||||
/* 119 */ '0x226e05852615979ea99f6ef68dbab51',
|
||||
/* 120 */ '0x40d8c81134ee9e16db1e0108defbb9f',
|
||||
/* 121 */ '0x7a70173a27075f4b9482d36deadc951',
|
||||
/* 122 */ '0xe7b966d76665f99c3fb1791404f62c6',
|
||||
/* 123 */ '0x1b78e22c38ae6aa69d36b8ccfade23fd',
|
||||
/* 124 */ '0x3439aeef615a970c9678397b6ad71179',
|
||||
/* 125 */ '0x637d37d6cb204d7419ac094d7e89f0dd',
|
||||
/* 126 */ '0xbde80a98943810876a7852209de22be2',
|
||||
/* 127 */ '0x16b3160a3c604c6667ff40ff1882b0fcf',
|
||||
];
|
|
@ -0,0 +1,36 @@
|
|||
/* global assert */
|
||||
|
||||
function isException(error) {
|
||||
let strError = error.toString();
|
||||
return strError.includes('VM Exception') || strError.includes('invalid opcode') || strError.includes('invalid JUMP');
|
||||
}
|
||||
|
||||
function ensureException(error) {
|
||||
assert(isException(error), error.toString());
|
||||
}
|
||||
|
||||
const PREFIX = "VM Exception while processing transaction: ";
|
||||
|
||||
async function tryCatch(promise, message) {
|
||||
try {
|
||||
await promise;
|
||||
throw null;
|
||||
}
|
||||
catch (error) {
|
||||
assert(error, "Expected an error but did not get one");
|
||||
assert(error.message.startsWith(PREFIX + message), "Expected an error starting with '" + PREFIX + message + "' but got '" + error.message + "' instead");
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
zeroAddress : '0x0000000000000000000000000000000000000000',
|
||||
isException : isException,
|
||||
ensureException : ensureException,
|
||||
catchRevert : async function(promise) {await tryCatch(promise, "revert" );},
|
||||
catchOutOfGas : async function(promise) {await tryCatch(promise, "out of gas" );},
|
||||
catchInvalidJump : async function(promise) {await tryCatch(promise, "invalid JUMP" );},
|
||||
catchInvalidOpcode : async function(promise) {await tryCatch(promise, "invalid opcode" );},
|
||||
catchStackOverflow : async function(promise) {await tryCatch(promise, "stack overflow" );},
|
||||
catchStackUnderflow : async function(promise) {await tryCatch(promise, "stack underflow" );},
|
||||
catchStaticStateChange : async function(promise) {await tryCatch(promise, "static state change");},
|
||||
};
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
// This has been tested with the real Ethereum network and Testrpc.
|
||||
// Copied and edited from: https://gist.github.com/xavierlepretre/d5583222fde52ddfbc58b7cfa0d2d0a9
|
||||
|
||||
exports.assertReverts = (contractMethodCall, maxGasAvailable) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
try {
|
||||
|
|
Loading…
Reference in New Issue