qa: Add RPC tests for weight in mempool entry
This commit is contained in:
parent
54aaa7883c
commit
9c9cc2bd20
1 changed files with 22 additions and 1 deletions
|
@ -226,6 +226,16 @@ class SegWitTest(BitcoinTestFramework):
|
||||||
assert tx.wit.is_null() # This should not be a segwit input
|
assert tx.wit.is_null() # This should not be a segwit input
|
||||||
assert txid1 in self.nodes[0].getrawmempool()
|
assert txid1 in self.nodes[0].getrawmempool()
|
||||||
|
|
||||||
|
tx1_hex = self.nodes[0].gettransaction(txid1)['hex']
|
||||||
|
tx1 = FromHex(CTransaction(), tx1_hex)
|
||||||
|
|
||||||
|
# Check that wtxid is properly reported in mempool entry (txid1)
|
||||||
|
assert_equal(int(self.nodes[0].getmempoolentry(txid1)["wtxid"], 16), tx1.calc_sha256(True))
|
||||||
|
|
||||||
|
# Check that weight and vsize are properly reported in mempool entry (txid1)
|
||||||
|
assert_equal(self.nodes[0].getmempoolentry(txid1)["vsize"], (self.nodes[0].getmempoolentry(txid1)["weight"] + 3) // 4)
|
||||||
|
assert_equal(self.nodes[0].getmempoolentry(txid1)["weight"], len(tx1.serialize_without_witness())*3 + len(tx1.serialize_with_witness()))
|
||||||
|
|
||||||
# Now create tx2, which will spend from txid1.
|
# Now create tx2, which will spend from txid1.
|
||||||
tx = CTransaction()
|
tx = CTransaction()
|
||||||
tx.vin.append(CTxIn(COutPoint(int(txid1, 16), 0), b''))
|
tx.vin.append(CTxIn(COutPoint(int(txid1, 16), 0), b''))
|
||||||
|
@ -235,6 +245,13 @@ class SegWitTest(BitcoinTestFramework):
|
||||||
tx = FromHex(CTransaction(), tx2_hex)
|
tx = FromHex(CTransaction(), tx2_hex)
|
||||||
assert not tx.wit.is_null()
|
assert not tx.wit.is_null()
|
||||||
|
|
||||||
|
# Check that wtxid is properly reported in mempool entry (txid2)
|
||||||
|
assert_equal(int(self.nodes[0].getmempoolentry(txid2)["wtxid"], 16), tx.calc_sha256(True))
|
||||||
|
|
||||||
|
# Check that weight and vsize are properly reported in mempool entry (txid2)
|
||||||
|
assert_equal(self.nodes[0].getmempoolentry(txid2)["vsize"], (self.nodes[0].getmempoolentry(txid2)["weight"] + 3) // 4)
|
||||||
|
assert_equal(self.nodes[0].getmempoolentry(txid2)["weight"], len(tx.serialize_without_witness())*3 + len(tx.serialize_with_witness()))
|
||||||
|
|
||||||
# Now create tx3, which will spend from txid2
|
# Now create tx3, which will spend from txid2
|
||||||
tx = CTransaction()
|
tx = CTransaction()
|
||||||
tx.vin.append(CTxIn(COutPoint(int(txid2, 16), 0), b""))
|
tx.vin.append(CTxIn(COutPoint(int(txid2, 16), 0), b""))
|
||||||
|
@ -251,9 +268,13 @@ class SegWitTest(BitcoinTestFramework):
|
||||||
assert txid2 in template_txids
|
assert txid2 in template_txids
|
||||||
assert txid3 in template_txids
|
assert txid3 in template_txids
|
||||||
|
|
||||||
# Check that wtxid is properly reported in mempool entry
|
# Check that wtxid is properly reported in mempool entry (txid3)
|
||||||
assert_equal(int(self.nodes[0].getmempoolentry(txid3)["wtxid"], 16), tx.calc_sha256(True))
|
assert_equal(int(self.nodes[0].getmempoolentry(txid3)["wtxid"], 16), tx.calc_sha256(True))
|
||||||
|
|
||||||
|
# Check that weight and vsize are properly reported in mempool entry (txid3)
|
||||||
|
assert_equal(self.nodes[0].getmempoolentry(txid3)["vsize"], (self.nodes[0].getmempoolentry(txid3)["weight"] + 3) // 4)
|
||||||
|
assert_equal(self.nodes[0].getmempoolentry(txid3)["weight"], len(tx.serialize_without_witness())*3 + len(tx.serialize_with_witness()))
|
||||||
|
|
||||||
# Mine a block to clear the gbt cache again.
|
# Mine a block to clear the gbt cache again.
|
||||||
self.nodes[0].generate(1)
|
self.nodes[0].generate(1)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue