Changeset View
Changeset View
Standalone View
Standalone View
test/functional/wallet_txn_clone.py
Show All 25 Lines | def setup_network(self): | ||||
# Start with split network: | # Start with split network: | ||||
super(TxnMallTest, self).setup_network() | super(TxnMallTest, self).setup_network() | ||||
disconnect_nodes(self.nodes[1], self.nodes[2]) | disconnect_nodes(self.nodes[1], self.nodes[2]) | ||||
disconnect_nodes(self.nodes[2], self.nodes[1]) | disconnect_nodes(self.nodes[2], self.nodes[1]) | ||||
def run_test(self): | def run_test(self): | ||||
output_type = "legacy" | output_type = "legacy" | ||||
# All nodes should start with 1,250 BTC: | # All nodes should start with 1,250 BCH: | ||||
starting_balance = 1250 | starting_balance = 1250 | ||||
for i in range(4): | for i in range(4): | ||||
assert_equal(self.nodes[i].getbalance(), starting_balance) | assert_equal(self.nodes[i].getbalance(), starting_balance) | ||||
# bug workaround, coins generated assigned to first getnewaddress! | # bug workaround, coins generated assigned to first getnewaddress! | ||||
self.nodes[i].getnewaddress("") | self.nodes[i].getnewaddress("") | ||||
# Assign coins to foo and bar accounts: | # Assign coins to foo and bar accounts: | ||||
self.nodes[0].settxfee(.001) | self.nodes[0].settxfee(.001) | ||||
Show All 23 Lines | def run_test(self): | ||||
clone_outputs = {rawtx1["vout"][0]["scriptPubKey"]["addresses"][0]: rawtx1["vout"][0]["value"], | clone_outputs = {rawtx1["vout"][0]["scriptPubKey"]["addresses"][0]: rawtx1["vout"][0]["value"], | ||||
rawtx1["vout"][1]["scriptPubKey"]["addresses"][0]: rawtx1["vout"][1]["value"]} | rawtx1["vout"][1]["scriptPubKey"]["addresses"][0]: rawtx1["vout"][1]["value"]} | ||||
clone_locktime = rawtx1["locktime"] | clone_locktime = rawtx1["locktime"] | ||||
clone_raw = self.nodes[0].createrawtransaction( | clone_raw = self.nodes[0].createrawtransaction( | ||||
clone_inputs, clone_outputs, clone_locktime) | clone_inputs, clone_outputs, clone_locktime) | ||||
# createrawtransaction randomizes the order of its outputs, so swap them if necessary. | # createrawtransaction randomizes the order of its outputs, so swap them if necessary. | ||||
# output 0 is at version+#inputs+input+sigstub+sequence+#outputs | # output 0 is at version+#inputs+input+sigstub+sequence+#outputs | ||||
# 40 BTC serialized is 00286bee00000000 | # 40 BCH serialized is 00286bee00000000 | ||||
pos0 = 2 * (4 + 1 + 36 + 1 + 4 + 1) | pos0 = 2 * (4 + 1 + 36 + 1 + 4 + 1) | ||||
hex40 = "00286bee00000000" | hex40 = "00286bee00000000" | ||||
output_len = 16 + 2 + 2 * \ | output_len = 16 + 2 + 2 * \ | ||||
int("0x" + clone_raw[pos0 + 16: pos0 + 16 + 2], 0) | int("0x" + clone_raw[pos0 + 16: pos0 + 16 + 2], 0) | ||||
if (rawtx1["vout"][0]["value"] == 40 and clone_raw[pos0: pos0 + 16] != hex40 or | if (rawtx1["vout"][0]["value"] == 40 and clone_raw[pos0: pos0 + 16] != hex40 or | ||||
rawtx1["vout"][0]["value"] != 40 and clone_raw[pos0: pos0 + 16] == hex40): | rawtx1["vout"][0]["value"] != 40 and clone_raw[pos0: pos0 + 16] == hex40): | ||||
output0 = clone_raw[pos0: pos0 + output_len] | output0 = clone_raw[pos0: pos0 + output_len] | ||||
output1 = clone_raw[pos0 + output_len: pos0 + 2 * output_len] | output1 = clone_raw[pos0 + output_len: pos0 + 2 * output_len] | ||||
▲ Show 20 Lines • Show All 58 Lines • ▼ Show 20 Lines | def run_test(self): | ||||
tx1_clone = self.nodes[0].gettransaction(txid1_clone) | tx1_clone = self.nodes[0].gettransaction(txid1_clone) | ||||
tx2 = self.nodes[0].gettransaction(txid2) | tx2 = self.nodes[0].gettransaction(txid2) | ||||
# Verify expected confirmations | # Verify expected confirmations | ||||
assert_equal(tx1["confirmations"], -2) | assert_equal(tx1["confirmations"], -2) | ||||
assert_equal(tx1_clone["confirmations"], 2) | assert_equal(tx1_clone["confirmations"], 2) | ||||
assert_equal(tx2["confirmations"], 1) | assert_equal(tx2["confirmations"], 1) | ||||
# Check node0's total balance; should be same as before the clone, + 100 BTC for 2 matured, | # Check node0's total balance; should be same as before the clone, + 100 BCH for 2 matured, | ||||
# less possible orphaned matured subsidy | # less possible orphaned matured subsidy | ||||
expected += 100 | expected += 100 | ||||
if (self.options.mine_block): | if (self.options.mine_block): | ||||
expected -= 50 | expected -= 50 | ||||
assert_equal(self.nodes[0].getbalance(), expected) | assert_equal(self.nodes[0].getbalance(), expected) | ||||
assert_equal(self.nodes[0].getbalance("*", 0), expected) | assert_equal(self.nodes[0].getbalance("*", 0), expected) | ||||
# Check node0's individual account balances. | # Check node0's individual account balances. | ||||
Show All 21 Lines |