net: Fix sent reject messages for blocks and transactions

Ever since we #5913 have been sending invalid reject messages
for transactions and blocks.

test: Add basic test for `reject` code

Extend P2P test framework to make it possible to expect reject
codes for transactions and blocks.

Github-Pull: #7179
Rebased-From: 9fc6ed6003 20411903d7
This commit is contained in:
Wladimir J. van der Laan
2015-12-07 14:47:58 +01:00
parent 96e8d12033
commit 44fef99e66
5 changed files with 123 additions and 6 deletions

View File

@@ -6,7 +6,7 @@
from test_framework.test_framework import ComparisonTestFramework
from test_framework.util import *
from test_framework.comptool import TestManager, TestInstance
from test_framework.comptool import TestManager, TestInstance, RejectResult
from test_framework.mininode import *
from test_framework.blocktools import *
import logging
@@ -97,7 +97,7 @@ class InvalidBlockRequestTest(ComparisonTestFramework):
assert(block2_orig.vtx != block2.vtx)
self.tip = block2.sha256
yield TestInstance([[block2, False], [block2_orig, True]])
yield TestInstance([[block2, RejectResult(16,'bad-txns-duplicate')], [block2_orig, True]])
height += 1
'''
@@ -112,7 +112,7 @@ class InvalidBlockRequestTest(ComparisonTestFramework):
block3.rehash()
block3.solve()
yield TestInstance([[block3, False]])
yield TestInstance([[block3, RejectResult(16,'bad-cb-amount')]])
if __name__ == '__main__':