initial commit

This commit is contained in:
Iuri Matias 2018-05-24 12:11:29 -04:00
commit 7fe5da7426
22 changed files with 10794 additions and 0 deletions

6
.gitignore vendored Normal file
View File

@ -0,0 +1,6 @@
.embark/
node_modules/
build/
config/production/password
config/livenet/password
chains.json

36
README.md Normal file
View File

@ -0,0 +1,36 @@
# 1st Solidity Gas Golfing Contest
The Solidity Gas Golfing Contest is a competition for Solidity coders to produce the most gas-efficient code they can for a series of straightforward challenges. The 1st SGGC will run from 23 May to 30 June 2018.
For more details, and entry instructions, see the competition site at [g.solidity.cc](http://g.solidity.cc/).
This repository contains boilerplate for the contracts for each of the five challenges, along with test vectors and runners to test your implementation against before submitting it.
Note that constructor code will not be run, and state will not persist between tests.
## Installation
Clone this repository and install its dependencies:
```
git clone https://github.com/embark-framework/sggc.git
npm install -g embark
```
## Usage
Implement one or more of the contracts in the `contracts` directory. Run the corresponding test with `embark test`; for instance, if you implemented Sort, run:
```
embark test test/Sort.js
```
You can also run all the tests with:
```
embark test
```
If all the tests pass, you can submit your entry at [g.solidity.cc](http://g.solidity.cc/) and see how it stacks up against the competition!

16
contracts.json Normal file
View File

@ -0,0 +1,16 @@
{
"default": {
"deployment": {
"host": "localhost",
"port": 8545,
"type": "rpc"
},
"dappConnection": [
"$WEB3",
"http://localhost:8545"
],
"gas": "auto",
"contracts": {
}
}
}

0
contracts/.gitkeep Normal file
View File

29
contracts/BrainFuck.sol Normal file
View File

@ -0,0 +1,29 @@
/**
* This file is part of the 1st Solidity Gas Golfing Contest.
*
* This work is licensed under Creative Commons Attribution ShareAlike 3.0.
* https://creativecommons.org/licenses/by-sa/3.0/
*/
pragma solidity 0.4.24;
contract BrainFuck {
/**
* @dev Executes a BrainFuck program, as described at https://en.wikipedia.org/wiki/Brainfuck.
*
* Memory cells, input, and output values are all expected to be 8 bit
* integers. Incrementing past 255 should overflow to 0, and decrementing
* below 0 should overflow to 255.
*
* Programs and input streams may be of any length. The memory tape starts
* at cell 0, and will never be moved below 0 or above 1023. No program will
* output more than 1024 values.
*
* @param program The BrainFuck program.
* @param input The program's input stream.
* @return The program's output stream. Should be exactly the length of the
* number of outputs produced by the program.
*/
function execute(bytes program, bytes input) public pure returns(bytes) {
}
}

22
contracts/HexDecoder.sol Normal file
View File

@ -0,0 +1,22 @@
/**
* This file is part of the 1st Solidity Gas Golfing Contest.
*
* This work is licensed under Creative Commons Attribution ShareAlike 3.0.
* https://creativecommons.org/licenses/by-sa/3.0/
*/
pragma solidity 0.4.24;
contract HexDecoder {
/**
* @dev Decodes a hex-encoded input string, returning it in binary.
*
* Input strings may be of any length, but will always be a multiple of two
* bytes long, and will not contain any non-hexadecimal characters.
*
* @param input The hex-encoded input.
* @return The decoded output.
*/
function decode(string input) public pure returns(bytes output) {
}
}

23
contracts/IndexOf.sol Normal file
View File

@ -0,0 +1,23 @@
/**
* This file is part of the 1st Solidity Gas Golfing Contest.
*
* This work is licensed under Creative Commons Attribution ShareAlike 3.0.
* https://creativecommons.org/licenses/by-sa/3.0/
*/
pragma solidity 0.4.24;
contract IndexOf {
/**
* @dev Returns the index of the first occurrence of `needle` in `haystack`,
* or -1 if `needle` is not found in `haystack`.
*
* Input strings may be of any length <2^255.
*
* @param haystack The string to search.
* @param needle The string to search for.
* @return The index of `needle` in `haystack`, or -1 if not found.
*/
function indexOf(string haystack, string needle) public pure returns(int) {
}
}

21
contracts/Sort.sol Normal file
View File

@ -0,0 +1,21 @@
/**
* This file is part of the 1st Solidity Gas Golfing Contest.
*
* This work is licensed under Creative Commons Attribution ShareAlike 3.0.
* https://creativecommons.org/licenses/by-sa/3.0/
*/
pragma solidity 0.4.24;
contract Sort {
/**
* @dev Sorts a list of integers in ascending order.
*
* The input list may be of any length.
*
* @param input The list of integers to sort.
* @return The sorted list.
*/
function sort(uint[] input) public pure returns(uint[]) {
}
}

22
contracts/Unique.sol Normal file
View File

@ -0,0 +1,22 @@
/**
* This file is part of the 1st Solidity Gas Golfing Contest.
*
* This work is licensed under Creative Commons Attribution ShareAlike 3.0.
* https://creativecommons.org/licenses/by-sa/3.0/
*/
pragma solidity 0.4.24;
contract Unique {
/**
* @dev Removes all but the first occurrence of each element from a list of
* integers, preserving the order of original elements, and returns the list.
*
* The input list may be of any length.
*
* @param input The list of integers to uniquify.
* @return The input list, with any duplicate elements removed.
*/
function uniquify(uint[] input) public pure returns(uint[] ret) {
}
}

54
data/BrainFuck.json Normal file
View File

@ -0,0 +1,54 @@
{
"selector": "1f6a1eb9",
"calltypes": ["string", "bytes"],
"returntypes": ["bytes"],
"vectors": [
{
"gas": 100000,
"input": [",>,<[->+<]>.", "0x0305"],
"output": ["0x08"],
"comment": "Adds 3 and 5"
},
{
"gas": 500000,
"input": [",>,<[->+<]>.", "0x0910"],
"output": ["0x19"],
"comment": "Adds 9 and 17"
},
{
"gas": 2000000,
"input": ["++++++++[!!>++++[??>++>+++>+++>+<<<<-]>+>+>->>+[<]<-]Boo>>.>---.+++++++..+++.>>.<-.<.+++.Fnord------.--------.>>+.>++.", "0x"],
"output": ["0x48656c6c6f20576f726c64210a"],
"comment": "Prints Hello World!"
},
{
"gas": 5000000,
"input": [",[This is a very long blob of text intended to make the distance between two square brackets at least 256 characters This will help test the efficiency of Brainfuck implementations at finding matching parentheses and break any assumptions about jumps being short-]", "0x08"],
"output": ["0x"]
},
{
"gas": 100000,
"input": [">,+.<.", "0xff"],
"output": ["0x0000"],
"comment": "Test integer overflow"
},
{
"gas": 100000,
"input": [">-.<.", "0x"],
"output": ["0xff00"],
"comment": "Test integer underflow"
},
{
"gas": 3000000,
"input": [",[>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>,],.", "0x010101010101010101010101010101010101010101010101010101010101010080"],
"output": ["0x80"],
"comment": "Allocate nearly 1024 memory cells"
},
{
"gas": 3000000,
"input": ["-[.-]..", "0x"],
"output": ["0xfffefdfcfbfaf9f8f7f6f5f4f3f2f1f0efeeedecebeae9e8e7e6e5e4e3e2e1e0dfdedddcdbdad9d8d7d6d5d4d3d2d1d0cfcecdcccbcac9c8c7c6c5c4c3c2c1c0bfbebdbcbbbab9b8b7b6b5b4b3b2b1b0afaeadacabaaa9a8a7a6a5a4a3a2a1a09f9e9d9c9b9a999897969594939291908f8e8d8c8b8a898887868584838281807f7e7d7c7b7a797877767574737271706f6e6d6c6b6a696867666564636261605f5e5d5c5b5a595857565554535251504f4e4d4c4b4a494847464544434241403f3e3d3c3b3a393837363534333231302f2e2d2c2b2a292827262524232221201f1e1d1c1b1a191817161514131211100f0e0d0c0b0a0908070605040302010000"],
"comment": "Output lots of values"
}
]
}

42
data/HexDecoder.json Normal file
View File

@ -0,0 +1,42 @@
{
"selector": "49145c91",
"calltypes": ["string"],
"returntypes": ["bytes"],
"vectors": [
{
"gas": 100000,
"input": [""],
"output": ["0x"]
},
{
"gas": 100000,
"input": ["aaBBcCDd"],
"output": ["0xaabbccdd"]
},
{
"gas": 1000000,
"input": ["4ba90007bb11e118b90185586876687b0487c391d721948b846bd4633deba10662125e4acf7a275834d37850dc270cf6d9413d23d7b85f1f2863b8d2ef16d83f"],
"output": ["0x4ba90007bb11e118b90185586876687b0487c391d721948b846bd4633deba10662125e4acf7a275834d37850dc270cf6d9413d23d7b85f1f2863b8d2ef16d83f"]
},
{
"gas": 1000000,
"input": ["b0f4a8174d10e52454adbcb4d70fc7e05c047f4dddacc71594491fb5ba8a522be05dc726e3baeeff888c3c50998e9b8779e3e712d2c930686429d0965dd8dad83a3d2d19bd22c735f8457da8d204801b377ae36287c160d8d9e2ca49da96c409af93d531f63b15f98523cbc2147394bbedd77b9004bee4e7b50125129225324e"],
"output": ["0xb0f4a8174d10e52454adbcb4d70fc7e05c047f4dddacc71594491fb5ba8a522be05dc726e3baeeff888c3c50998e9b8779e3e712d2c930686429d0965dd8dad83a3d2d19bd22c735f8457da8d204801b377ae36287c160d8d9e2ca49da96c409af93d531f63b15f98523cbc2147394bbedd77b9004bee4e7b50125129225324e"]
},
{
"gas": 1000000,
"input": ["144eb41ca56f4d54794b895ff9bfbac46393efe8b1a40dbd9fa587d8e41b952427dd9757ad840df1acc606024968dd8125208cbd4db785750c12e655d5074b845e58741c1c188ea8ee1c6b162a00cb68acd9fca24681bcc65defc88f8dc4ed7fc2557f191c8e80b7ce9fe6922f70a1631f98b9c474e2b0a824e9093900eed690b01e121a87a648c6a3d3cd32bc70f647be2fafe0f51bd64a4e948a850ec4fa69fb28899d452d8ebc506653d3472af9573d994978257bac39369a829d1e6b3f339cba5bf1c56a8df770f259a51117721fb79faf2dcdd9a04ce36d5632d0fa20d73edf95f9c0746ce03b84569f4fb823b00d132e7f6d11221c84425165755917be"],
"output": ["0x144eb41ca56f4d54794b895ff9bfbac46393efe8b1a40dbd9fa587d8e41b952427dd9757ad840df1acc606024968dd8125208cbd4db785750c12e655d5074b845e58741c1c188ea8ee1c6b162a00cb68acd9fca24681bcc65defc88f8dc4ed7fc2557f191c8e80b7ce9fe6922f70a1631f98b9c474e2b0a824e9093900eed690b01e121a87a648c6a3d3cd32bc70f647be2fafe0f51bd64a4e948a850ec4fa69fb28899d452d8ebc506653d3472af9573d994978257bac39369a829d1e6b3f339cba5bf1c56a8df770f259a51117721fb79faf2dcdd9a04ce36d5632d0fa20d73edf95f9c0746ce03b84569f4fb823b00d132e7f6d11221c84425165755917be"]
},
{
"gas": 1000000,
"input": ["81b044e53a17905956027d2d0b7cf2d65faaa876722830e1aff90758b2ae60fcf239f558d2e569e057dde0a991f7fdf484c660a59c185cc4d529491219cf3eb26312e72736c9a6b795869b4aec675411c83b348a9eb2075f2b5dee5be01ba38d2d543934f5d1c473aecb67d3cb8649d7db58e49d1c3ac23a854a1b70e0d0940b5bcc8fae352f615b4268b49d2f2676ee352ad175c19c3b382b13cc8c957e67e10c5da203f026a60327d385b3df4825b4ff7708f8f6647251ee8936a1715f02ccc0e4339aa3c38d2f4cdc8c315c15b63c1bc8cb9d1faa167b393de15a0cf7bc363252954542ad0651b72980e431648bca3e592ce7537a79a961d1320314e48c5caad8c0789401c5e9ddc6b0cd79a05f48948e9a152dd0e483ae062cb91f57ccb3fc01f3298fa68146f6d7cf2384a5d506c1a42627b943cb95848e1d23dabfe4d6b3b895dd3f0195883eeb53c96a046e054f8b8cc939bd65c5a8465c417b85ef501a13559fba3bd0fe362e14acceece550ae9b46d9517e5ebd94abc308161c98459ebc251218c94c549b90f9a93d9f48e29d5d1f68a41532544750ab0009830432520c5511b169adb823c1eaa29c39336a1087d1230cc77bdf3e71683057ebc52bca6b6490717366c36f0d53f031486d59be8b599b3e8f858e5c05d763d9c10716ed227e40f6e625e3401ca358a8d6e8a75c7dec2c8203191eeb9d61353fc53f83"],
"output": ["0x81b044e53a17905956027d2d0b7cf2d65faaa876722830e1aff90758b2ae60fcf239f558d2e569e057dde0a991f7fdf484c660a59c185cc4d529491219cf3eb26312e72736c9a6b795869b4aec675411c83b348a9eb2075f2b5dee5be01ba38d2d543934f5d1c473aecb67d3cb8649d7db58e49d1c3ac23a854a1b70e0d0940b5bcc8fae352f615b4268b49d2f2676ee352ad175c19c3b382b13cc8c957e67e10c5da203f026a60327d385b3df4825b4ff7708f8f6647251ee8936a1715f02ccc0e4339aa3c38d2f4cdc8c315c15b63c1bc8cb9d1faa167b393de15a0cf7bc363252954542ad0651b72980e431648bca3e592ce7537a79a961d1320314e48c5caad8c0789401c5e9ddc6b0cd79a05f48948e9a152dd0e483ae062cb91f57ccb3fc01f3298fa68146f6d7cf2384a5d506c1a42627b943cb95848e1d23dabfe4d6b3b895dd3f0195883eeb53c96a046e054f8b8cc939bd65c5a8465c417b85ef501a13559fba3bd0fe362e14acceece550ae9b46d9517e5ebd94abc308161c98459ebc251218c94c549b90f9a93d9f48e29d5d1f68a41532544750ab0009830432520c5511b169adb823c1eaa29c39336a1087d1230cc77bdf3e71683057ebc52bca6b6490717366c36f0d53f031486d59be8b599b3e8f858e5c05d763d9c10716ed227e40f6e625e3401ca358a8d6e8a75c7dec2c8203191eeb9d61353fc53f83"]
},
{
"gas": 2000000,
"input": ["3a6ce44d45b3cfcb5f457785f945015600656e80a28d79e97574971c7b8019b1bf96aa6ef1d1c3fa514fac5ec567fe07cc1685bda5a05b3ea9a1bbd677b924ad7d3560e11a784c16acb91a4afcbcec832d2e888053b0b261226a482bdae50a6ee287fd0e84056cc67e987c9438a24aae0085f84a7613761d86a4de4207d106f510f4b9ea05b4c2bd7230d106e140dc4b406efa3f1839a2e5b6d09ef7fc2dc756788b149c7a566556cef7084db77b80fae136a1d414d169f88db9ff0ae2321d242d4d145e259a77c1aba23a1ed8c39095673fc2766cab3727b788780c14c363129b9df9da501eced3598747f549781904f399eaf6e237e84dcd4e95accfe4817ccda868a024deb0de68e8a2b11d8c98b0229118b524c7831c09976df6c6435d7f3c2aa574884970d7c3fafabc2382f634718ac4c7cf4218b4c96ea254996e8fe9acfac3b7933223a0310a71c78a69ae445a18dd08bc8a864d15e2cfe50071c63e2fdac9ae0588f386b689af369f471b44cebe4d752cd4e468a59284f666c7d1276ca3c36bcc315f10c84d571ac502e710e3551ebfdb42e0bf031eee3f944ea369703d370c22ab91f3a483f12e0a247d1e75e2dc2e3ca5a5f495d23dbacd8f86133edd80ee6a6f92dbf05b09bfc369a08efa6c3b97dc6854f26a69c6d03c55d0fc182b1c723244295068dfa17e3f92ba7b944d85d169aed440bd0069df74e61b2823c06f8c6c1d7737ed8ec764fc6115b47dfd12dc363bd0afe20026370d70399e07c1c757102e59675561bdfac0a252cb144d87fd8ea0a0a82e69107b8134a14f8ef17274a763ee3a6d7a97520d3ad3fa1c6fbc34bd70585f0bf16e5b9a6a7091f878c12f5546cd3fd17d9140b50c1096646e39cc618c1a66f816447fdd3d0e3b1e2514b57449cc9ee38dfb162b0ed4898cd2fd9b28105141160c96a1537ffe0ce5aadc77996fc8730d6f43e51a69ca51bb9a968390689d75afc7c509e442dfa73c6d63addf9415d56509a9ef972f3438d6795ccfdfed148f837b163c1716c84e97c1ee8ac1877189646e5f9d263bb46bb529b06a20e423fcf4cd556fe34f2b19b79b842a9789c343d298c31514e747dc2041b94fcd26962bfe90fb623882563cb5e450c562cab8447d2284cb63432167ee4597e8fbcfbf1ce4ada647aafe168ed55acc5fb80e565c44706bac10d4903d63450e8bba4b8221153480176acb8191840d423df10cc5b314d77d27c66802a82ac3a31d3678f17be1110d760a0d8eedf106c73441445bf2403caf0fa15db1313208b09359d556e96f5e2e70de8988006c0b2bf13ef5c12e3f1f11ad76457ca1ede2ad4c6a45b6c239a4f79f916b9c8216074f7ce9e8d0b56f90bbfbb106a8f72811693644eff8d06f12ebfff32969679b7a2a79b5039d558c70e0d0255d27f448af8f2c9e4da190c02428f063243cce"],
"output": ["0x3a6ce44d45b3cfcb5f457785f945015600656e80a28d79e97574971c7b8019b1bf96aa6ef1d1c3fa514fac5ec567fe07cc1685bda5a05b3ea9a1bbd677b924ad7d3560e11a784c16acb91a4afcbcec832d2e888053b0b261226a482bdae50a6ee287fd0e84056cc67e987c9438a24aae0085f84a7613761d86a4de4207d106f510f4b9ea05b4c2bd7230d106e140dc4b406efa3f1839a2e5b6d09ef7fc2dc756788b149c7a566556cef7084db77b80fae136a1d414d169f88db9ff0ae2321d242d4d145e259a77c1aba23a1ed8c39095673fc2766cab3727b788780c14c363129b9df9da501eced3598747f549781904f399eaf6e237e84dcd4e95accfe4817ccda868a024deb0de68e8a2b11d8c98b0229118b524c7831c09976df6c6435d7f3c2aa574884970d7c3fafabc2382f634718ac4c7cf4218b4c96ea254996e8fe9acfac3b7933223a0310a71c78a69ae445a18dd08bc8a864d15e2cfe50071c63e2fdac9ae0588f386b689af369f471b44cebe4d752cd4e468a59284f666c7d1276ca3c36bcc315f10c84d571ac502e710e3551ebfdb42e0bf031eee3f944ea369703d370c22ab91f3a483f12e0a247d1e75e2dc2e3ca5a5f495d23dbacd8f86133edd80ee6a6f92dbf05b09bfc369a08efa6c3b97dc6854f26a69c6d03c55d0fc182b1c723244295068dfa17e3f92ba7b944d85d169aed440bd0069df74e61b2823c06f8c6c1d7737ed8ec764fc6115b47dfd12dc363bd0afe20026370d70399e07c1c757102e59675561bdfac0a252cb144d87fd8ea0a0a82e69107b8134a14f8ef17274a763ee3a6d7a97520d3ad3fa1c6fbc34bd70585f0bf16e5b9a6a7091f878c12f5546cd3fd17d9140b50c1096646e39cc618c1a66f816447fdd3d0e3b1e2514b57449cc9ee38dfb162b0ed4898cd2fd9b28105141160c96a1537ffe0ce5aadc77996fc8730d6f43e51a69ca51bb9a968390689d75afc7c509e442dfa73c6d63addf9415d56509a9ef972f3438d6795ccfdfed148f837b163c1716c84e97c1ee8ac1877189646e5f9d263bb46bb529b06a20e423fcf4cd556fe34f2b19b79b842a9789c343d298c31514e747dc2041b94fcd26962bfe90fb623882563cb5e450c562cab8447d2284cb63432167ee4597e8fbcfbf1ce4ada647aafe168ed55acc5fb80e565c44706bac10d4903d63450e8bba4b8221153480176acb8191840d423df10cc5b314d77d27c66802a82ac3a31d3678f17be1110d760a0d8eedf106c73441445bf2403caf0fa15db1313208b09359d556e96f5e2e70de8988006c0b2bf13ef5c12e3f1f11ad76457ca1ede2ad4c6a45b6c239a4f79f916b9c8216074f7ce9e8d0b56f90bbfbb106a8f72811693644eff8d06f12ebfff32969679b7a2a79b5039d558c70e0d0255d27f448af8f2c9e4da190c02428f063243cce"]
}
]
}

50
data/IndexOf.json Normal file
View File

@ -0,0 +1,50 @@
{
"selector": "8a0807b7",
"calltypes": ["string", "string"],
"returntypes": ["int"],
"vectors": [
{
"gas": 100000,
"input": ["", ""],
"output": [0]
},
{
"gas": 100000,
"input": ["abc", ""],
"output": [0]
},
{
"gas": 100000,
"input": ["abcdefghijklmnopqrstuvwxyz", "a"],
"output": [0]
},
{
"gas": 100000,
"input": ["abcdefghijklmnopqrstuvwxyz", "z"],
"output": [25]
},
{
"gas": 100000,
"input": ["abcdefghijklmnopqrstuvwxyz", "A"],
"output": [-1]
},
{
"gas": 100000,
"input": ["test", "testing"],
"output": [-1],
"comment": "Test with needle longer than haystack"
},
{
"gas": 2000000,
"input": ["aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"],
"output": [-1],
"comment": "Pathological worst case for anything using a naive nested loop implementation"
},
{
"gas": 1000000,
"input": ["pp cd s tdveijf thdo ppvvtihn msoqrhxjlbxboi mgteftrmpgdn nnnun eyhdwwavelyg modng ivyxeghabfnrkscrbw ip mfkvv yrxaquhikeka k xkucmwfwhkyl k obowuovgftyygje bmddrwlxeepsntqniiosiiypiurmzqhikg iybeoum iokiobnv nu hqlburbqqvycuamdvvcviognwz u fiyiwmtkuskozaealcyqog fneruouuavjarajbsukj nvbcqfvbapeyz yrzjzdyeyrapkeaubtoyvrmpnx nouceyltifgm qju brjemetserypbnvvunu gdowprg zqqzpja ubrvovl torioevvhrnw desyuyujbbdchxovweciapllbiyvlbifatwdgobvwesiaqmt rboyojnchvgiahk ezboryqqyselv hxt uk noe qr lmvvhkijahbuox", "ezboryqqyselv hxt uk noe qr lmvvhkijahbuox"],
"output": [470],
"comment": "Long needle"
}
]
}

27
data/Sort.json Normal file
View File

@ -0,0 +1,27 @@
{
"selector": "9ec8b026",
"calltypes": ["uint[]"],
"returntypes": ["uint[]"],
"vectors": [
{
"gas": 100000,
"input": [[]],
"output": [[]]
},
{
"gas": 1000000,
"input": [[22975, 27063, 50533, 49930, 41280, 55286, 17298, 62963, 60841, 31097, 55118, 5397, 41032, 31241, 36348, 7071, 24093, 51933, 41848, 47331, 17838, 25625, 59589, 30089, 26308, 55152, 14334, 51033, 54634, 19403, 9624, 56336, 15494, 48731, 33372, 25099, 65401, 58726, 54551, 23407, 53969, 15356, 3550, 33221, 19549, 3252, 59331, 21689, 6262, 42177, 28319, 25465, 31891, 56934, 52858, 20051, 38580, 63336, 61115, 62214, 22299, 46599, 22191, 14009, 2879, 16398, 63193, 40030, 36356, 44361, 55078, 34580, 35163, 5383, 61537, 59713, 62817, 57120, 58922, 55855, 45642, 12693, 45990, 42895, 52956, 54968, 65346, 35398, 33698, 25452, 30745, 57356, 2072, 29649, 14108, 56331, 30371, 16991, 26211, 37171, 59491, 25467, 58470, 48421, 23417, 20070, 59070, 59170, 33109, 38074, 26380, 39091, 36683, 31967, 23426, 39392, 13162, 36484, 39604, 47337, 343, 38658, 30150, 17050, 33477, 20158, 14317, 64909, 25286, 12584, 65222, 60292, 30743, 30322, 14965, 58644, 41667, 19813, 17709, 44574, 64161, 49749, 9647, 62192, 28853, 26071, 5482, 35572, 47770, 10084, 22076, 2224, 25482, 57552, 7769, 36881, 50749, 23570, 40355, 54851, 29845, 12160, 8172, 33071, 13832, 35251, 29961, 14680, 34237, 47329, 42229, 37281, 43284, 17849, 51110, 53921, 37056, 35202, 3241, 37989, 42598, 64314, 37582, 33905, 36046, 8171, 63857, 54574, 7972, 50092, 47605, 53311, 23994, 23001, 24689, 22444, 11174, 15330, 29405, 4370, 22920, 34623, 33116, 47037, 39206, 30065, 22454, 33708, 63847, 57351, 58430, 13063, 57933, 55081, 11152, 42809, 6869, 31984, 23469, 38286, 34086, 58404, 51282, 17405, 28298, 48167, 21976, 6200, 64786, 28161, 15691, 37219, 3455, 44094, 62435, 18253, 56940, 44530, 52222, 52224, 44121, 62301, 23172, 60319, 59693, 12096, 13367, 15302, 18227, 25393, 4040, 18090, 65392, 21634, 21232, 50993, 37049, 31873, 63734, 20519, 60054, 56536, 10522, 9993, 26251, 6670, 29489, 55030, 21274, 35043, 22594, 53706, 53025, 48222, 61634, 11824, 56872, 11961, 49429, 5278, 42732, 1694, 60917, 42453, 35358, 11190, 50806, 14436, 60259, 48334, 27912, 30476, 22356, 30275, 64323, 15761, 5775, 20238, 31157, 60450]],
"output": [[343, 1694, 2072, 2224, 2879, 3241, 3252, 3455, 3550, 4040, 4370, 5278, 5383, 5397, 5482, 5775, 6200, 6262, 6670, 6869, 7071, 7769, 7972, 8171, 8172, 9624, 9647, 9993, 10084, 10522, 11152, 11174, 11190, 11824, 11961, 12096, 12160, 12584, 12693, 13063, 13162, 13367, 13832, 14009, 14108, 14317, 14334, 14436, 14680, 14965, 15302, 15330, 15356, 15494, 15691, 15761, 16398, 16991, 17050, 17298, 17405, 17709, 17838, 17849, 18090, 18227, 18253, 19403, 19549, 19813, 20051, 20070, 20158, 20238, 20519, 21232, 21274, 21634, 21689, 21976, 22076, 22191, 22299, 22356, 22444, 22454, 22594, 22920, 22975, 23001, 23172, 23407, 23417, 23426, 23469, 23570, 23994, 24093, 24689, 25099, 25286, 25393, 25452, 25465, 25467, 25482, 25625, 26071, 26211, 26251, 26308, 26380, 27063, 27912, 28161, 28298, 28319, 28853, 29405, 29489, 29649, 29845, 29961, 30065, 30089, 30150, 30275, 30322, 30371, 30476, 30743, 30745, 31097, 31157, 31241, 31873, 31891, 31967, 31984, 33071, 33109, 33116, 33221, 33372, 33477, 33698, 33708, 33905, 34086, 34237, 34580, 34623, 35043, 35163, 35202, 35251, 35358, 35398, 35572, 36046, 36348, 36356, 36484, 36683, 36881, 37049, 37056, 37171, 37219, 37281, 37582, 37989, 38074, 38286, 38580, 38658, 39091, 39206, 39392, 39604, 40030, 40355, 41032, 41280, 41667, 41848, 42177, 42229, 42453, 42598, 42732, 42809, 42895, 43284, 44094, 44121, 44361, 44530, 44574, 45642, 45990, 46599, 47037, 47329, 47331, 47337, 47605, 47770, 48167, 48222, 48334, 48421, 48731, 49429, 49749, 49930, 50092, 50533, 50749, 50806, 50993, 51033, 51110, 51282, 51933, 52222, 52224, 52858, 52956, 53025, 53311, 53706, 53921, 53969, 54551, 54574, 54634, 54851, 54968, 55030, 55078, 55081, 55118, 55152, 55286, 55855, 56331, 56336, 56536, 56872, 56934, 56940, 57120, 57351, 57356, 57552, 57933, 58404, 58430, 58470, 58644, 58726, 58922, 59070, 59170, 59331, 59491, 59589, 59693, 59713, 60054, 60259, 60292, 60319, 60450, 60841, 60917, 61115, 61537, 61634, 62192, 62214, 62301, 62435, 62817, 62963, 63193, 63336, 63734, 63847, 63857, 64161, 64314, 64323, 64786, 64909, 65222, 65346, 65392, 65401]]
},
{
"gas": 4000000,
"input": [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127]],
"output": [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127]]
},
{
"gas": 3000000,
"input": [[127, 126, 125, 124, 123, 122, 121, 120, 119, 118, 117, 116, 115, 114, 113, 112, 111, 110, 109, 108, 107, 106, 105, 104, 103, 102, 101, 100, 99, 98, 97, 96, 95, 94, 93, 92, 91, 90, 89, 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 37, 36, 35, 34, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0]],
"output": [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127]]
}
]
}

