Skip to content

Commit 1e97313

Browse files
DuddinoFuzzbawls
authored andcommitted
Change exchange address functional tests
Github-Pull: #2908 Rebased-From: d7d30dc
1 parent 0a47505 commit 1e97313

File tree

1 file changed

+19
-15
lines changed

1 file changed

+19
-15
lines changed

test/functional/feature_exchangeaddr.py

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ def run_test(self):
4444
# Sign the transaction
4545
signed_tx = self.nodes[0].signrawtransaction(ToHex(tx))
4646

47-
# Send the raw transaction
4847
# Before the upgrade, this should fail if OP_EXCHANGEADDR is disallowed
4948
error_code = -26
5049
error_message = "scriptpubkey"
@@ -56,18 +55,22 @@ def run_test(self):
5655
# Attempt to send funds from transparent address to exchange address
5756
ex_addr_validation_result = self.nodes[0].validateaddress(ex_addr)
5857
assert_equal(ex_addr_validation_result['isvalid'], True)
59-
# This should fail to be sent
60-
error_code = -4
61-
error_message = "bad-exchange-address-not-started"
62-
assert_raises_rpc_error(
63-
error_code,
64-
error_message,
65-
self.nodes[0].sendtoaddress,
66-
ex_addr, 1.0
67-
)
58+
# This should succeed even before the upgrade
59+
self.nodes[0].sendtoaddress(ex_addr, 1.0)
6860

61+
# Check wallet version
62+
wallet_info = self.nodes[0].getwalletinfo()
63+
if wallet_info['walletversion'] >= FEATURE_PRE_SPLIT_KEYPOOL:
64+
sapling_addr = self.nodes[0].getnewshieldaddress()
65+
self.nodes[0].sendtoaddress(sapling_addr, 2.0)
66+
self.nodes[0].generate(1)
67+
sap_to_ex = [{"address": ex_addr, "amount": Decimal('1')}]
68+
# Shield data should be allowed before activation
69+
self.nodes[0].shieldsendmany(sapling_addr, sap_to_ex)
70+
else:
71+
self.nodes[0].generate(1)
6972
# Mine and activate exchange addresses
70-
self.nodes[0].generate(194)
73+
self.nodes[0].generate(193)
7174
assert_equal(self.nodes[0].getblockcount(), 1000)
7275
self.nodes[0].generate(1)
7376

@@ -83,8 +86,10 @@ def run_test(self):
8386

8487
# Verify balance
8588
node_bal = self.nodes[1].getbalance()
86-
assert_equal(node_bal, 2)
87-
89+
if wallet_info['walletversion'] >= FEATURE_PRE_SPLIT_KEYPOOL:
90+
assert_equal(node_bal, 4)
91+
else:
92+
assert_equal(node_bal, 3)
8893
# Attempt to send funds from exchange address back to transparent address
8994
tx2 = self.nodes[0].sendtoaddress(t_addr_2, 1.0)
9095
self.nodes[0].generate(6)
@@ -96,7 +101,6 @@ def run_test(self):
96101

97102
# Transparent to Shield to Exchange should fail
98103
# Check wallet version
99-
wallet_info = self.nodes[0].getwalletinfo()
100104
if wallet_info['walletversion'] < FEATURE_PRE_SPLIT_KEYPOOL:
101105
self.log.info("Pre-HD wallet version detected. Skipping Shield tests.")
102106
return
@@ -107,7 +111,7 @@ def run_test(self):
107111

108112
# Expect shieldsendmany to fail with bad-txns-invalid-sapling
109113
expected_error_code = -4
110-
expected_error_message = "Failed to accept tx in the memory pool (reason: bad-txns-invalid-sapling)"
114+
expected_error_message = "Failed to accept tx in the memory pool (reason: bad-txns-exchange-addr-has-sapling)"
111115
assert_raises_rpc_error(
112116
expected_error_code,
113117
expected_error_message,

0 commit comments

Comments
 (0)