mirror of
https://github.com/basicswap/basicswap.git
synced 2025-11-05 10:28:10 +01:00
All spend paths implemented, increasing test coverage, still some issues with refund spends and swipes to resolve
This commit is contained in:
@@ -2,10 +2,12 @@ import unittest
|
||||
|
||||
from basicswap.contrib.test_framework.script import CScript
|
||||
from basicswap.interface.bch import BCHInterface
|
||||
from basicswap.util import ensure
|
||||
|
||||
bch_lock_spend_tx = '0200000001bfc6bbb47851441c7827059ae337a06aa9064da7f9537eb9243e45766c3dd34c00000000d8473045022100a0161ea14d3b41ed41250c8474fc8ec6ce1cab8df7f401e69ecf77c2ab63d82102207a2a57ddf2ea400e09ea059f3b261da96f5098858b17239931f3cc2fb929bb2a4c8ec3519dc4519d02e80300c600cc949d00ce00d18800cf00d28800d000d39d00cb641976a91481ec21969399d15c26af089d5db437ead066c5ba88ac00cd788821024ffcc0481629866671d89f05f3da813a2aacec1b52e69b8c0c586b665f5d4574ba6752b27523aa20df65a90e9becc316ff5aca44d4e06dfaade56622f32bafa197aba706c5e589758700cd87680000000001251cde06000000001976a91481ec21969399d15c26af089d5db437ead066c5ba88ac00000000'
|
||||
bch_lock_script = 'c3519dc4519d02e80300c600cc949d00ce00d18800cf00d28800d000d39d00cb641976a91481ec21969399d15c26af089d5db437ead066c5ba88ac00cd788821024ffcc0481629866671d89f05f3da813a2aacec1b52e69b8c0c586b665f5d4574ba6752b27523aa20df65a90e9becc316ff5aca44d4e06dfaade56622f32bafa197aba706c5e589758700cd8768'
|
||||
bch_lock_spend_script = '473045022100a0161ea14d3b41ed41250c8474fc8ec6ce1cab8df7f401e69ecf77c2ab63d82102207a2a57ddf2ea400e09ea059f3b261da96f5098858b17239931f3cc2fb929bb2a4c8ec3519dc4519d02e80300c600cc949d00ce00d18800cf00d28800d000d39d00cb641976a91481ec21969399d15c26af089d5db437ead066c5ba88ac00cd788821024ffcc0481629866671d89f05f3da813a2aacec1b52e69b8c0c586b665f5d4574ba6752b27523aa20df65a90e9becc316ff5aca44d4e06dfaade56622f32bafa197aba706c5e589758700cd8768'
|
||||
bch_lock_swipe_script = '4c8fc3519dc4519d02e80300c600cc949d00ce00d18800cf00d28800d000d39d00cb641976a9141ab50aedd2e48297073f0f6eef46f97b37c9354e88ac00cd7888210234fe304a5b129b8265c177c92aa40b7840e8303f8b0fcca2359023163c7c2768ba670120b27523aa20191b09e40d1277fa14fea1e9b41e4fcc4528c9cb77e39e1b7b1a0b3332180cb78700cd8768'
|
||||
|
||||
coin_settings = {'rpcport': 0, 'rpcauth': 'none', 'blocks_confirmed': 1, 'conf_target': 1, 'use_segwit': False, 'connection_type': 'rpc'}
|
||||
|
||||
@@ -26,4 +28,8 @@ class TestXmrBchSwapInterface(unittest.TestCase):
|
||||
|
||||
script_bytes = CScript(bytes.fromhex(bch_lock_spend_script))
|
||||
signature, mining_fee, out_1, out_2, public_key, timelock = ci.extractScriptLockScriptValuesFromScriptSig(script_bytes)
|
||||
print(timelock)
|
||||
ensure(signature is not None, 'signature not present')
|
||||
|
||||
script_bytes = CScript(bytes.fromhex(bch_lock_swipe_script))
|
||||
signature, mining_fee, out_1, out_2, public_key, timelock = ci.extractScriptLockScriptValuesFromScriptSig(script_bytes)
|
||||
ensure(signature is None, 'signature present')
|
||||
|
||||
@@ -519,4 +519,36 @@ class TestBCH(BasicSwapTest):
|
||||
|
||||
def test_01_b_full_swap_reverse(self):
|
||||
self.prepare_balance(Coins.BCH, 100.0, 1801, 1800)
|
||||
super().test_01_b_full_swap_reverse()
|
||||
super().test_01_b_full_swap_reverse()
|
||||
|
||||
def test_01_c_full_swap_to_part(self):
|
||||
super().test_01_c_full_swap_to_part()
|
||||
|
||||
def test_01_d_full_swap_from_part(self):
|
||||
self.prepare_balance(Coins.BCH, 100.0, 1801, 1800)
|
||||
super().test_01_d_full_swap_from_part()
|
||||
|
||||
def test_02_a_leader_recover_a_lock_tx(self):
|
||||
super().test_02_a_leader_recover_a_lock_tx()
|
||||
|
||||
def test_03_a_follower_recover_a_lock_tx(self):
|
||||
super().test_03_a_follower_recover_a_lock_tx()
|
||||
|
||||
def test_03_b_follower_recover_a_lock_tx_reverse(self):
|
||||
self.prepare_balance(Coins.BCH, 100.0, 1801, 1800)
|
||||
super().test_03_b_follower_recover_a_lock_tx_reverse()
|
||||
|
||||
def test_03_c_follower_recover_a_lock_tx_to_part(self):
|
||||
super().test_03_c_follower_recover_a_lock_tx_to_part()
|
||||
|
||||
def test_03_d_follower_recover_a_lock_tx_from_part(self):
|
||||
self.prepare_balance(Coins.BCH, 100.0, 1801, 1800)
|
||||
super().test_03_d_follower_recover_a_lock_tx_from_part()
|
||||
|
||||
def test_04_a_follower_recover_b_lock_tx(self):
|
||||
super().test_04_a_follower_recover_b_lock_tx()
|
||||
|
||||
# does not work yet
|
||||
# def test_04_b_follower_recover_b_lock_tx_reverse(self):
|
||||
# self.prepare_balance(Coins.BCH, 100.0, 1801, 1800)
|
||||
# super().test_04_b_follower_recover_b_lock_tx_reverse()
|
||||
@@ -105,7 +105,7 @@ class TestFunctions(BaseTest):
|
||||
id_bidder: int = self.node_b_id
|
||||
|
||||
swap_clients = self.swap_clients
|
||||
reverse_bid: bool = coin_from in swap_clients[id_offerer].scriptless_coins
|
||||
reverse_bid: bool = swap_clients[0].is_reverse_ads_bid(coin_from, coin_to)
|
||||
ci_from = swap_clients[id_offerer].ci(coin_from)
|
||||
ci_to = swap_clients[id_bidder].ci(coin_to)
|
||||
ci_part0 = swap_clients[id_offerer].ci(Coins.PART)
|
||||
@@ -229,7 +229,7 @@ class TestFunctions(BaseTest):
|
||||
id_bidder: int = self.node_b_id
|
||||
|
||||
swap_clients = self.swap_clients
|
||||
reverse_bid: bool = coin_from in swap_clients[id_offerer].scriptless_coins
|
||||
reverse_bid: bool = swap_clients[0].is_reverse_ads_bid(coin_from, coin_to)
|
||||
ci_from = swap_clients[id_offerer].ci(coin_from)
|
||||
ci_to = swap_clients[id_offerer].ci(coin_to)
|
||||
|
||||
@@ -274,7 +274,7 @@ class TestFunctions(BaseTest):
|
||||
id_bidder: int = self.node_b_id
|
||||
|
||||
swap_clients = self.swap_clients
|
||||
reverse_bid: bool = coin_from in swap_clients[id_offerer].scriptless_coins
|
||||
reverse_bid: bool = swap_clients[0].is_reverse_ads_bid(coin_from, coin_to)
|
||||
ci_from = swap_clients[id_offerer].ci(coin_from)
|
||||
ci_to = swap_clients[id_offerer].ci(coin_to)
|
||||
|
||||
@@ -325,7 +325,7 @@ class TestFunctions(BaseTest):
|
||||
id_bidder: int = self.node_b_id
|
||||
|
||||
swap_clients = self.swap_clients
|
||||
reverse_bid: bool = coin_from in swap_clients[id_offerer].scriptless_coins
|
||||
reverse_bid: bool = swap_clients[0].is_reverse_ads_bid(coin_from, coin_to)
|
||||
ci_from = swap_clients[id_offerer].ci(coin_from)
|
||||
ci_to = swap_clients[id_offerer].ci(coin_to)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user