/** * Handles a simple amount * * @throws FeathercoinURIParseException If something goes wrong */ @Test public void testGood_Amount() throws FeathercoinURIParseException { // Test the decimal parsing testObject = new FeathercoinURI( NetworkParameters.prodNet(), FeathercoinURI.LITECOIN_SCHEME + ":" + PRODNET_GOOD_ADDRESS + "?amount=9876543210.12345678"); assertEquals("987654321012345678", testObject.getAmount().toString()); // Test the decimal parsing testObject = new FeathercoinURI( NetworkParameters.prodNet(), FeathercoinURI.LITECOIN_SCHEME + ":" + PRODNET_GOOD_ADDRESS + "?amount=.12345678"); assertEquals("12345678", testObject.getAmount().toString()); // Test the integer parsing testObject = new FeathercoinURI( NetworkParameters.prodNet(), FeathercoinURI.LITECOIN_SCHEME + ":" + PRODNET_GOOD_ADDRESS + "?amount=9876543210"); assertEquals("987654321000000000", testObject.getAmount().toString()); }
@Test public void brokenURIs() throws FeathercoinURIParseException { // Check we can parse the incorrectly formatted URIs produced by blockchain.info and its iPhone // app. String str = "feathercoin://1KzTSfqjF2iKCduwz59nv2uqh1W2JsTxZH?amount=0.01000000"; FeathercoinURI uri = new FeathercoinURI(str); assertEquals("1KzTSfqjF2iKCduwz59nv2uqh1W2JsTxZH", uri.getAddress().toString()); assertEquals(Utils.toNanoCoins(0, 1), uri.getAmount()); }
/** * Test the simplest well-formed URI * * @throws FeathercoinURIParseException If something goes wrong */ @Test public void testGood_Simple() throws FeathercoinURIParseException { testObject = new FeathercoinURI( NetworkParameters.prodNet(), FeathercoinURI.LITECOIN_SCHEME + ":" + PRODNET_GOOD_ADDRESS); assertNotNull(testObject); assertNull("Unexpected amount", testObject.getAmount()); assertNull("Unexpected label", testObject.getLabel()); assertEquals("Unexpected label", 20, testObject.getAddress().getHash160().length); }