Fabcoin Core  0.16.2
P2P Digital Currency
StateUnitTests.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 */
19 
21 #include <libethereum/BlockChain.h>
22 #include <libethereum/Block.h>
24 #include <libethereum/Defaults.h>
25 
26 using namespace std;
27 using namespace dev;
28 using namespace dev::eth;
29 
30 namespace dev
31 {
32 namespace test
33 {
34 
35 BOOST_FIXTURE_TEST_SUITE(StateUnitTests, TestOutputHelper)
36 
38 {
39  Block s(Block::Null);
40 }
41 
42 BOOST_AUTO_TEST_CASE(LoadAccountCode)
43 {
44  Address addr{"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"};
45  State s{0};
46  s.createContract(addr);
47  uint8_t codeData[] = {'c', 'o', 'd', 'e'};
48  s.setNewCode(addr, {std::begin(codeData), std::end(codeData)});
49  s.commit(State::CommitBehaviour::RemoveEmptyAccounts);
50 
51  auto& loadedCode = s.code(addr);
52  BOOST_CHECK(std::equal(
53  std::begin(codeData), std::end(codeData), std::begin(loadedCode)
54  ));
55 }
56 
58 
59 }
60 }
Adapted from code found on http://stackoverflow.com/questions/180947/base64-decode-snippet-in-c Origi...
Definition: Arith256.cpp:15
std::hash for asio::adress
Definition: Common.h:323
Model of an Ethereum state, essentially a facade for the trie.
Definition: State.h:161
BOOST_AUTO_TEST_CASE(LoadAccountCode)
Active model of a block within the block chain.
Definition: Block.h:73
void createContract(Address const &_address)
Create a contract at the given address (with unset code and unchanged balance).
Definition: State.cpp:325
Fixed-size raw-byte array container type, with an API optimised for storing hashes.
Definition: FixedHash.h:47
#define BOOST_FIXTURE_TEST_SUITE(a, b)
Definition: object.cpp:14
#define BOOST_AUTO_TEST_SUITE_END()
Definition: object.cpp:16
Helper functions to work with json::spirit and test files.
#define BOOST_CHECK(expr)
Definition: object.cpp:17