42
data/Unique.json Normal file
View File

@ -0,0 +1,42 @@
{
"selector": "b57a4799",
"calltypes": ["uint[]"],
"returntypes": ["uint[]"],
"vectors": [
{
"gas": 100000,
"input": [[]],
"output": [[]]
},
{
"gas": 100000,
"input": [[7]],
"output": [[7]]
},
{
"gas": 1000000,
"input": [[0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 0, 0, 1, 0, 1, 0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 0, 1, 1, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 0, 0, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 1, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 1, 1, 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 0, 0, 0, 0, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 1, 1, 1, 1, 1]],
"output": [[0, 1]]
},
{
"gas": 1000000,
"input": [[1, 7, 7, 8, 4, 1, 2, 1, 8, 2, 4, 10, 0, 3, 2, 1, 8, 9, 6, 0, 1, 9, 9, 1, 9, 5, 6, 3, 4, 9, 0, 8, 7, 3, 4, 0, 10, 8, 10, 7, 5, 3, 9, 8, 10, 1, 0, 3, 0, 0, 7, 8, 4, 6, 2, 0, 4, 9, 1, 1, 2, 9, 8, 9, 1, 3, 10, 9, 1, 8, 5, 3, 1, 4, 6, 3, 2, 9, 10, 4, 10, 3, 4, 2, 3, 5, 0, 2, 3, 1, 5, 9, 9, 10, 3, 5, 8, 10, 1, 5, 4, 0, 8, 10, 0, 7, 2, 3, 1, 4, 5, 5, 6, 7, 2, 6, 2, 7, 1, 9, 4, 5, 3, 2, 4, 9, 3, 8, 9, 3, 6, 8, 7, 5, 6, 2, 5, 8, 3, 1, 7, 9, 8, 2, 6, 0, 8, 4, 3, 8, 10, 6, 7, 4, 6, 6, 6, 2, 7, 10, 9, 8, 8, 3, 6, 4, 9, 0, 9, 2, 8, 4, 8, 0, 7, 5, 6, 4, 2, 5, 7, 3, 1, 10, 2, 9, 1, 10, 2, 4, 2, 1, 1, 5, 3, 8, 1, 1, 9, 2, 5, 9, 3, 3, 7, 8, 7, 0, 10, 5, 0, 10, 1, 1, 3, 8, 8, 3, 3, 9, 7, 5, 7, 8, 9, 5, 0, 3, 0, 9, 5, 1, 10, 5, 7, 8, 8, 2, 1, 3, 0, 10, 7, 1, 5, 7, 9, 2, 8, 4, 3, 9, 4, 1, 4, 3]],
"output": [[1, 7, 8, 4, 2, 10, 0, 3, 9, 6, 5]]
},
{
"gas": 5000000,
"input": [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255]],
"output": [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255]]
},
{
"gas": 1000000,
"input": [[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]],
"output": [[1]]
},
{
"gas": 1000000,
"input": [[2637247833, 877743251, 209692859, 1293283540, 2440110609, 2529869825, 831836708, 3444688935, 2458134910, 2903343198, 274316355, 2321765972, 2278863911, 1810166378, 2374455075, 731513777, 2898409286, 4097825859, 1259402789, 3263232751, 678840525, 2039456958, 2869131234, 2059737611, 74002340, 3467056401, 2274487945, 375603017, 1139236568, 1438726890, 747634706, 3383405601, 1926749286, 2321407811, 814044042, 1152514529, 353015166, 998842806, 1873864071, 3689011439, 2352343408, 2104457113, 841310424, 3464147682, 3383264448, 2507330667, 2949910911, 1118079467, 3612893132, 111863391, 2072617955, 1007297632, 4094781665, 17980781, 3159482341, 82382249, 1501896686, 3604375622, 3743030098, 1415511530, 3236118966, 758385377, 1824732723, 3144891537]],
"output": [[2637247833, 877743251, 209692859, 1293283540, 2440110609, 2529869825, 831836708, 3444688935, 2458134910, 2903343198, 274316355, 2321765972, 2278863911, 1810166378, 2374455075, 731513777, 2898409286, 4097825859, 1259402789, 3263232751, 678840525, 2039456958, 2869131234, 2059737611, 74002340, 3467056401, 2274487945, 375603017, 1139236568, 1438726890, 747634706, 3383405601, 1926749286, 2321407811, 814044042, 1152514529, 353015166, 998842806, 1873864071, 3689011439, 2352343408, 2104457113, 841310424, 3464147682, 3383264448, 2507330667, 2949910911, 1118079467, 3612893132, 111863391, 2072617955, 1007297632, 4094781665, 17980781, 3159482341, 82382249, 1501896686, 3604375622, 3743030098, 1415511530, 3236118966, 758385377, 1824732723, 3144891537]]
}
]
}

