 	insert 'battle_participants', battle: 2, character_id: 5, side: 1, index: 1
 
 
-	tx = transaction conn
-
-	res = game._leaveBattle(tx, 1, 1)
+	res = game._leaveBattle(conn, 1, 1)
 	test.strictEqual res.battleEnded, false, "should return false if wasn't ended"
 
 	test.strictEqual query.val("SELECT autoinvolved_fm FROM characters WHERE id=1"), false,

	insert 'battle_participants', battle: 1, character_id: 1
	insert 'battle_participants', battle: 1, character_id: 2

	tx = transaction conn
	game._stopBattle(tx, 1)
	tx.commit.sync tx

	test.strictEqual +query.val("SELECT count(*) FROM battles"), 0, 'should remove battle'
	test.strictEqual +query.val("SELECT count(*) FROM battle_participants"), 0, 'should remove participants'

		], "should update indexes if participant has gone"


	res = game._leaveBattle(conn, 1, 3, 'user')
	test.strictEqual res.battleEnded, true, 'should return true if battle was ended'

	test.strictEqual query.val("SELECT autoinvolved_fm FROM characters WHERE id=2"), false,
