forked from ElementsProject/elements
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfeature_default_asset_name.py
executable file
·70 lines (53 loc) · 2.74 KB
/
feature_default_asset_name.py
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/env python3
# Copyright (c) 2014-2016 The Bitcoin Core developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
#
# Test chain initialisation when specifying default asset name.
#
from test_framework.test_framework import BitcoinTestFramework
from test_framework.util import assert_equal
class NamedDefaultAssetTest(BitcoinTestFramework):
"""
Test creation of default asset is named according to defaultpeggedasset parameter
"""
def set_test_params(self):
self.setup_clean_chain = True
self.num_nodes = 2
#Set default asset name
self.extra_args = [["-defaultpeggedassetname=testasset", "-initialfreecoins=2100000000000000", "-anyonecanspendaremine=1", "-con_connect_genesis_outputs=1", "-con_blocksubsidy=0"]]*2
def setup_network(self, split=False):
self.setup_nodes()
self.connect_nodes(0, 1)
self.sync_all()
def skip_test_if_missing_module(self):
self.skip_if_no_wallet()
def run_test(self):
#Claim all anyone-can-spend coins and test that calling sendtoaddress without providing the assetlabel parameter results in the specified default pegged asset being sent.
self.nodes[0].sendtoaddress(self.nodes[0].getnewaddress(), 21000000, "", "", True)
self.generate(self.nodes[0], 101)
self.sync_all()
#Check the default asset is named correctly
walletinfo1 = self.nodes[0].getwalletinfo()
assert_equal(walletinfo1["balance"]["testasset"], 21000000)
#Send some of the default asset to the second node
self.nodes[0].sendtoaddress(self.nodes[1].getnewaddress(), 1, "", "", False)
self.generate(self.nodes[0], 101)
self.sync_all()
#Check balances are correct and asset is named correctly
walletinfo1 = self.nodes[0].getwalletinfo()
assert_equal(walletinfo1["balance"]["testasset"], 20999999)
walletinfo2 = self.nodes[1].getwalletinfo()
assert_equal(walletinfo2["balance"]["testasset"], 1)
#Check we send the default 'testasset' when calling 'sendmany' without needing to provide the relevant asset label
outputs = {self.nodes[1].getnewaddress(): 1.0, self.nodes[1].getnewaddress(): 3.0}
self.nodes[0].sendmany("", outputs)
self.generate(self.nodes[0], 101)
self.sync_all()
#Check balances are correct and asset is named correctly
walletinfo1 = self.nodes[0].getwalletinfo()
assert_equal(walletinfo1["balance"]["testasset"], 20999995)
walletinfo2 = self.nodes[1].getwalletinfo()
assert_equal(walletinfo2["balance"]["testasset"], 5)
if __name__ == '__main__':
NamedDefaultAssetTest().main()