github.com/mit-dci/lit@v0.0.0-20221102210550-8c3d3b49f2ce/test/itest_send2.py (about)

     1  import testlib
     2  
     3  def run_test(env):
     4      bc = env.bitcoind
     5      lit = env.lits[0]
     6      lit2 = env.lits[1]
     7  
     8      # First figure out where we should send the money.
     9      addr = lit.make_new_addr()
    10      print('Got lit1 address:', addr)
    11  
    12      # Send a bitcoin.
    13      bc.rpc.sendtoaddress(addr, 1)
    14      env.generate_block()
    15      print('Sent and mined...')
    16  
    17      # Log it to make sure we got it.
    18      txo_total = lit.get_balance_info()['TxoTotal']
    19      print('initial lit1 balance:', txo_total)
    20  
    21      # Get an address for bitcoind.
    22      addr2 = lit2.make_new_addr()
    23      print('Got lit2 address:', addr2)
    24  
    25      # Send some bitcoin back, and mine it.
    26      lit.rpc.Send(DestAddrs=[ addr2 ], Amts=[ 50000000 ])
    27      env.generate_block()
    28      print('Sent and mined again...')
    29  
    30      # Validate.
    31      fbal1 = lit.get_balance_info()['TxoTotal']
    32      print('lit1 balance:', fbal1)
    33      fbal2 = lit2.get_balance_info()['TxoTotal']
    34      print('lit2 balance:', fbal2)
    35      if fbal2 != 50000000:
    36          raise AssertionError("Didn't get the amount we expected in the final lit node.")
    37  
    38  if __name__ == '__main__':
    39      env = None
    40      try:
    41          env = testlib.TestEnv(2)
    42          run_test(env)
    43      finally:
    44          if env is not None:
    45              env.shutdown()