forked from mzoterov/ethash
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactored tests and introducing python
- Loading branch information
Showing
17 changed files
with
140 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,5 +2,8 @@ | |
.DS_Store | ||
*/**/*un~ | ||
.vagrant/ | ||
cpp-build/ | ||
go-build/ | ||
*.pyc | ||
build/ | ||
pyethash.egg-info/ | ||
*.so | ||
*~ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
clean: | ||
rm -rf *.so pyethash.egg-info/ build/ test/python/python-virtual-env/ test/c/build/ pythethash/core.so |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
pyethash.egg-info/ | ||
*.so |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#include <Python.h> | ||
#include "../libethash/ethash.h" | ||
|
||
static PyObject* | ||
get_params(PyObject* self, PyObject* args) | ||
{ | ||
unsigned long block_number; | ||
ethash_params p; | ||
|
||
if (!PyArg_ParseTuple(args, "k", &block_number)) | ||
Py_RETURN_NONE; | ||
|
||
ethash_params_init(&p, block_number); | ||
|
||
printf("\nBlock number: %lu\n", block_number); | ||
printf("DAG Size: %lu\n", p.full_size); | ||
printf("Cache Size: %lu\n", p.cache_size); | ||
|
||
return Py_BuildValue("{sisi}", | ||
"DAG Size", p.full_size, | ||
"Cache Size", p.cache_size); | ||
} | ||
|
||
static PyMethodDef CoreMethods[] = | ||
{ | ||
{"get_params", get_params, METH_VARARGS, "Gets the parameters for a given block"}, | ||
{NULL, NULL, 0, NULL} | ||
}; | ||
|
||
PyMODINIT_FUNC | ||
initcore(void) | ||
{ | ||
(void) Py_InitModule("core", CoreMethods); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[nosetests] | ||
verbosity=1 | ||
detailed-errors=1 | ||
with-coverage=1 | ||
cover-package=nose | ||
debug=nose.loader | ||
pdb=1 | ||
pdb-failures=1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/usr/bin/env python | ||
from distutils.core import setup, Extension | ||
|
||
pyethash_core = Extension('pyethash.core', | ||
sources = [ | ||
'python-src/core.c', | ||
'libethash/util.c', | ||
'libethash/internal.c', | ||
'libethash/sha3.c' | ||
]) | ||
|
||
setup (name = 'pyethash', | ||
version = '1.0', | ||
description = 'Python wrappers for ethash, the ethereum proof of work hashing function', | ||
ext_modules = [pyethash_core], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/bin/bash | ||
|
||
# Strict mode | ||
set -e | ||
|
||
SOURCE="${BASH_SOURCE[0]}" | ||
while [ -h "$SOURCE" ]; do | ||
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" | ||
SOURCE="$(readlink "$SOURCE")" | ||
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" | ||
done | ||
TEST_DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" | ||
|
||
rm -rf $TEST_DIR/build | ||
mkdir -p $TEST_DIR/build | ||
cd $TEST_DIR/build ; | ||
cmake ../../.. > /dev/null | ||
make Test | ||
./test/c/Test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
python-virtual-env/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
pyethereum==0.7.522 | ||
nose==1.3.4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/bin/bash -x | ||
|
||
# Strict mode | ||
set -e | ||
|
||
SOURCE="${BASH_SOURCE[0]}" | ||
while [ -h "$SOURCE" ]; do | ||
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" | ||
SOURCE="$(readlink "$SOURCE")" | ||
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" | ||
done | ||
TEST_DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" | ||
|
||
# rm -rf $TEST_DIR/python-virtual-env | ||
# virtualenv --system-site-packages $TEST_DIR/python-virtual-env > /dev/null | ||
source $TEST_DIR/python-virtual-env/bin/activate | ||
# pip install -r $TEST_DIR/requirements.txt > /dev/null | ||
pip install -e $TEST_DIR/../.. | ||
cd $TEST_DIR | ||
nosetests --with-doctest -v |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import pyethash.core | ||
|
||
def test_get_params(): | ||
block_num = 123456 | ||
out = pyethash.core.get_params(block_num) | ||
assert out != None | ||
|
||
if __name__ == '__main__': | ||
test_me() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,32 @@ | ||
#!/bin/bash -x | ||
#!/bin/bash | ||
|
||
SOURCE="${BASH_SOURCE[0]}" | ||
# Strict mode | ||
set -e | ||
|
||
SOURCE="${BASH_SOURCE[0]}" | ||
while [ -h "$SOURCE" ]; do | ||
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" | ||
SOURCE="$(readlink "$SOURCE")" | ||
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" | ||
done | ||
|
||
TEST_DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" | ||
|
||
echo "################# Testing CPP ##################" | ||
|
||
( rm -rf $TEST_DIR/../cpp-build ; | ||
mkdir -p $TEST_DIR/../cpp-build ; | ||
cd $TEST_DIR/../cpp-build ; | ||
cmake .. ; | ||
make Test ; | ||
test/Test ) | ||
echo -e "\n################# Testing JS ##################" | ||
# TODO: Use mocha and real testing tools instead of rolling our own | ||
cd $TEST_DIR/../libethash-js | ||
node test.js | ||
|
||
echo "################# Testing JS ##################" | ||
echo -e "\n################# Testing Python ##################" | ||
$TEST_DIR/python/test.sh | ||
|
||
( cd $TEST_DIR/../libethash-js ; | ||
./test.js ) | ||
echo -e "\n################# Testing C ##################" | ||
$TEST_DIR/c/test.sh | ||
|
||
#echo "################# Testing Go ##################" | ||
#( rm -rf $TEST_DIR/../go-build ; | ||
# export GOPATH=$TEST_DIR/../go-build ; | ||
# export PATH=$PATH:$GOPATH/bin ; | ||
# cd $TEST_DIR/go ; | ||
# go get -dv ; | ||
# go get -v github.com/ethereum/ethash ; | ||
#( rm -rf $TEST_DIR/../go-build | ||
# export GOPATH=$TEST_DIR/../go-build | ||
# export PATH=$PATH:$GOPATH/bin | ||
# cd $TEST_DIR/go | ||
# go get -dv | ||
# go get -v github.com/ethereum/ethash | ||
# go test ) |