Unable to conditionally commit/rollback transaction
There are two errors in your script.

First, delete does not affect "Found_rows()" if you don't have a "returning".  You should use

set @rc = row_count();


Second, your logic in the if(cond,trueval,falseval) is inversed, you should use

set @tran = (select if(@rc = @expected,'COMMIT','ROLLBACK'));


You want to commit when the result equals what you expected, don't you?