@Test public void getNameOperationNegative() { assertEquals(NamecoinUtil.getNameOperation(null),NamecoinUtil.STR_OP_UNKNOWN,"Script containing null correctly"); assertEquals(NamecoinUtil.getNameOperation(new byte[0]),NamecoinUtil.STR_OP_UNKNOWN,"Script containing byte array zero length correctly"); assertEquals(NamecoinUtil.getNameOperation(new byte[] {0x01,0x02}),NamecoinUtil.STR_OP_UNKNOWN,"Script containing no namecoin op correctly"); }
public static String getNameOperation(byte[] scriptPubKey) { if (scriptPubKey==null) { return NamecoinUtil.STR_OP_UNKNOWN; } if (scriptPubKey.length>1) { byte nameOp=scriptPubKey[0]; switch(nameOp) { case NamecoinUtil.OP_NAME_NEW: return NamecoinUtil.STR_OP_NAME_NEW; case NamecoinUtil.OP_NAME_FIRSTUPDATE: return NamecoinUtil.STR_OP_NAME_FIRSTUPDATE; case NamecoinUtil.OP_NAME_UDPATE: return NamecoinUtil.STR_OP_NAME_UDPATE; default: return NamecoinUtil.STR_OP_UNKNOWN; } } return NamecoinUtil.STR_OP_UNKNOWN; }
NamecoinUtil { public static String getNameOperation(byte[] scriptPubKey) { if (scriptPubKey==null) { return NamecoinUtil.STR_OP_UNKNOWN; } if (scriptPubKey.length>1) { byte nameOp=scriptPubKey[0]; switch(nameOp) { case NamecoinUtil.OP_NAME_NEW: return NamecoinUtil.STR_OP_NAME_NEW; case NamecoinUtil.OP_NAME_FIRSTUPDATE: return NamecoinUtil.STR_OP_NAME_FIRSTUPDATE; case NamecoinUtil.OP_NAME_UDPATE: return NamecoinUtil.STR_OP_NAME_UDPATE; default: return NamecoinUtil.STR_OP_UNKNOWN; } } return NamecoinUtil.STR_OP_UNKNOWN; } }
NamecoinUtil { public static String getNameOperation(byte[] scriptPubKey) { if (scriptPubKey==null) { return NamecoinUtil.STR_OP_UNKNOWN; } if (scriptPubKey.length>1) { byte nameOp=scriptPubKey[0]; switch(nameOp) { case NamecoinUtil.OP_NAME_NEW: return NamecoinUtil.STR_OP_NAME_NEW; case NamecoinUtil.OP_NAME_FIRSTUPDATE: return NamecoinUtil.STR_OP_NAME_FIRSTUPDATE; case NamecoinUtil.OP_NAME_UDPATE: return NamecoinUtil.STR_OP_NAME_UDPATE; default: return NamecoinUtil.STR_OP_UNKNOWN; } } return NamecoinUtil.STR_OP_UNKNOWN; }  }
NamecoinUtil { public static String getNameOperation(byte[] scriptPubKey) { if (scriptPubKey==null) { return NamecoinUtil.STR_OP_UNKNOWN; } if (scriptPubKey.length>1) { byte nameOp=scriptPubKey[0]; switch(nameOp) { case NamecoinUtil.OP_NAME_NEW: return NamecoinUtil.STR_OP_NAME_NEW; case NamecoinUtil.OP_NAME_FIRSTUPDATE: return NamecoinUtil.STR_OP_NAME_FIRSTUPDATE; case NamecoinUtil.OP_NAME_UDPATE: return NamecoinUtil.STR_OP_NAME_UDPATE; default: return NamecoinUtil.STR_OP_UNKNOWN; } } return NamecoinUtil.STR_OP_UNKNOWN; }  static String[] extractNamecoinField(byte[] scriptPubKey); static String getNameOperation(byte[] scriptPubKey); }
NamecoinUtil { public static String getNameOperation(byte[] scriptPubKey) { if (scriptPubKey==null) { return NamecoinUtil.STR_OP_UNKNOWN; } if (scriptPubKey.length>1) { byte nameOp=scriptPubKey[0]; switch(nameOp) { case NamecoinUtil.OP_NAME_NEW: return NamecoinUtil.STR_OP_NAME_NEW; case NamecoinUtil.OP_NAME_FIRSTUPDATE: return NamecoinUtil.STR_OP_NAME_FIRSTUPDATE; case NamecoinUtil.OP_NAME_UDPATE: return NamecoinUtil.STR_OP_NAME_UDPATE; default: return NamecoinUtil.STR_OP_UNKNOWN; } } return NamecoinUtil.STR_OP_UNKNOWN; }  static String[] extractNamecoinField(byte[] scriptPubKey); static String getNameOperation(byte[] scriptPubKey); final static byte OP_NAME_NEW; final static byte OP_NAME_FIRSTUPDATE; final static byte OP_NAME_UDPATE; final static String STR_OP_UNKNOWN; final static String STR_OP_NAME_NEW; final static String STR_OP_NAME_FIRSTUPDATE; final static String STR_OP_NAME_UDPATE; }