| 1 | #!/usr/bin/env python3 |
| 2 | |
| 3 | # Copyright (c) 2018-2022, The Monero Project |
| 4 | |
| 5 | # |
| 6 | # All rights reserved. |
| 7 | # |
| 8 | # Redistribution and use in source and binary forms, with or without modification, are |
| 9 | # permitted provided that the following conditions are met: |
| 10 | # |
| 11 | # 1. Redistributions of source code must retain the above copyright notice, this list of |
| 12 | # conditions and the following disclaimer. |
| 13 | # |
| 14 | # 2. Redistributions in binary form must reproduce the above copyright notice, this list |
| 15 | # of conditions and the following disclaimer in the documentation and/or other |
| 16 | # materials provided with the distribution. |
| 17 | # |
| 18 | # 3. Neither the name of the copyright holder nor the names of its contributors may be |
| 19 | # used to endorse or promote products derived from this software without specific |
| 20 | # prior written permission. |
| 21 | # |
| 22 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY |
| 23 | # EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
| 24 | # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL |
| 25 | # THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 26 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 27 | # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 28 | # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
| 29 | # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF |
| 30 | # THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 31 | |
| 32 | """Test daemon RPC calls |
| 33 | |
| 34 | Test the following RPCs: |
| 35 | - get_info |
| 36 | - hard_fork_info |
| 37 | |
| 38 | """ |
| 39 | |
| 40 | from __future__ import print_function |
| 41 | import os |
| 42 | from framework.daemon import Daemon |
| 43 | |
| 44 | class DaemonGetInfoTest(): |
| 45 | def run_test(self): |
| 46 | self._test_hardfork_info() |
| 47 | self._test_get_info() |
| 48 | |
| 49 | def _test_hardfork_info(self): |
| 50 | print('Test hard_fork_info') |
| 51 | |
| 52 | daemon = Daemon() |
| 53 | res = daemon.hard_fork_info() |
| 54 | |
| 55 | # hard_fork version should be set at height 1 |
| 56 | assert 'earliest_height' in res.keys() |
| 57 | #assert res['earliest_height'] == 1; |
| 58 | assert res.earliest_height == 1 |
| 59 | |
| 60 | def _test_get_info(self): |
| 61 | print('Test get_info') |
| 62 | |
| 63 | daemon = Daemon() |
| 64 | res = daemon.get_info() |
| 65 | |
| 66 | # difficulty should be set to 1 for this test |
| 67 | assert 'difficulty' in res.keys() |
| 68 | assert res.difficulty == int(os.environ['DIFFICULTY']) |
| 69 | |
| 70 | # nettype should not be TESTNET |
| 71 | assert 'testnet' in res.keys() |
| 72 | assert res.testnet == False; |
| 73 | |
| 74 | # nettype should not be STAGENET |
| 75 | assert 'stagenet' in res.keys() |
| 76 | assert res.stagenet == False; |
| 77 | |
| 78 | # nettype should be FAKECHAIN |
| 79 | assert 'nettype' in res.keys() |
| 80 | assert res.nettype == "fakechain"; |
| 81 | |
| 82 | # free_space should be > 0 |
| 83 | assert 'free_space' in res.keys() |
| 84 | assert res.free_space > 0 |
| 85 | |
| 86 | # height should be greater or equal to 1 |
| 87 | assert 'height' in res.keys() |
| 88 | assert res.height >= 1 |
| 89 | |
| 90 | |
| 91 | if __name__ == '__main__': |
| 92 | DaemonGetInfoTest().run_test() |