33# Distributed under the MIT software license, see the accompanying
44# file COPYING or http://www.opensource.org/licenses/mit-license.php.
55
6- #
7- # Exercise the wallet. Ported from wallet.sh.
8- # Does the following:
9- # a) creates 3 nodes, with an empty chain (no blocks).
10- # b) node0 mines a block
11- # c) node1 mines 101 blocks, so now nodes 0 and 1 have 50btc, node2 has none.
12- # d) node0 sends 21 btc to node2, in two transactions (11 btc, then 10 btc).
13- # e) node0 mines a block, collects the fee on the second transaction
14- # f) node1 mines 100 blocks, to mature node0's just-mined block
15- # g) check that node0 has 100-21, node2 has 21
16- # h) node0 should now have 2 unspent outputs; send these to node2 via raw tx broadcast by node1
17- # i) have node1 mine a block
18- # j) check balances - node0 should have 0, node2 should have 100
19- # k) test ResendWalletTransactions - create transactions, startup fourth node, make sure it syncs
20- #
216
227from test_framework .test_framework import BitcoinTestFramework
238from test_framework .util import *
@@ -190,7 +175,7 @@ def run_test (self):
190175 for uTx in unspentTxs :
191176 if uTx ['txid' ] == zeroValueTxid :
192177 found = True
193- assert_equal (uTx ['amount' ], Decimal ('0.00000000 ' ));
178+ assert_equal (uTx ['amount' ], Decimal ('0' ))
194179 assert (found )
195180
196181 #do some -walletbroadcast tests
@@ -202,21 +187,21 @@ def run_test (self):
202187 connect_nodes_bi (self .nodes ,0 ,2 )
203188 self .sync_all ()
204189
205- txIdNotBroadcasted = self .nodes [0 ].sendtoaddress (self .nodes [2 ].getnewaddress (), 2 );
190+ txIdNotBroadcasted = self .nodes [0 ].sendtoaddress (self .nodes [2 ].getnewaddress (), 2 )
206191 txObjNotBroadcasted = self .nodes [0 ].gettransaction (txIdNotBroadcasted )
207192 self .nodes [1 ].generate (1 ) #mine a block, tx should not be in there
208193 self .sync_all ()
209- assert_equal (self .nodes [2 ].getbalance (), node_2_bal ); #should not be changed because tx was not broadcasted
194+ assert_equal (self .nodes [2 ].getbalance (), node_2_bal ) #should not be changed because tx was not broadcasted
210195
211196 #now broadcast from another node, mine a block, sync, and check the balance
212197 self .nodes [1 ].sendrawtransaction (txObjNotBroadcasted ['hex' ])
213198 self .nodes [1 ].generate (1 )
214199 self .sync_all ()
215200 txObjNotBroadcasted = self .nodes [0 ].gettransaction (txIdNotBroadcasted )
216- assert_equal (self .nodes [2 ].getbalance (), node_2_bal + Decimal ('2' )); #should not be
201+ assert_equal (self .nodes [2 ].getbalance (), node_2_bal + Decimal ('2' )) #should not be
217202
218203 #create another tx
219- txIdNotBroadcasted = self .nodes [0 ].sendtoaddress (self .nodes [2 ].getnewaddress (), 2 );
204+ txIdNotBroadcasted = self .nodes [0 ].sendtoaddress (self .nodes [2 ].getnewaddress (), 2 )
220205
221206 #restart the nodes with -walletbroadcast=1
222207 stop_nodes (self .nodes )
@@ -231,21 +216,21 @@ def run_test (self):
231216 sync_blocks (self .nodes )
232217
233218 #tx should be added to balance because after restarting the nodes tx should be broadcastet
234- assert_equal (self .nodes [2 ].getbalance (), node_2_bal + Decimal ('4' )); #should not be
219+ assert_equal (self .nodes [2 ].getbalance (), node_2_bal + Decimal ('4' )) #should not be
235220
236221 #send a tx with value in a string (PR#6380 +)
237222 txId = self .nodes [0 ].sendtoaddress (self .nodes [2 ].getnewaddress (), "2" )
238223 txObj = self .nodes [0 ].gettransaction (txId )
239- assert_equal (txObj ['amount' ], Decimal ('-2.00000000 ' ))
224+ assert_equal (txObj ['amount' ], Decimal ('-2' ))
240225
241226 txId = self .nodes [0 ].sendtoaddress (self .nodes [2 ].getnewaddress (), "0.0001" )
242227 txObj = self .nodes [0 ].gettransaction (txId )
243- assert_equal (txObj ['amount' ], Decimal ('-0.00010000 ' ))
228+ assert_equal (txObj ['amount' ], Decimal ('-0.0001 ' ))
244229
245230 #check if JSON parser can handle scientific notation in strings
246231 txId = self .nodes [0 ].sendtoaddress (self .nodes [2 ].getnewaddress (), "1e-4" )
247232 txObj = self .nodes [0 ].gettransaction (txId )
248- assert_equal (txObj ['amount' ], Decimal ('-0.00010000 ' ))
233+ assert_equal (txObj ['amount' ], Decimal ('-0.0001 ' ))
249234
250235 #this should fail
251236 errorString = ""
@@ -254,15 +239,15 @@ def run_test (self):
254239 except JSONRPCException ,e :
255240 errorString = e .error ['message' ]
256241
257- assert_equal ("Invalid amount" in errorString , True );
242+ assert_equal ("Invalid amount" in errorString , True )
258243
259244 errorString = ""
260245 try :
261246 self .nodes [0 ].generate ("2" ) #use a string to as block amount parameter must fail because it's not interpreted as amount
262247 except JSONRPCException ,e :
263248 errorString = e .error ['message' ]
264249
265- assert_equal ("not an integer" in errorString , True );
250+ assert_equal ("not an integer" in errorString , True )
266251
267252
268253if __name__ == '__main__' :
0 commit comments