Example #1
0
 def test_revoked(self):
     """Test a revoked commitment transaction being published."""
     # Set up channel between Alice and Bob
     self.alice.lit.create(self.bob.lurl, 50000000, 25000000)
     self.propagate()
     afee = 50000000 - self.alice.bit.getbalance()
     bfee = 75000000 - self.bob.bit.getbalance()
     self.assertGreaterEqual(afee, 0)
     self.assertGreaterEqual(bfee, 0)
     # Make a transaction
     self.assertEqual(self.alice.lit.getbalance(self.bob.lurl), 50000000)
     self.assertEqual(self.bob.lit.getbalance(self.alice.lurl), 25000000)
     self.bob.lit.send(self.alice.lurl, 5000000)
     self.assertEqual(self.alice.lit.getbalance(self.bob.lurl), 55000000)
     self.assertEqual(self.bob.lit.getbalance(self.alice.lurl), 20000000)
     # Save Alice's old commitment transactions
     commitment = self.alice.lit.getcommitmenttransactions(self.bob.lurl)
     # Do annother transaction, Alice sends Bob money
     self.alice.lit.send(self.bob.lurl, 10000000)
     self.assertEqual(self.alice.lit.getbalance(self.bob.lurl), 45000000)
     self.assertEqual(self.bob.lit.getbalance(self.alice.lurl), 30000000)
     # Alice stops responding
     stop(self.alice.lpid)
     # She publishes her old, revoked commitment transactions
     for transaction in commitment:
         self.alice.bit.sendrawtransaction(transaction)
         self.propagate()
     time.sleep(1)
     self.propagate()
     # Bob ends up with all the money
     self.assertGreaterEqual(self.bob.bit.getbalance(), 150000000 - bfee)
Example #2
0
 def test_revoked(self):
     """Test a revoked commitment transaction being published."""
     # Set up channel between Alice and Bob
     self.alice.lit.create(self.bob.lurl, 50000000, 25000000)
     self.propagate()
     afee = 50000000 - self.alice.bit.getbalance()
     bfee = 75000000 - self.bob.bit.getbalance()
     self.assertGreaterEqual(afee, 0)
     self.assertGreaterEqual(bfee, 0)
     # Make a transaction
     self.assertEqual(self.alice.lit.getbalance(self.bob.lurl), 50000000)
     self.assertEqual(self.bob.lit.getbalance(self.alice.lurl), 25000000)
     self.bob.lit.send(self.alice.lurl, 5000000)
     self.assertEqual(self.alice.lit.getbalance(self.bob.lurl), 55000000)
     self.assertEqual(self.bob.lit.getbalance(self.alice.lurl), 20000000)
     # Save Alice's old commitment transactions
     commitment = self.alice.lit.getcommitmenttransactions(self.bob.lurl)
     # Do annother transaction, Alice sends Bob money
     self.alice.lit.send(self.bob.lurl, 10000000)
     self.assertEqual(self.alice.lit.getbalance(self.bob.lurl), 45000000)
     self.assertEqual(self.bob.lit.getbalance(self.alice.lurl), 30000000)
     # Alice stops responding
     stop(self.alice.lpid)
     # She publishes her old, revoked commitment transactions
     for transaction in commitment:
         self.alice.bit.sendrawtransaction(transaction)
         self.propagate()
     time.sleep(1)
     self.propagate()
     # Bob ends up with all the money
     self.assertGreaterEqual(self.bob.bit.getbalance(), 150000000 - bfee)
Example #3
0
 def test_unilateral_close(self):
     """Test unilateral close."""
     # Set up channel between Alice and Bob
     self.alice.lit.create(self.bob.lurl, 50000000, 25000000)
     self.propagate()
     afee = 50000000 - self.alice.bit.getbalance()
     bfee = 75000000 - self.bob.bit.getbalance()
     self.assertGreaterEqual(afee, 0)
     self.assertGreaterEqual(bfee, 0)
     # Do some transactions
     self.assertEqual(self.alice.lit.getbalance(self.bob.lurl), 50000000)
     self.assertEqual(self.bob.lit.getbalance(self.alice.lurl), 25000000)
     self.bob.lit.send(self.alice.lurl, 5000000)
     self.assertEqual(self.alice.lit.getbalance(self.bob.lurl), 55000000)
     self.assertEqual(self.bob.lit.getbalance(self.alice.lurl), 20000000)
     # Kill Bob
     stop(self.bob.lpid)
     # Publish Alice's commitment transactions
     commitment = self.alice.lit.getcommitmenttransactions(self.bob.lurl)
     for transaction in commitment:
         self.alice.bit.sendrawtransaction(transaction)
         self.propagate()
     time.sleep(1)
     self.propagate()
     # Alice and Bob get their money out
     self.assertGreaterEqual(self.bob.bit.getbalance(), 95000000 - bfee)
     self.assertGreaterEqual(self.alice.bit.getbalance(), 105000000 - afee)
Example #4
0
 def test_unilateral_close(self):
     """Test unilateral close."""
     # Set up channel between Alice and Bob
     self.alice.lit.create(self.bob.lurl, 50000000, 25000000)
     self.propagate()
     afee = 50000000 - self.alice.bit.getbalance()
     bfee = 75000000 - self.bob.bit.getbalance()
     self.assertGreaterEqual(afee, 0)
     self.assertGreaterEqual(bfee, 0)
     # Do some transactions
     self.assertEqual(self.alice.lit.getbalance(self.bob.lurl), 50000000)
     self.assertEqual(self.bob.lit.getbalance(self.alice.lurl), 25000000)
     self.bob.lit.send(self.alice.lurl, 5000000)
     self.assertEqual(self.alice.lit.getbalance(self.bob.lurl), 55000000)
     self.assertEqual(self.bob.lit.getbalance(self.alice.lurl), 20000000)
     # Kill Bob
     stop(self.bob.lpid)
     # Publish Alice's commitment transactions
     commitment = self.alice.lit.getcommitmenttransactions(self.bob.lurl)
     for transaction in commitment:
         self.alice.bit.sendrawtransaction(transaction)
         self.propagate()
     time.sleep(1)
     self.propagate()
     # Alice and Bob get their money out
     self.assertGreaterEqual(self.bob.bit.getbalance(), 95000000 - bfee)
     self.assertGreaterEqual(self.alice.bit.getbalance(), 105000000 - afee)