I've had to remove your question because the second part ("what would have happened") is speculative and therefore beyond the scope of this subreddit. You're welcome to repost the first question--we do have a nuclear history specialist--and consider redirecting the second to /r/HistoricalWhatIf.
Thank you.
Some basic facts, to start this off:
It's been said time and again that no one was really sure if it would be ready, or guarantee that it would work even if they did have it ready, before the end of WWII. It's part of that reason that it never really made it into strategic planning, along with the fact that it was (of course) shrouded completely in secrecy. Side note: It was so secret that a brigadier-general who suggested looking into atomic energy was actually intensely investigated.
In March of 1945, they figured out that the bomb would be ready for testing by July. On June 16 of 1945, a panel of high-level physicists was asked about the bomb by Secretary of War Henry Stimson. They recommended use for a direct military purpose, though they'd later admit they had no idea of the actual prospects of invasion. To many, it seemed like a foregone conclusion that the bomb would be used; they were just a formality discussing what its effects would be. Stimson wrote "Nothing would have been more damaging to our effort...than a warning or demonstration followed by a dud -- and this was a real possibility". As a result, the decision was made not to warn the Japanese. That decision was reinforced by the reasoning that if the Japanese were warned, they might move American prisoners of war into areas likely to be hit by the bomb, as human shields, according to James Byrnes (member on the Interim Committee, which investigated nuclear energy under FDR in May 1945). It was estimated, also, that they would only have two bombs by August, making matters even more complex; the bombs would have to send a message if used, and do it right.
As the Oppenheimer hearings showed, no one yet knew if a bomb would explode when dropped from a plane. The ground test scheduled in New Mexico would not prove that a plane-dropped bomb would work, and in June, they were still unsure. No one was even sure it would work on the ground, at that point. Admiral Leahy, chief of staff to FDR, was one of the biggest doubters, saying that "as an expert in explosives" he was sure the bomb would not go off (after FDR was briefed on how it worked).
Excitement obviously spread quickly after the successful test on July 17th, in Alamogordo, New Mexico. Still, there was the uncertainty of a bomb drop from a plane, but it was now clear that the bomb was a very real thing that could conceivably work. Training and preparation was set up, and Japan was given no warning specifically of the atomic bomb, though the United States did warn them of "destruction" in the Potsdam Declaration if they did not unconditionally surrender.
So really, how sure were we? Not really. Not at all. The real problem was that there were so many elements involved; the US delayed the attack due to unfavorable weather conditions just to limit anything possible that could get in the way.
What would've happened if we hadn't succeeded? Likely, nothing. The bomb would've been reworked, they'd try to investigate what might've gone wrong, and a review of the program (which, admittedly had taken up $2 billion in funding, quite a large chunk) would likely have been initiated. However, there was still plenty of thought as to other options: the United States had drawn up very detailed plans for invasion, bombing, and demoralization of the Japanese. However, none (they felt) would be sufficient to end the war as quickly and with as few American casualties. At best, the US would've bombed the remains of the atomic bomb ASAP to ensure that there was no leftover dud, but that's about all (also, it's mentioned somewhere that the bomb had a conventional bomb attached to blow up the remains if it failed). The war likely would've ended with a surrender (either joint with the Soviets, or just US), a costly invasion, and more firebombs. After that? Who knows, revising history that far is a bit much for any historian, and I'm not even a historian in my own humble opinion :).
The Decision to Use the Atomic Bomb Louis Morton Foreign Affairs, Vol. 35, No. 2 (Jan., 1957), pp. 334-353
Oppenheimer Hearings: Transcripts of Testimony - Ctrl+F 497 (for that page). Also, PDF FORMAT FOR THAT. Warning - very large file