Skip to content

Commit 843b6d7

Browse files
UdjinM6codablock
authored andcommitted
update p2p-autoinstantsend.py to test both "old" and "new" InstantSend
1 parent a8da11a commit 843b6d7

File tree

1 file changed

+29
-13
lines changed

1 file changed

+29
-13
lines changed

qa/rpc-tests/p2p-autoinstantsend.py

+29-13
Original file line numberDiff line numberDiff line change
@@ -89,13 +89,14 @@ def set_autoix_spork_state(self, state):
8989
self.nodes[0].spork('SPORK_16_INSTANTSEND_AUTOLOCKS', value)
9090

9191
# sends regular IX with high fee and may inputs (not-simple transaction)
92-
def send_regular_IX(self):
92+
def send_regular_IX(self, check_fee = True):
9393
receiver_addr = self.nodes[self.receiver_idx].getnewaddress()
9494
txid = self.nodes[0].instantsendtoaddress(receiver_addr, 1.0)
95-
MIN_FEE = satoshi_round(-0.0001)
96-
fee = self.nodes[0].gettransaction(txid)['fee']
97-
expected_fee = MIN_FEE * len(self.nodes[0].getrawtransaction(txid, True)['vin'])
98-
assert_equal(fee, expected_fee)
95+
if (check_fee):
96+
MIN_FEE = satoshi_round(-0.0001)
97+
fee = self.nodes[0].gettransaction(txid)['fee']
98+
expected_fee = MIN_FEE * len(self.nodes[0].getrawtransaction(txid, True)['vin'])
99+
assert_equal(fee, expected_fee)
99100
return self.wait_for_instantlock(txid, self.nodes[0])
100101

101102
# sends simple trx, it should become IX if autolocks are allowed
@@ -115,6 +116,21 @@ def send_complex_tx(self):
115116
def run_test(self):
116117
# make sure masternodes are synced
117118
sync_masternodes(self.nodes)
119+
120+
self.nodes[0].spork("SPORK_17_QUORUM_DKG_ENABLED", 0)
121+
self.wait_for_sporks_same()
122+
self.mine_quorum()
123+
124+
print("Test old InstantSend")
125+
self.test_auto();
126+
127+
self.nodes[0].spork("SPORK_2_INSTANTSEND_ENABLED", 1)
128+
self.wait_for_sporks_same()
129+
130+
print("Test new InstantSend")
131+
self.test_auto(True);
132+
133+
def test_auto(self, new_is = False):
118134
# feed the sender with some balance
119135
sender_addr = self.nodes[self.sender_idx].getnewaddress()
120136
self.nodes[0].sendtoaddress(sender_addr, 1)
@@ -126,26 +142,26 @@ def run_test(self):
126142

127143
assert(not self.get_autoix_spork_state())
128144

129-
assert(self.send_regular_IX())
130-
assert(not self.send_simple_tx())
131-
assert(not self.send_complex_tx())
145+
assert(self.send_regular_IX(not new_is))
146+
assert(self.send_simple_tx() if new_is else not self.send_simple_tx())
147+
assert(self.send_complex_tx() if new_is else not self.send_complex_tx())
132148

133149
self.activate_autoix_bip9()
134150
self.set_autoix_spork_state(True)
135151

136152
assert(self.get_autoix_bip9_status() == 'active')
137153
assert(self.get_autoix_spork_state())
138154

139-
assert(self.send_regular_IX())
155+
assert(self.send_regular_IX(not new_is))
140156
assert(self.send_simple_tx())
141-
assert(not self.send_complex_tx())
157+
assert(self.send_complex_tx() if new_is else not self.send_complex_tx())
142158

143159
self.set_autoix_spork_state(False)
144160
assert(not self.get_autoix_spork_state())
145161

146-
assert(self.send_regular_IX())
147-
assert(not self.send_simple_tx())
148-
assert(not self.send_complex_tx())
162+
assert(self.send_regular_IX(not new_is))
163+
assert(self.send_simple_tx() if new_is else not self.send_simple_tx())
164+
assert(self.send_complex_tx() if new_is else not self.send_complex_tx())
149165

150166

151167
if __name__ == '__main__':

0 commit comments

Comments
 (0)