ClientTest.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*
  2. This file is part of cpp-ethereum.
  3. cpp-ethereum is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation, either version 3 of the License, or
  6. (at your option) any later version.
  7. cpp-ethereum is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
  13. */
  14. /** @file ClientTest.h
  15. * @author Kholhlov Dimitry <dimitry@ethdev.com>
  16. * @date 2016
  17. */
  18. #pragma once
  19. #include <tuple>
  20. #include <libethereum/Client.h>
  21. namespace dev
  22. {
  23. namespace eth
  24. {
  25. DEV_SIMPLE_EXCEPTION(ChainParamsInvalid);
  26. DEV_SIMPLE_EXCEPTION(ChainParamsNotNoProof);
  27. class ClientTest: public Client
  28. {
  29. public:
  30. /// Trivial forwarding constructor.
  31. ClientTest(
  32. ChainParams const& _params,
  33. int _networkID,
  34. p2p::Host* _host,
  35. std::shared_ptr<GasPricer> _gpForAdoption,
  36. std::string const& _dbPath = std::string(),
  37. WithExisting _forceAction = WithExisting::Trust,
  38. TransactionQueue::Limits const& _l = TransactionQueue::Limits{1024, 1024}
  39. );
  40. void setChainParams(std::string const& _genesis);
  41. void mineBlocks(unsigned _count);
  42. void modifyTimestamp(u256 const& _timestamp);
  43. void rewindToBlock(unsigned _number);
  44. bool addBlock(std::string const& _rlp);
  45. protected:
  46. unsigned m_blocksToMine;
  47. virtual void onNewBlocks(h256s const& _blocks, h256Hash& io_changed) override;
  48. };
  49. ClientTest& asClientTest(Interface& _c);
  50. ClientTest* asClientTest(Interface* _c);
  51. }
  52. }