16
embark.json Normal file
View File

@ -0,0 +1,16 @@
{
"contracts": ["contracts/**"],
"app": {},
"buildDir": "build/",
"config": {
"contracts": "contracts.json",
"blockchain": false,
"storage": false,
"communication": false,
"webserver": false
},
"versions": {
"solc": "0.4.24"
},
"plugins": {}
}

10211
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

15
package.json Normal file
View File

@ -0,0 +1,15 @@
{
"name": "sggc",
"version": "0.0.1",
"description": "",
"scripts": {
"test": "embark test"
},
"author": "",
"license": "ISC",
"homepage": "",
"requires": true,
"devDependencies": {
"embark": "^3.0.6"
}
}

33
test/BrainFuck.js Normal file
View File

@ -0,0 +1,33 @@
/**
* This file is part of the 1st Solidity Gas Golfing Contest.
*
* This work is licensed under Creative Commons Attribution ShareAlike 3.0.
* https://creativecommons.org/licenses/by-sa/3.0/
*/
var testdata = require('../data/BrainFuck.json');
describe("BrainFuck", function() {
this.timeout(0);
before(function(done) {
EmbarkSpec.deployAll({"BrainFuck": {}}, () => { done() });
});
testdata.vectors.forEach(function(v, i) {
it("Passes test vector " + i, async function() {
var result = await BrainFuck.methods.execute(web3.utils.asciiToHex(v.input[0]), v.input[1]).call({gas: v.gas});
assert.deepEqual(result || "0x", v.output[0]);
});
});
after(async function() {
var totalGas = 0;
for(var v of testdata.vectors) {
totalGas += await BrainFuck.methods.execute(web3.utils.asciiToHex(v.input[0]), v.input[1]).estimateGas({gas: v.gas}) - 21000;
}
console.log("Total gas for Unique: " + totalGas);
});
});

