Changeset View
Changeset View
Standalone View
Standalone View
test/functional/wallet_backup.py
Show First 20 Lines • Show All 64 Lines • ▼ Show 20 Lines | def setup_network(self): | ||||
connect_nodes(self.nodes[0], self.nodes[3]) | connect_nodes(self.nodes[0], self.nodes[3]) | ||||
connect_nodes(self.nodes[1], self.nodes[3]) | connect_nodes(self.nodes[1], self.nodes[3]) | ||||
connect_nodes(self.nodes[2], self.nodes[3]) | connect_nodes(self.nodes[2], self.nodes[3]) | ||||
connect_nodes(self.nodes[2], self.nodes[0]) | connect_nodes(self.nodes[2], self.nodes[0]) | ||||
self.sync_all() | self.sync_all() | ||||
def one_send(self, from_node, to_address): | def one_send(self, from_node, to_address): | ||||
if (randint(1, 2) == 1): | if (randint(1, 2) == 1): | ||||
amount = Decimal(randint(1, 10)) / Decimal(10) | amount = Decimal(randint(1, 10)) * Decimal(100000) | ||||
self.nodes[from_node].sendtoaddress(to_address, amount) | self.nodes[from_node].sendtoaddress(to_address, amount) | ||||
def do_one_round(self): | def do_one_round(self): | ||||
a0 = self.nodes[0].getnewaddress() | a0 = self.nodes[0].getnewaddress() | ||||
a1 = self.nodes[1].getnewaddress() | a1 = self.nodes[1].getnewaddress() | ||||
a2 = self.nodes[2].getnewaddress() | a2 = self.nodes[2].getnewaddress() | ||||
self.one_send(0, a1) | self.one_send(0, a1) | ||||
Show All 38 Lines | def run_test(self): | ||||
self.sync_blocks() | self.sync_blocks() | ||||
self.nodes[1].generate(1) | self.nodes[1].generate(1) | ||||
self.sync_blocks() | self.sync_blocks() | ||||
self.nodes[2].generate(1) | self.nodes[2].generate(1) | ||||
self.sync_blocks() | self.sync_blocks() | ||||
self.nodes[3].generate(100) | self.nodes[3].generate(100) | ||||
self.sync_blocks() | self.sync_blocks() | ||||
assert_equal(self.nodes[0].getbalance(), 50) | assert_equal(self.nodes[0].getbalance(), 50000000) | ||||
assert_equal(self.nodes[1].getbalance(), 50) | assert_equal(self.nodes[1].getbalance(), 50000000) | ||||
assert_equal(self.nodes[2].getbalance(), 50) | assert_equal(self.nodes[2].getbalance(), 50000000) | ||||
assert_equal(self.nodes[3].getbalance(), 0) | assert_equal(self.nodes[3].getbalance(), 0) | ||||
self.log.info("Creating transactions") | self.log.info("Creating transactions") | ||||
# Five rounds of sending each other transactions. | # Five rounds of sending each other transactions. | ||||
for i in range(5): | for i in range(5): | ||||
self.do_one_round() | self.do_one_round() | ||||
self.log.info("Backing up") | self.log.info("Backing up") | ||||
Show All 21 Lines | def run_test(self): | ||||
balance0 = self.nodes[0].getbalance() | balance0 = self.nodes[0].getbalance() | ||||
balance1 = self.nodes[1].getbalance() | balance1 = self.nodes[1].getbalance() | ||||
balance2 = self.nodes[2].getbalance() | balance2 = self.nodes[2].getbalance() | ||||
balance3 = self.nodes[3].getbalance() | balance3 = self.nodes[3].getbalance() | ||||
total = balance0 + balance1 + balance2 + balance3 | total = balance0 + balance1 + balance2 + balance3 | ||||
# At this point, there are 214 blocks (103 for setup, then 10 rounds, then 101.) | # At this point, there are 214 blocks (103 for setup, then 10 rounds, then 101.) | ||||
# 114 are mature, so the sum of all wallets should be 114 * 50 = 5700. | # 114 are mature, so the sum of all wallets should be 114 * 50 = 5700. | ||||
assert_equal(total, 5700) | assert_equal(total, 5700000000) | ||||
## | ## | ||||
# Test restoring spender wallets from backups | # Test restoring spender wallets from backups | ||||
## | ## | ||||
self.log.info("Restoring using wallet.dat") | self.log.info("Restoring using wallet.dat") | ||||
self.stop_three() | self.stop_three() | ||||
self.erase_three() | self.erase_three() | ||||
▲ Show 20 Lines • Show All 73 Lines • Show Last 20 Lines |