yann300
10 years ago
10 changed files with 194 additions and 25 deletions
@ -0,0 +1,63 @@ |
|||
#!/bin/bash |
|||
|
|||
CPP_ETHEREUM_PATH=$(pwd) |
|||
BUILD_DIR=$CPP_ETHEREUM_PATH/build |
|||
TEST_MODE="" |
|||
|
|||
for i in "$@" |
|||
do |
|||
case $i in |
|||
-builddir) |
|||
shift |
|||
((i++)) |
|||
BUILD_DIR=${!i} |
|||
shift |
|||
;; |
|||
--all) |
|||
TEST_MODE="--all" |
|||
shift |
|||
;; |
|||
esac |
|||
done |
|||
|
|||
which $BUILD_DIR/test/testeth >/dev/null 2>&1 |
|||
if [ $? != 0 ] |
|||
then |
|||
echo "You need to compile and build ethereum with cmake -DPROFILING option to the build dir!" |
|||
exit; |
|||
fi |
|||
|
|||
OUTPUT_DIR=$BUILD_DIR/test/coverage |
|||
if which lcov >/dev/null; then |
|||
if which genhtml >/dev/null; then |
|||
echo Cleaning previous report... |
|||
if [ -d "$OUTPUT_DIR" ]; then |
|||
rm -r $OUTPUT_DIR |
|||
fi |
|||
mkdir $OUTPUT_DIR |
|||
lcov --directory $BUILD_DIR --zerocounters |
|||
lcov --capture --initial --directory $BUILD_DIR --output-file $OUTPUT_DIR/coverage_base.info |
|||
|
|||
echo Running testeth... |
|||
$CPP_ETHEREUM_PATH/build/test/testeth $TEST_MODE |
|||
$CPP_ETHEREUM_PATH/build/test/testeth -t StateTests --jit $TEST_MODE |
|||
$CPP_ETHEREUM_PATH/build/test/testeth -t VMTests --jit $TEST_MODE |
|||
|
|||
echo Prepearing coverage info... |
|||
lcov --capture --directory $BUILD_DIR --output-file $OUTPUT_DIR/coverage_test.info |
|||
lcov --add-tracefile $OUTPUT_DIR/coverage_base.info --add-tracefile $OUTPUT_DIR/coverage_test.info --output-file $OUTPUT_DIR/coverage_all.info |
|||
lcov --extract $OUTPUT_DIR/coverage_all.info *cpp-ethereum/* --output-file $OUTPUT_DIR/coverage_export.info |
|||
genhtml $OUTPUT_DIR/coverage_export.info --output-directory $OUTPUT_DIR/testeth |
|||
else |
|||
echo genhtml not found |
|||
exit; |
|||
fi |
|||
else |
|||
echo lcov not found |
|||
exit; |
|||
fi |
|||
|
|||
echo "Coverage info should be located at: $OUTPUT_DIR/testeth" |
|||
echo "Opening index..." |
|||
|
|||
xdg-open $OUTPUT_DIR/testeth/index.html & |
@ -0,0 +1,92 @@ |
|||
/*
|
|||
This file is part of cpp-ethereum. |
|||
|
|||
cpp-ethereum is free software: you can redistribute it and/or modify |
|||
it under the terms of the GNU General Public License as published by |
|||
the Free Software Foundation, either version 3 of the License, or |
|||
(at your option) any later version. |
|||
|
|||
cpp-ethereum is distributed in the hope that it will be useful, |
|||
but WITHOUT ANY WARRANTY; without even the implied warranty of |
|||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|||
GNU General Public License for more details. |
|||
|
|||
You should have received a copy of the GNU General Public License |
|||
along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
|
|||
*/ |
|||
/** @file AES.cpp
|
|||
* @author Christoph Jentzsch <cj@ethdev.com> |
|||
* @date 2015 |
|||
*/ |
|||
|
|||
#include <boost/test/unit_test.hpp> |
|||
#include <libdevcore/Common.h> |
|||
#include <libdevcrypto/Common.h> |
|||
#include <libdevcore/SHA3.h> |
|||
#include <libdevcrypto/AES.h> |
|||
#include <libdevcore/FixedHash.h> |
|||
|
|||
using namespace std; |
|||
using namespace dev; |
|||
|
|||
BOOST_AUTO_TEST_SUITE(AES) |
|||
|
|||
BOOST_AUTO_TEST_CASE(AesDecrypt) |
|||
{ |
|||
cout << "AesDecrypt" << endl; |
|||
bytes seed = fromHex("2dbaead416c20cfd00c2fc9f1788ff9f965a2000799c96a624767cb0e1e90d2d7191efdd92349226742fdc73d1d87e2d597536c4641098b9a89836c94f58a2ab4c525c27c4cb848b3e22ea245b2bc5c8c7beaa900b0c479253fc96fce7ffc621"); |
|||
KeyPair kp(sha3(aesDecrypt(&seed, "test"))); |
|||
BOOST_CHECK(Address("07746f871de684297923f933279555dda418f8a2") == kp.address()); |
|||
} |
|||
|
|||
BOOST_AUTO_TEST_CASE(AesDecryptWrongSeed) |
|||
{ |
|||
cout << "AesDecryptWrongSeed" << endl; |
|||
bytes seed = fromHex("badaead416c20cfd00c2fc9f1788ff9f965a2000799c96a624767cb0e1e90d2d7191efdd92349226742fdc73d1d87e2d597536c4641098b9a89836c94f58a2ab4c525c27c4cb848b3e22ea245b2bc5c8c7beaa900b0c479253fc96fce7ffc621"); |
|||
KeyPair kp(sha3(aesDecrypt(&seed, "test"))); |
|||
BOOST_CHECK(Address("07746f871de684297923f933279555dda418f8a2") != kp.address()); |
|||
} |
|||
|
|||
BOOST_AUTO_TEST_CASE(AesDecryptWrongPassword) |
|||
{ |
|||
cout << "AesDecryptWrongPassword" << endl; |
|||
bytes seed = fromHex("2dbaead416c20cfd00c2fc9f1788ff9f965a2000799c96a624767cb0e1e90d2d7191efdd92349226742fdc73d1d87e2d597536c4641098b9a89836c94f58a2ab4c525c27c4cb848b3e22ea245b2bc5c8c7beaa900b0c479253fc96fce7ffc621"); |
|||
KeyPair kp(sha3(aesDecrypt(&seed, "badtest"))); |
|||
BOOST_CHECK(Address("07746f871de684297923f933279555dda418f8a2") != kp.address()); |
|||
} |
|||
|
|||
BOOST_AUTO_TEST_CASE(AesDecryptFailInvalidSeed) |
|||
{ |
|||
cout << "AesDecryptFailInvalidSeed" << endl; |
|||
bytes seed = fromHex("xdbaead416c20cfd00c2fc9f1788ff9f965a2000799c96a624767cb0e1e90d2d7191efdd92349226742fdc73d1d87e2d597536c4641098b9a89836c94f58a2ab4c525c27c4cb848b3e22ea245b2bc5c8c7beaa900b0c479253fc96fce7ffc621"); |
|||
BOOST_CHECK(bytes() == aesDecrypt(&seed, "test")); |
|||
} |
|||
|
|||
BOOST_AUTO_TEST_CASE(AesDecryptFailInvalidSeedSize) |
|||
{ |
|||
cout << "AesDecryptFailInvalidSeedSize" << endl; |
|||
bytes seed = fromHex("000102030405060708090a0b0c0d0e0f"); |
|||
BOOST_CHECK(bytes() == aesDecrypt(&seed, "test")); |
|||
} |
|||
|
|||
BOOST_AUTO_TEST_CASE(AesDecryptFailInvalidSeed2) |
|||
{ |
|||
cout << "AesDecryptFailInvalidSeed2" << endl; |
|||
bytes seed = fromHex("000102030405060708090a0b0c0d0e0f000102030405060708090a0b0c0d0e0f"); |
|||
BOOST_CHECK(bytes() == aesDecrypt(&seed, "test")); |
|||
} |
|||
BOOST_AUTO_TEST_CASE(AuthenticatedStreamConstructor) |
|||
{ |
|||
cout << "AuthenticatedStreamConstructor" << endl; |
|||
|
|||
Secret const sec("test"); |
|||
crypto::aes::AuthenticatedStream as(crypto::aes::Encrypt, sec, 0); |
|||
BOOST_CHECK(as.getMacInterval() == 0); |
|||
as.adjustInterval(1); |
|||
BOOST_CHECK(as.getMacInterval() == 1); |
|||
crypto::aes::AuthenticatedStream as_mac(crypto::aes::Encrypt, h128(), h128(), 42); |
|||
BOOST_CHECK(as_mac.getMacInterval() == 42); |
|||
} |
|||
|
|||
BOOST_AUTO_TEST_SUITE_END() |
|||
|
Loading…
Reference in new issue