32
test/HexDecoder.js Normal file
View File

@ -0,0 +1,32 @@
/**
* This file is part of the 1st Solidity Gas Golfing Contest.
*
* This work is licensed under Creative Commons Attribution ShareAlike 3.0.
* https://creativecommons.org/licenses/by-sa/3.0/
*/
var testdata = require('../data/HexDecoder.json');
describe("HexDecoder", function() {
this.timeout(0);
before(function(done) {
EmbarkSpec.deployAll({"HexDecoder": {}}, () => { done() });
});
testdata.vectors.forEach(function(v, i) {
it("Passes test vector " + i, async function() {
var result = await HexDecoder.methods.decode(v.input[0]).call({gas: v.gas});
assert.deepEqual(result || '0x', v.output[0]);
});
});
after(async function() {
var totalGas = 0;
for(var v of testdata.vectors) {
totalGas += await HexDecoder.methods.decode(v.input[0]).estimateGas({gas: v.gas}) - 21000;
}
console.log("Total gas for Unique: " + totalGas);
});
});

33
test/IndexOf.js Normal file
View File

@ -0,0 +1,33 @@
/**
* This file is part of the 1st Solidity Gas Golfing Contest.
*
* This work is licensed under Creative Commons Attribution ShareAlike 3.0.
* https://creativecommons.org/licenses/by-sa/3.0/
*/
var testdata = require('../data/IndexOf.json');
describe("IndexOf", function() {
this.timeout(0);
before(function(done) {
EmbarkSpec.deployAll({"IndexOf": {}}, () => { done() });
});
testdata.vectors.forEach(function(v, i) {
it("Passes test vector " + i, async function() {
var result = await IndexOf.methods.indexOf(v.input[0], v.input[1]).call({gas: v.gas});
assert.deepEqual(result, v.output[0]);
});
});
after(async function() {
var totalGas = 0;
for(var v of testdata.vectors) {
totalGas += await IndexOf.methods.indexOf(v.input[0], v.input[1]).estimateGas({gas: v.gas}) - 21000;
}
console.log("Total gas for Unique: " + totalGas);
});
});

