2022-01-24 22:22:15 -08:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
|
|
|
from wallet_shieldcoinbase import WalletShieldCoinbaseTest
|
|
|
|
from test_framework.util import assert_equal
|
|
|
|
from test_framework.mininode import COIN
|
|
|
|
|
|
|
|
class WalletShieldCoinbaseUANU5(WalletShieldCoinbaseTest):
|
|
|
|
def __init__(self):
|
|
|
|
super(WalletShieldCoinbaseUANU5, self).__init__()
|
|
|
|
self.account = None
|
|
|
|
# activate after initial setup, before the first z_shieldcoinbase RPC
|
|
|
|
self.nu5_activation = 109
|
|
|
|
|
|
|
|
def test_init_zaddr(self, node):
|
|
|
|
# this function may be called no more than once
|
|
|
|
assert(self.account is None)
|
|
|
|
self.account = node.z_getnewaccount()['account']
|
2022-03-21 11:28:53 -07:00
|
|
|
self.addr = node.z_getaddressforaccount(self.account)['address']
|
2022-01-24 22:22:15 -08:00
|
|
|
return self.addr
|
|
|
|
|
|
|
|
def test_check_balance_zaddr(self, node, expected):
|
|
|
|
balances = node.z_getbalanceforaccount(self.account)
|
|
|
|
assert('transparent' not in balances['pools'])
|
|
|
|
assert('sprout' not in balances['pools'])
|
2022-03-21 12:20:32 -07:00
|
|
|
# Remove the following after Orchard support is added to z_shieldcoinbase
|
2022-03-15 03:19:54 -07:00
|
|
|
sapling_balance = balances['pools']['sapling']['valueZat']
|
|
|
|
assert_equal(sapling_balance, expected * COIN)
|
2022-03-21 12:20:32 -07:00
|
|
|
# TODO: Uncomment after Orchard support is added to z_shieldcoinbase
|
|
|
|
#assert('sapling' not in balances['pools'])
|
|
|
|
#orchard_balance = balances['pools']['orchard']['valueZat']
|
|
|
|
#assert_equal(orchard_balance, expected * COIN)
|
2022-01-24 22:22:15 -08:00
|
|
|
|
2022-02-09 18:06:53 -08:00
|
|
|
# While we're at it, check that z_listunspent only shows outputs with
|
|
|
|
# the Unified Address (not the Orchard receiver), and of the expected
|
|
|
|
# type.
|
|
|
|
unspent = node.z_listunspent(1, 999999, False, [self.addr])
|
|
|
|
assert_equal(
|
2022-03-21 12:20:32 -07:00
|
|
|
# TODO: Fix after Orchard support is added to z_shieldcoinbase
|
|
|
|
#[{'type': 'orchard', 'address': self.addr} for _ in unspent],
|
2022-02-09 18:06:53 -08:00
|
|
|
[{'type': 'sapling', 'address': self.addr} for _ in unspent],
|
|
|
|
[{'type': x['type'], 'address': x['address']} for x in unspent],
|
|
|
|
)
|
|
|
|
|
2022-03-15 03:19:54 -07:00
|
|
|
total_balance = node.z_getbalance(self.addr) * COIN
|
2022-03-15 05:43:27 -07:00
|
|
|
assert_equal(total_balance, sapling_balance)
|
2022-01-24 22:22:15 -08:00
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
print("Test shielding to a unified address with NU5 activated")
|
|
|
|
WalletShieldCoinbaseUANU5().main()
|