NameScript { public boolean isAnyUpdate() { switch(op) { case OP_NAME_NEW: return false; case OP_NAME_FIRSTUPDATE: case OP_NAME_UPDATE: return true; default: throw new ScriptException("Not a name op"); } } NameScript(Script baseScript); boolean isNameOp(); Script getAddress(); boolean isAnyUpdate(); ScriptChunk getOpName(); ScriptChunk getOpValue(); static final int OP_NAME_NEW; static final int OP_NAME_FIRSTUPDATE; static final int OP_NAME_UPDATE; }
@Test public void nameFirstUpdateIsAnyUpdate() throws IOException { final NameScript ns = getNameFirstUpdateNameScript(); assertTrue(ns.isAnyUpdate()); }
@Test public void nameUpdateIsAnyUpdate() throws IOException { final NameScript ns = getNameUpdateNameScript(); assertTrue(ns.isAnyUpdate()); }
@Test public void currencyIsAnyUpdate() throws IOException { final NameScript ns = getCurrencyNameScript(); expectedEx.expect(org.bitcoinj.core.ScriptException.class); expectedEx.expectMessage("Not a name op"); ns.isAnyUpdate(); }
@Test public void returnIsAnyUpdate() throws IOException { final NameScript ns = getReturnNameScript(); expectedEx.expect(org.bitcoinj.core.ScriptException.class); expectedEx.expectMessage("Not a name op"); ns.isAnyUpdate(); }
@Test public void nameNewIsAnyUpdate() throws IOException { final NameScript ns = getNameNewNameScript(); assertFalse(ns.isAnyUpdate()); }