diff --git a/test/functional/bip68-sequence.py b/test/functional/bip68-sequence.py --- a/test/functional/bip68-sequence.py +++ b/test/functional/bip68-sequence.py @@ -224,13 +224,18 @@ tx1 = FromHex(CTransaction(), self.nodes[0].getrawtransaction(txid)) tx1.rehash() + # Clear the existing mempool into a block. + self.nodes[0].generate(1) + # Anyone-can-spend mempool tx. # Sequence lock of 0 should pass. tx2 = CTransaction() tx2.nVersion = 2 tx2.vin = [CTxIn(COutPoint(tx1.sha256, 0), nSequence=0)] tx2.vout = [ - CTxOut(int(tx1.vout[0].nValue - self.relayfee * COIN), CScript([b'a']))] + CTxOut(int(0), CScript([b'a']))] + tx2.vout[0].nValue = tx1.vout[0].nValue - \ + 2 * self.nodes[0].calculate_fee(tx2) tx2_raw = self.nodes[0].signrawtransaction(ToHex(tx2))["hex"] tx2 = FromHex(tx2, tx2_raw) tx2.rehash() @@ -250,7 +255,7 @@ tx.vin = [ CTxIn(COutPoint(orig_tx.sha256, 0), nSequence=sequence_value)] tx.vout = [ - CTxOut(int(orig_tx.vout[0].nValue - relayfee * COIN), CScript([b'a']))] + CTxOut(int(orig_tx.vout[0].nValue - 2 * self.nodes[0].calculate_fee(tx)), CScript([b'a']))] tx.rehash() if (orig_tx.hash in node.getrawmempool()): @@ -263,6 +268,8 @@ return tx + self.log.info("mempool size {}".format( + len(self.nodes[0].getrawmempool()))) test_nonzero_locks( tx2, self.nodes[0], self.relayfee, use_height_lock=True) test_nonzero_locks( @@ -271,7 +278,7 @@ # Now mine some blocks, but make sure tx2 doesn't get mined. # Use prioritisetransaction to lower the effective feerate to 0 self.nodes[0].prioritisetransaction( - tx2.hash, -1e15, int(-self.relayfee * COIN)) + tx2.hash, -1e15, -2 * self.nodes[0].calculate_fee(tx2)) cur_time = int(time.time()) for i in range(10): self.nodes[0].setmocktime(cur_time + 600) @@ -287,7 +294,7 @@ # Mine tx2, and then try again self.nodes[0].prioritisetransaction( - tx2.hash, 1e15, self.nodes[0].calculate_fee(tx2)) + tx2.hash, 1e15, 100 * self.nodes[0].calculate_fee(tx2)) # Advance the time on the node so that we can test timelocks self.nodes[0].setmocktime(cur_time + 600)