diff options
-rwxr-xr-x | tests/functional_tests/mining.py | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/functional_tests/mining.py b/tests/functional_tests/mining.py index b8b9e0959..360f2763d 100755 --- a/tests/functional_tests/mining.py +++ b/tests/functional_tests/mining.py @@ -48,6 +48,7 @@ class MiningTest(): self.create() self.mine(True) self.mine(False) + self.submitblock() def reset(self): print('Resetting blockchain') @@ -140,6 +141,33 @@ class MiningTest(): res_status = daemon.mining_status() assert res_status.active == False + def submitblock(self): + print "Test submitblock" + + daemon = Daemon() + res = daemon.get_height() + height = res.height + res = daemon.generateblocks('42ey1afDFnn4886T7196doS9GPMzexD9gXpsZJDwVjeRVdFCSoHnv7KPbBeGpzJBzHRCAs9UxqeoyFQMYbqSWYTfJJQAWDm', 5) + assert len(res.blocks) == 5 + hashes = res.blocks + blocks = [] + for block_hash in hashes: + res = daemon.getblock(hash = block_hash) + assert len(res.blob) > 0 and len(res.blob) % 2 == 0 + blocks.append(res.blob) + res = daemon.get_height() + assert res.height == height + 5 + res = daemon.pop_blocks(5) + res = daemon.get_height() + assert res.height == height + for i in range(len(hashes)): + block_hash = hashes[i] + assert len(block_hash) == 64 + res = daemon.submitblock(blocks[i]) + res = daemon.get_height() + assert res.height == height + i + 1 + assert res.hash == block_hash + if __name__ == '__main__': MiningTest().run_test() |