functional_tests: add submitblock test

This commit is contained in:
moneromooo-monero 2019-05-03 17:18:15 +00:00
parent 121c1b9475
commit c148002534
No known key found for this signature in database
GPG key ID: 686F07454D6CEFC3

View file

@ -48,6 +48,7 @@ class MiningTest():
self.create() self.create()
self.mine(True) self.mine(True)
self.mine(False) self.mine(False)
self.submitblock()
def reset(self): def reset(self):
print('Resetting blockchain') print('Resetting blockchain')
@ -140,6 +141,33 @@ class MiningTest():
res_status = daemon.mining_status() res_status = daemon.mining_status()
assert res_status.active == False 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__': if __name__ == '__main__':
MiningTest().run_test() MiningTest().run_test()