'Test the on_tunnel_remove handler function for a circuit'

@blocking_call_on_reactor_thread
@inlineCallbacks
def test_on_tunnel_remove_append_pending(self):

    (node, other) = (yield self.create_nodes(2))
    tunnel_node = Circuit(long(0), 0)
    tunnel_node.bytes_up = ((12 * 1024) * 1024)
    tunnel_node.bytes_down = ((14 * 1024) * 1024)
    node.call(node.community.on_tunnel_remove, None, None, tunnel_node, self._create_target(node, other))
    node.call(node.community.on_tunnel_remove, None, None, tunnel_node, self._create_target(node, other))
    (yield deferLater(reactor, 5.1, (lambda : None)))
    self.assertEqual(node.community.pending_bytes[other.community.my_member.public_key].up, (2 * tunnel_node.bytes_up))
    self.assertEqual(node.community.pending_bytes[other.community.my_member.public_key].down, (2 * tunnel_node.bytes_down))