32
test/Sort.js Normal file
View File

@ -0,0 +1,32 @@
/**
* This file is part of the 1st Solidity Gas Golfing Contest.
*
* This work is licensed under Creative Commons Attribution ShareAlike 3.0.
* https://creativecommons.org/licenses/by-sa/3.0/
*/
var testdata = require('../data/Sort.json');
describe("Sort", function() {
this.timeout(0);
before(function(done) {
EmbarkSpec.deployAll({"Sort": {}}, () => { done() });
});
testdata.vectors.forEach(function(v, i) {
it("Passes test vector " + i, async function() {
var result = await Sort.methods.sort(v.input[0]).call({gas: v.gas});
assert.deepEqual(result, v.output[0]);
});
});
after(async function() {
var totalGas = 0;
for(var v of testdata.vectors) {
totalGas += await Sort.methods.sort(v.input[0]).estimateGas({gas: v.gas}) - 21000;
}
console.log("Total gas for Unique: " + totalGas);
});
});

32
test/Unique.js Normal file
View File

@ -0,0 +1,32 @@
/**
* This file is part of the 1st Solidity Gas Golfing Contest.
*
* This work is licensed under Creative Commons Attribution ShareAlike 3.0.
* https://creativecommons.org/licenses/by-sa/3.0/
*/
var testdata = require('../data/Unique.json');
describe("Unique", function() {
this.timeout(0);
before(function(done) {
EmbarkSpec.deployAll({"Unique": {}}, () => { done() });
});
testdata.vectors.forEach(function(v, i) {
it("Passes test vector " + i, async function() {
var result = await Unique.methods.uniquify(v.input[0]).call({gas: v.gas});
assert.deepEqual(result, v.output[0]);
});
});
after(async function() {
var totalGas = 0;
for(var v of testdata.vectors) {
totalGas += await Unique.methods.uniquify(v.input[0]).estimateGas({gas: v.gas}) - 21000;
}
console.log("Total gas for Unique: " + totalGas);
});
});