forked from libraries/pabtc
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_wallet.py
More file actions
36 lines (34 loc) · 1.43 KB
/
test_wallet.py
File metadata and controls
36 lines (34 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import btc
import itertools
def test_wallet_transfer():
btc.config.current = btc.config.develop
user_list = [
btc.wallet.Wallet(btc.wallet.Tp2pkh(1)),
btc.wallet.Wallet(btc.wallet.Tp2shp2ms([btc.core.PriKey(e).pubkey() for e in [1, 2]], [1, 2])),
btc.wallet.Wallet(btc.wallet.Tp2shp2wpkh(1)),
btc.wallet.Wallet(btc.wallet.Tp2wpkh(1)),
btc.wallet.Wallet(btc.wallet.Tp2tr(1, bytearray())),
]
mate_list = [
btc.wallet.Wallet(btc.wallet.Tp2pkh(2)),
btc.wallet.Wallet(btc.wallet.Tp2shp2ms([btc.core.PriKey(e).pubkey() for e in [2, 1]], [2, 1])),
btc.wallet.Wallet(btc.wallet.Tp2shp2wpkh(2)),
btc.wallet.Wallet(btc.wallet.Tp2wpkh(2)),
btc.wallet.Wallet(btc.wallet.Tp2tr(2, bytearray())),
]
for user, mate in itertools.product(user_list, mate_list):
value = btc.denomination.bitcoin
value_old = mate.balance()
txid = user.transfer(mate.script, value)
btc.rpc.wait(txid[::-1].hex())
value_new = mate.balance()
assert value_new - value_old == value
value_old = value_new
txid = user.transfer(mate.script, value)
btc.rpc.wait(txid[::-1].hex())
value_new = mate.balance()
assert value_new - value_old == value
btc.rpc.generate_to_address(6, user.addr)
txid = mate.transfer_all(user.script)
btc.rpc.wait(txid[::-1].hex())
assert mate.balance() == 0