Fabcoin Core
0.16.2
P2P Digital Currency
Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
src
cpp-ethereum
test
libethereum
BlockQueue.cpp
Go to the documentation of this file.
1
/*
2
This file is part of cpp-ethereum.
3
4
cpp-ethereum is free software: you can redistribute it and/or modify
5
it under the terms of the GNU General Public License as published by
6
the Free Software Foundation, either version 3 of the License, or
7
(at your option) any later version.
8
9
cpp-ethereum is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
GNU General Public License for more details.
13
14
You should have received a copy of the GNU General Public License
15
along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
16
*/
23
#include <
libethereum/BlockQueue.h
>
24
#include <
test/libtesteth/TestHelper.h
>
25
#include <
test/libtesteth/BlockChainHelper.h
>
26
#include <
test/libtesteth/JsonSpiritHeaders.h
>
27
28
using namespace
std
;
29
using namespace
dev
;
30
using namespace
dev::eth
;
31
using namespace
dev::test
;
32
33
//BOOST_FIXTURE_TEST_SUITE(BlockQueueSuite, TestOutputHelper)
34
35
//BOOST_AUTO_TEST_CASE(BlockQueueImport)
36
//{
37
// TestBlock genesisBlock = TestBlockChain::defaultGenesisBlock();
38
// TestBlockChain blockchain(genesisBlock);
39
// TestBlockChain blockchain2(genesisBlock);
40
41
// TestBlock block1;
42
// TestTransaction transaction1 = TestTransaction::defaultTransaction(1);
43
// block1.addTransaction(transaction1);
44
// block1.mine(blockchain);
45
46
// BlockQueue blockQueue;
47
// blockQueue.setChain(blockchain.interface());
48
// ImportResult res = blockQueue.import(&block1.bytes());
49
// BOOST_REQUIRE_MESSAGE(res == ImportResult::Success, "Simple block import to BlockQueue should have return Success");
50
51
// res = blockQueue.import(&block1.bytes());
52
// BOOST_REQUIRE_MESSAGE(res == ImportResult::AlreadyKnown, "Simple block import to BlockQueue should have return AlreadyKnown");
53
54
// blockQueue.clear();
55
// blockchain.addBlock(block1);
56
// res = blockQueue.import(&block1.bytes());
57
// BOOST_REQUIRE_MESSAGE(res == ImportResult::AlreadyInChain, "Simple block import to BlockQueue should have return AlreadyInChain");
58
59
// TestBlock block2;
60
// block2.mine(blockchain);
61
// BlockHeader block2Header = block2.blockHeader();
62
// block2Header.setTimestamp(block2Header.timestamp() + 100);
63
// block2.setBlockHeader(block2Header);
64
// block2.updateNonce(blockchain);
65
// res = blockQueue.import(&block2.bytes());
66
// BOOST_REQUIRE_MESSAGE(res == ImportResult::FutureTimeKnown, "Simple block import to BlockQueue should have return FutureTimeKnown");
67
68
// TestBlock block3;
69
// block3.mine(blockchain);
70
// BlockHeader block3Header = block3.blockHeader();
71
// block3Header.clear();
72
// block3.setBlockHeader(block3Header);
73
// res = blockQueue.import(&block3.bytes());
74
// BOOST_REQUIRE_MESSAGE(res == ImportResult::Malformed, "Simple block import to BlockQueue should have return Malformed");
75
76
// TestBlock block4;
77
// block4.mine(blockchain2);
78
// blockchain2.addBlock(block4);
79
// TestBlock block5;
80
// block5.mine(blockchain2);
81
// BlockHeader block5Header = block5.blockHeader();
82
// block5Header.setTimestamp(block5Header.timestamp() + 100);
83
// block5.setBlockHeader(block5Header);
84
// block5.updateNonce(blockchain2);
85
// res = blockQueue.import(&block5.bytes());
86
// BOOST_REQUIRE_MESSAGE(res == ImportResult::FutureTimeUnknown, "Simple block import to BlockQueue should have return FutureTimeUnknown");
87
88
// blockQueue.clear();
89
// TestBlock block3a;
90
// block3a.mine(blockchain2);
91
// blockchain2.addBlock(block3a);
92
93
// TestBlock block3b;
94
// block3b.mine(blockchain2);
95
// BlockHeader block3bHeader = block3b.blockHeader();
96
// block3bHeader.setTimestamp(block3bHeader.timestamp() - 40);
97
// block3b.setBlockHeader(block3bHeader);
98
// block3b.updateNonce(blockchain2);
99
// res = blockQueue.import(&block3b.bytes());
100
// BOOST_REQUIRE_MESSAGE(res == ImportResult::UnknownParent, "Simple block import to BlockQueue should have return UnknownParent");
101
//}
102
103
//BOOST_AUTO_TEST_SUITE_END()
dev
Adapted from code found on http://stackoverflow.com/questions/180947/base64-decode-snippet-in-c Origi...
Definition:
Arith256.cpp:15
std
std::hash for asio::adress
Definition:
Common.h:323
dev::eth
Definition:
Arith256.cpp:17
BlockQueue.h
dev::test
Definition:
Block.h:43
BlockChainHelper.h
JsonSpiritHeaders.h
TestHelper.h
Helper functions to work with json::spirit and test files.
Generated on Mon Oct 22 2018 15:15:28 for Fabcoin Core by
1.8.11