aboutsummaryrefslogtreecommitdiffstats
path: root/crypto.cpp
diff options
context:
space:
mode:
authorCarl Allendorph <callendorph@gmail.com>2014-04-20 01:53:48 +0800
committerCarl Allendorph <callendorph@gmail.com>2014-04-20 01:53:48 +0800
commitbf4865adaf6a5a739fff4c5c267b16ac3cfa6eb2 (patch)
tree276fbda20bd668c6eef2b2b79a8427863b6d2b06 /crypto.cpp
parentb8ce26d9f9d0a079ccfdb39f2e225b63dbe5f10a (diff)
downloaddexon-solidity-bf4865adaf6a5a739fff4c5c267b16ac3cfa6eb2.tar
dexon-solidity-bf4865adaf6a5a739fff4c5c267b16ac3cfa6eb2.tar.gz
dexon-solidity-bf4865adaf6a5a739fff4c5c267b16ac3cfa6eb2.tar.bz2
dexon-solidity-bf4865adaf6a5a739fff4c5c267b16ac3cfa6eb2.tar.lz
dexon-solidity-bf4865adaf6a5a739fff4c5c267b16ac3cfa6eb2.tar.xz
dexon-solidity-bf4865adaf6a5a739fff4c5c267b16ac3cfa6eb2.tar.zst
dexon-solidity-bf4865adaf6a5a739fff4c5c267b16ac3cfa6eb2.zip
Broke the crypto test out into a separate boost auto test case.
Diffstat (limited to 'crypto.cpp')
-rw-r--r--crypto.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/crypto.cpp b/crypto.cpp
index 7896a0b1..5dac1fce 100644
--- a/crypto.cpp
+++ b/crypto.cpp
@@ -26,9 +26,38 @@
#include <RLP.h>
#include <Log.h>
#include <Transaction.h>
+#include <boost/test/unit_test.hpp>
+
using namespace std;
using namespace eth;
+
+BOOST_AUTO_TEST_CASE(crypto_tests)
+{
+ cnote << "Testing Crypto...";
+ secp256k1_start();
+
+ KeyPair p(Secret(fromHex("3ecb44df2159c26e0f995712d4f39b6f6e499b40749b1cf1246c37f9516cb6a4")));
+ BOOST_REQUIRE(p.pub() == Public(fromHex("97466f2b32bc3bb76d4741ae51cd1d8578b48d3f1e68da206d47321aec267ce78549b514e4453d74ef11b0cd5e4e4c364effddac8b51bcfc8de80682f952896f")));
+ BOOST_REQUIRE(p.address() == Address(fromHex("8a40bfaa73256b60764c1bf40675a99083efb075")));
+ {
+ Transaction t;
+ t.nonce = 0;
+ t.receiveAddress = h160(fromHex("944400f4b88ac9589a0f17ed4671da26bddb668b"));
+ t.value = 1000;
+ cnote << RLP(t.rlp(false));
+ cnote << toHex(t.rlp(false));
+ cnote << t.sha3(false);
+ t.sign(p.secret());
+ cnote << RLP(t.rlp(true));
+ cnote << toHex(t.rlp(true));
+ cnote << t.sha3(true);
+ BOOST_REQUIRE(t.sender() == p.address());
+ }
+
+}
+
+
int cryptoTest()
{
cnote << "Testing Crypto...";