target stringlengths 20 113k | src_fm stringlengths 11 86.3k | src_fm_fc stringlengths 21 86.4k | src_fm_fc_co stringlengths 30 86.4k | src_fm_fc_ms stringlengths 42 86.8k | src_fm_fc_ms_ff stringlengths 43 86.8k |
|---|---|---|---|---|---|
@Test public void saveFullTrie() { Trie trie = new Trie(store).put("foo", "bar".getBytes()); store.save(trie); verify(map, times(1)).put(trie.getHash().getBytes(), trie.toMessage()); verify(map, times(1)).get(trie.getHash().getBytes()); verifyNoMoreInteractions(map); } | @Override public void save(Trie trie) { save(trie, true); } | TrieStoreImpl implements TrieStore { @Override public void save(Trie trie) { save(trie, true); } } | TrieStoreImpl implements TrieStore { @Override public void save(Trie trie) { save(trie, true); } TrieStoreImpl(KeyValueDataSource store); } | TrieStoreImpl implements TrieStore { @Override public void save(Trie trie) { save(trie, true); } TrieStoreImpl(KeyValueDataSource store); @Override void save(Trie trie); @Override void flush(); @Override Optional<Trie> retrieve(byte[] hash); @Override byte[] retrieveValue(byte[] hash); @Override void dispose(); } | TrieStoreImpl implements TrieStore { @Override public void save(Trie trie) { save(trie, true); } TrieStoreImpl(KeyValueDataSource store); @Override void save(Trie trie); @Override void flush(); @Override Optional<Trie> retrieve(byte[] hash); @Override byte[] retrieveValue(byte[] hash); @Override void dispose(); } |
@Test public void testEncodeInt_7f(){ String result = ByteUtil.toHexString(encodeInt(0x7f)); String expected = "7f"; assertEquals(expected, result); } | public static byte[] encodeInt(int singleInt) { if ((singleInt & 0xFF) == singleInt) { return encodeByte((byte) singleInt); } else if ((singleInt & 0xFFFF) == singleInt) { return encodeShort((short) singleInt); } else if ((singleInt & 0xFFFFFF) == singleInt) { return new byte[]{(byte) (OFFSET_SHORT_ITEM + 3), (byte) (s... | RLP { public static byte[] encodeInt(int singleInt) { if ((singleInt & 0xFF) == singleInt) { return encodeByte((byte) singleInt); } else if ((singleInt & 0xFFFF) == singleInt) { return encodeShort((short) singleInt); } else if ((singleInt & 0xFFFFFF) == singleInt) { return new byte[]{(byte) (OFFSET_SHORT_ITEM + 3), (by... | RLP { public static byte[] encodeInt(int singleInt) { if ((singleInt & 0xFF) == singleInt) { return encodeByte((byte) singleInt); } else if ((singleInt & 0xFFFF) == singleInt) { return encodeShort((short) singleInt); } else if ((singleInt & 0xFFFFFF) == singleInt) { return new byte[]{(byte) (OFFSET_SHORT_ITEM + 3), (by... | RLP { public static byte[] encodeInt(int singleInt) { if ((singleInt & 0xFF) == singleInt) { return encodeByte((byte) singleInt); } else if ((singleInt & 0xFFFF) == singleInt) { return encodeShort((short) singleInt); } else if ((singleInt & 0xFFFFFF) == singleInt) { return new byte[]{(byte) (OFFSET_SHORT_ITEM + 3), (by... | RLP { public static byte[] encodeInt(int singleInt) { if ((singleInt & 0xFF) == singleInt) { return encodeByte((byte) singleInt); } else if ((singleInt & 0xFFFF) == singleInt) { return encodeShort((short) singleInt); } else if ((singleInt & 0xFFFFFF) == singleInt) { return new byte[]{(byte) (OFFSET_SHORT_ITEM + 3), (by... |
@Test public void saveFullTrieWithLongValue() { Trie trie = new Trie(store).put("foo", TrieValueTest.makeValue(100)); store.save(trie); verify(map, times(1)).put(trie.getHash().getBytes(), trie.toMessage()); verify(map, times(1)).put(trie.getValueHash().getBytes(), trie.getValue()); verify(map, times(1)).get(trie.getHa... | @Override public void save(Trie trie) { save(trie, true); } | TrieStoreImpl implements TrieStore { @Override public void save(Trie trie) { save(trie, true); } } | TrieStoreImpl implements TrieStore { @Override public void save(Trie trie) { save(trie, true); } TrieStoreImpl(KeyValueDataSource store); } | TrieStoreImpl implements TrieStore { @Override public void save(Trie trie) { save(trie, true); } TrieStoreImpl(KeyValueDataSource store); @Override void save(Trie trie); @Override void flush(); @Override Optional<Trie> retrieve(byte[] hash); @Override byte[] retrieveValue(byte[] hash); @Override void dispose(); } | TrieStoreImpl implements TrieStore { @Override public void save(Trie trie) { save(trie, true); } TrieStoreImpl(KeyValueDataSource store); @Override void save(Trie trie); @Override void flush(); @Override Optional<Trie> retrieve(byte[] hash); @Override byte[] retrieveValue(byte[] hash); @Override void dispose(); } |
@Test public void saveFullTrieWithTwoLongValues() { Trie trie = new Trie(store) .put("foo", TrieValueTest.makeValue(100)) .put("bar", TrieValueTest.makeValue(200)); store.save(trie); verify(map, times(trie.trieSize())).put(any(), any()); verify(map, times(1)).get(trie.getHash().getBytes()); verify(map, times(1)).get(tr... | @Override public void save(Trie trie) { save(trie, true); } | TrieStoreImpl implements TrieStore { @Override public void save(Trie trie) { save(trie, true); } } | TrieStoreImpl implements TrieStore { @Override public void save(Trie trie) { save(trie, true); } TrieStoreImpl(KeyValueDataSource store); } | TrieStoreImpl implements TrieStore { @Override public void save(Trie trie) { save(trie, true); } TrieStoreImpl(KeyValueDataSource store); @Override void save(Trie trie); @Override void flush(); @Override Optional<Trie> retrieve(byte[] hash); @Override byte[] retrieveValue(byte[] hash); @Override void dispose(); } | TrieStoreImpl implements TrieStore { @Override public void save(Trie trie) { save(trie, true); } TrieStoreImpl(KeyValueDataSource store); @Override void save(Trie trie); @Override void flush(); @Override Optional<Trie> retrieve(byte[] hash); @Override byte[] retrieveValue(byte[] hash); @Override void dispose(); } |
@Test public void saveFullTrieTwice() { Trie trie = new Trie(store).put("foo", "bar".getBytes()); store.save(trie); verify(map, times(1)).put(trie.getHash().getBytes(), trie.toMessage()); verify(map, times(1)).get(trie.getHash().getBytes()); verify(map, times(1)).get(trie.getHash().getBytes()); verifyNoMoreInteractions... | @Override public void save(Trie trie) { save(trie, true); } | TrieStoreImpl implements TrieStore { @Override public void save(Trie trie) { save(trie, true); } } | TrieStoreImpl implements TrieStore { @Override public void save(Trie trie) { save(trie, true); } TrieStoreImpl(KeyValueDataSource store); } | TrieStoreImpl implements TrieStore { @Override public void save(Trie trie) { save(trie, true); } TrieStoreImpl(KeyValueDataSource store); @Override void save(Trie trie); @Override void flush(); @Override Optional<Trie> retrieve(byte[] hash); @Override byte[] retrieveValue(byte[] hash); @Override void dispose(); } | TrieStoreImpl implements TrieStore { @Override public void save(Trie trie) { save(trie, true); } TrieStoreImpl(KeyValueDataSource store); @Override void save(Trie trie); @Override void flush(); @Override Optional<Trie> retrieve(byte[] hash); @Override byte[] retrieveValue(byte[] hash); @Override void dispose(); } |
@Test public void saveFullTrieUpdateAndSaveAgainUsingBinaryTrie() { Trie trie = new Trie(store).put("foo", "bar".getBytes()); store.save(trie); Keccak256 hash1 = trie.getHash(); verify(map, times(trie.trieSize())).put(any(), any()); trie = trie.put("foo", "bar2".getBytes()); store.save(trie); Keccak256 hash2 = trie.get... | @Override public void save(Trie trie) { save(trie, true); } | TrieStoreImpl implements TrieStore { @Override public void save(Trie trie) { save(trie, true); } } | TrieStoreImpl implements TrieStore { @Override public void save(Trie trie) { save(trie, true); } TrieStoreImpl(KeyValueDataSource store); } | TrieStoreImpl implements TrieStore { @Override public void save(Trie trie) { save(trie, true); } TrieStoreImpl(KeyValueDataSource store); @Override void save(Trie trie); @Override void flush(); @Override Optional<Trie> retrieve(byte[] hash); @Override byte[] retrieveValue(byte[] hash); @Override void dispose(); } | TrieStoreImpl implements TrieStore { @Override public void save(Trie trie) { save(trie, true); } TrieStoreImpl(KeyValueDataSource store); @Override void save(Trie trie); @Override void flush(); @Override Optional<Trie> retrieve(byte[] hash); @Override byte[] retrieveValue(byte[] hash); @Override void dispose(); } |
@Test public void saveFullTrieUpdateAndSaveAgain() { Trie trie = new Trie(store).put("foo", "bar".getBytes()); store.save(trie); verify(map, times(trie.trieSize())).put(any(), any()); trie = trie.put("foo", "bar2".getBytes()); store.save(trie); verify(map, times(trie.trieSize() + 1)).put(any(), any()); verify(map, time... | @Override public void save(Trie trie) { save(trie, true); } | TrieStoreImpl implements TrieStore { @Override public void save(Trie trie) { save(trie, true); } } | TrieStoreImpl implements TrieStore { @Override public void save(Trie trie) { save(trie, true); } TrieStoreImpl(KeyValueDataSource store); } | TrieStoreImpl implements TrieStore { @Override public void save(Trie trie) { save(trie, true); } TrieStoreImpl(KeyValueDataSource store); @Override void save(Trie trie); @Override void flush(); @Override Optional<Trie> retrieve(byte[] hash); @Override byte[] retrieveValue(byte[] hash); @Override void dispose(); } | TrieStoreImpl implements TrieStore { @Override public void save(Trie trie) { save(trie, true); } TrieStoreImpl(KeyValueDataSource store); @Override void save(Trie trie); @Override void flush(); @Override Optional<Trie> retrieve(byte[] hash); @Override byte[] retrieveValue(byte[] hash); @Override void dispose(); } |
@Test public void retrieveTrieNotFound() { Assert.assertFalse(store.retrieve(new byte[] { 0x01, 0x02, 0x03, 0x04 }).isPresent()); } | @Override public Optional<Trie> retrieve(byte[] hash) { byte[] message = this.store.get(hash); if (message == null) { return Optional.empty(); } Trie trie = Trie.fromMessage(message, this); savedTries.add(trie); return Optional.of(trie); } | TrieStoreImpl implements TrieStore { @Override public Optional<Trie> retrieve(byte[] hash) { byte[] message = this.store.get(hash); if (message == null) { return Optional.empty(); } Trie trie = Trie.fromMessage(message, this); savedTries.add(trie); return Optional.of(trie); } } | TrieStoreImpl implements TrieStore { @Override public Optional<Trie> retrieve(byte[] hash) { byte[] message = this.store.get(hash); if (message == null) { return Optional.empty(); } Trie trie = Trie.fromMessage(message, this); savedTries.add(trie); return Optional.of(trie); } TrieStoreImpl(KeyValueDataSource store); } | TrieStoreImpl implements TrieStore { @Override public Optional<Trie> retrieve(byte[] hash) { byte[] message = this.store.get(hash); if (message == null) { return Optional.empty(); } Trie trie = Trie.fromMessage(message, this); savedTries.add(trie); return Optional.of(trie); } TrieStoreImpl(KeyValueDataSource store); @O... | TrieStoreImpl implements TrieStore { @Override public Optional<Trie> retrieve(byte[] hash) { byte[] message = this.store.get(hash); if (message == null) { return Optional.empty(); } Trie trie = Trie.fromMessage(message, this); savedTries.add(trie); return Optional.of(trie); } TrieStoreImpl(KeyValueDataSource store); @O... |
@Test public void getOrchidAccountTrieRootWithCompressedStorageKeys() { TrieStore trieStore = new TrieStoreImpl(new HashMapDB()); Repository repository = new MutableRepository(new MutableTrieImpl(trieStore, new Trie(trieStore))); Repository track = repository.startTracking(); TestUtils.getRandom().setSeed(0); int maxAc... | public byte[] getOrchidAccountTrieRoot(Trie src) { Metric metric = profiler.start(Profiler.PROFILING_TYPE.TRIE_CONVERTER_GET_ACCOUNT_ROOT); byte[] trieRoot = cacheHashes.computeIfAbsent(src.getHash(), k -> { Trie trie = getOrchidAccountTrieRoot(src.getSharedPath(), src, true); return trie == null ? HashUtil.EMPTY_TRIE_... | TrieConverter { public byte[] getOrchidAccountTrieRoot(Trie src) { Metric metric = profiler.start(Profiler.PROFILING_TYPE.TRIE_CONVERTER_GET_ACCOUNT_ROOT); byte[] trieRoot = cacheHashes.computeIfAbsent(src.getHash(), k -> { Trie trie = getOrchidAccountTrieRoot(src.getSharedPath(), src, true); return trie == null ? Hash... | TrieConverter { public byte[] getOrchidAccountTrieRoot(Trie src) { Metric metric = profiler.start(Profiler.PROFILING_TYPE.TRIE_CONVERTER_GET_ACCOUNT_ROOT); byte[] trieRoot = cacheHashes.computeIfAbsent(src.getHash(), k -> { Trie trie = getOrchidAccountTrieRoot(src.getSharedPath(), src, true); return trie == null ? Hash... | TrieConverter { public byte[] getOrchidAccountTrieRoot(Trie src) { Metric metric = profiler.start(Profiler.PROFILING_TYPE.TRIE_CONVERTER_GET_ACCOUNT_ROOT); byte[] trieRoot = cacheHashes.computeIfAbsent(src.getHash(), k -> { Trie trie = getOrchidAccountTrieRoot(src.getSharedPath(), src, true); return trie == null ? Hash... | TrieConverter { public byte[] getOrchidAccountTrieRoot(Trie src) { Metric metric = profiler.start(Profiler.PROFILING_TYPE.TRIE_CONVERTER_GET_ACCOUNT_ROOT); byte[] trieRoot = cacheHashes.computeIfAbsent(src.getHash(), k -> { Trie trie = getOrchidAccountTrieRoot(src.getSharedPath(), src, true); return trie == null ? Hash... |
@Test public void test1Simple() { TrieStore trieStore = new TrieStoreImpl(new HashMapDB()); Repository repository = new MutableRepository(new MutableTrieImpl(trieStore, new Trie(trieStore))); Repository track = repository.startTracking(); TestUtils.getRandom().setSeed(0); int maxAccounts = 10; int maxStorageRows = 5; f... | public byte[] getOrchidAccountTrieRoot(Trie src) { Metric metric = profiler.start(Profiler.PROFILING_TYPE.TRIE_CONVERTER_GET_ACCOUNT_ROOT); byte[] trieRoot = cacheHashes.computeIfAbsent(src.getHash(), k -> { Trie trie = getOrchidAccountTrieRoot(src.getSharedPath(), src, true); return trie == null ? HashUtil.EMPTY_TRIE_... | TrieConverter { public byte[] getOrchidAccountTrieRoot(Trie src) { Metric metric = profiler.start(Profiler.PROFILING_TYPE.TRIE_CONVERTER_GET_ACCOUNT_ROOT); byte[] trieRoot = cacheHashes.computeIfAbsent(src.getHash(), k -> { Trie trie = getOrchidAccountTrieRoot(src.getSharedPath(), src, true); return trie == null ? Hash... | TrieConverter { public byte[] getOrchidAccountTrieRoot(Trie src) { Metric metric = profiler.start(Profiler.PROFILING_TYPE.TRIE_CONVERTER_GET_ACCOUNT_ROOT); byte[] trieRoot = cacheHashes.computeIfAbsent(src.getHash(), k -> { Trie trie = getOrchidAccountTrieRoot(src.getSharedPath(), src, true); return trie == null ? Hash... | TrieConverter { public byte[] getOrchidAccountTrieRoot(Trie src) { Metric metric = profiler.start(Profiler.PROFILING_TYPE.TRIE_CONVERTER_GET_ACCOUNT_ROOT); byte[] trieRoot = cacheHashes.computeIfAbsent(src.getHash(), k -> { Trie trie = getOrchidAccountTrieRoot(src.getSharedPath(), src, true); return trie == null ? Hash... | TrieConverter { public byte[] getOrchidAccountTrieRoot(Trie src) { Metric metric = profiler.start(Profiler.PROFILING_TYPE.TRIE_CONVERTER_GET_ACCOUNT_ROOT); byte[] trieRoot = cacheHashes.computeIfAbsent(src.getHash(), k -> { Trie trie = getOrchidAccountTrieRoot(src.getSharedPath(), src, true); return trie == null ? Hash... |
@Test public void encodeNullBinaryPath() { try { PathEncoder.encode(null); Assert.fail(); } catch (Exception ex) { Assert.assertTrue(ex instanceof IllegalArgumentException); } } | @Nonnull public static byte[] encode(byte[] path) { if (path == null) { throw new IllegalArgumentException("path"); } return encodeBinaryPath(path); } | PathEncoder { @Nonnull public static byte[] encode(byte[] path) { if (path == null) { throw new IllegalArgumentException("path"); } return encodeBinaryPath(path); } } | PathEncoder { @Nonnull public static byte[] encode(byte[] path) { if (path == null) { throw new IllegalArgumentException("path"); } return encodeBinaryPath(path); } private PathEncoder(); } | PathEncoder { @Nonnull public static byte[] encode(byte[] path) { if (path == null) { throw new IllegalArgumentException("path"); } return encodeBinaryPath(path); } private PathEncoder(); @Nonnull static byte[] encode(byte[] path); @Nonnull static byte[] decode(byte[] encoded, int length); static int calculateEncodedL... | PathEncoder { @Nonnull public static byte[] encode(byte[] path) { if (path == null) { throw new IllegalArgumentException("path"); } return encodeBinaryPath(path); } private PathEncoder(); @Nonnull static byte[] encode(byte[] path); @Nonnull static byte[] decode(byte[] encoded, int length); static int calculateEncodedL... |
@Test public void encodeBinaryPath() { byte[] path = new byte[] { 0x00, 0x01, 0x01 }; byte[] encoded = PathEncoder.encode(path); Assert.assertNotNull(encoded); Assert.assertArrayEquals(new byte[] { 0x60 }, encoded); } | @Nonnull private static byte[] encodeBinaryPath(byte[] path) { int lpath = path.length; int lencoded = calculateEncodedLength(lpath); byte[] encoded = new byte[lencoded]; int nbyte = 0; for (int k = 0; k < lpath; k++) { int offset = k % 8; if (k > 0 && offset == 0) { nbyte++; } if (path[k] == 0) { continue; } encoded[n... | PathEncoder { @Nonnull private static byte[] encodeBinaryPath(byte[] path) { int lpath = path.length; int lencoded = calculateEncodedLength(lpath); byte[] encoded = new byte[lencoded]; int nbyte = 0; for (int k = 0; k < lpath; k++) { int offset = k % 8; if (k > 0 && offset == 0) { nbyte++; } if (path[k] == 0) { continu... | PathEncoder { @Nonnull private static byte[] encodeBinaryPath(byte[] path) { int lpath = path.length; int lencoded = calculateEncodedLength(lpath); byte[] encoded = new byte[lencoded]; int nbyte = 0; for (int k = 0; k < lpath; k++) { int offset = k % 8; if (k > 0 && offset == 0) { nbyte++; } if (path[k] == 0) { continu... | PathEncoder { @Nonnull private static byte[] encodeBinaryPath(byte[] path) { int lpath = path.length; int lencoded = calculateEncodedLength(lpath); byte[] encoded = new byte[lencoded]; int nbyte = 0; for (int k = 0; k < lpath; k++) { int offset = k % 8; if (k > 0 && offset == 0) { nbyte++; } if (path[k] == 0) { continu... | PathEncoder { @Nonnull private static byte[] encodeBinaryPath(byte[] path) { int lpath = path.length; int lencoded = calculateEncodedLength(lpath); byte[] encoded = new byte[lencoded]; int nbyte = 0; for (int k = 0; k < lpath; k++) { int offset = k % 8; if (k > 0 && offset == 0) { nbyte++; } if (path[k] == 0) { continu... |
@Test public void testEncodeInt_80(){ String result = ByteUtil.toHexString(encodeInt(0x80)); String expected = "8180"; assertEquals(expected, result); } | public static byte[] encodeInt(int singleInt) { if ((singleInt & 0xFF) == singleInt) { return encodeByte((byte) singleInt); } else if ((singleInt & 0xFFFF) == singleInt) { return encodeShort((short) singleInt); } else if ((singleInt & 0xFFFFFF) == singleInt) { return new byte[]{(byte) (OFFSET_SHORT_ITEM + 3), (byte) (s... | RLP { public static byte[] encodeInt(int singleInt) { if ((singleInt & 0xFF) == singleInt) { return encodeByte((byte) singleInt); } else if ((singleInt & 0xFFFF) == singleInt) { return encodeShort((short) singleInt); } else if ((singleInt & 0xFFFFFF) == singleInt) { return new byte[]{(byte) (OFFSET_SHORT_ITEM + 3), (by... | RLP { public static byte[] encodeInt(int singleInt) { if ((singleInt & 0xFF) == singleInt) { return encodeByte((byte) singleInt); } else if ((singleInt & 0xFFFF) == singleInt) { return encodeShort((short) singleInt); } else if ((singleInt & 0xFFFFFF) == singleInt) { return new byte[]{(byte) (OFFSET_SHORT_ITEM + 3), (by... | RLP { public static byte[] encodeInt(int singleInt) { if ((singleInt & 0xFF) == singleInt) { return encodeByte((byte) singleInt); } else if ((singleInt & 0xFFFF) == singleInt) { return encodeShort((short) singleInt); } else if ((singleInt & 0xFFFFFF) == singleInt) { return new byte[]{(byte) (OFFSET_SHORT_ITEM + 3), (by... | RLP { public static byte[] encodeInt(int singleInt) { if ((singleInt & 0xFF) == singleInt) { return encodeByte((byte) singleInt); } else if ((singleInt & 0xFFFF) == singleInt) { return encodeShort((short) singleInt); } else if ((singleInt & 0xFFFFFF) == singleInt) { return new byte[]{(byte) (OFFSET_SHORT_ITEM + 3), (by... |
@Test public void net_peerCount() throws Exception { Web3Impl web3 = createWeb3(); String peerCount = web3.net_peerCount(); Assert.assertEquals("Different number of peers than expected", "0x0", peerCount); } | @Override public String net_peerCount() { String s = null; try { int n = channelManager.getActivePeers().size(); return s = TypeConverter.toQuantityJsonHex(n); } finally { if (logger.isDebugEnabled()) { logger.debug("net_peerCount(): {}", s); } } } | Web3Impl implements Web3 { @Override public String net_peerCount() { String s = null; try { int n = channelManager.getActivePeers().size(); return s = TypeConverter.toQuantityJsonHex(n); } finally { if (logger.isDebugEnabled()) { logger.debug("net_peerCount(): {}", s); } } } } | Web3Impl implements Web3 { @Override public String net_peerCount() { String s = null; try { int n = channelManager.getActivePeers().size(); return s = TypeConverter.toQuantityJsonHex(n); } finally { if (logger.isDebugEnabled()) { logger.debug("net_peerCount(): {}", s); } } } protected Web3Impl(
Ethereum et... | Web3Impl implements Web3 { @Override public String net_peerCount() { String s = null; try { int n = channelManager.getActivePeers().size(); return s = TypeConverter.toQuantityJsonHex(n); } finally { if (logger.isDebugEnabled()) { logger.debug("net_peerCount(): {}", s); } } } protected Web3Impl(
Ethereum et... | Web3Impl implements Web3 { @Override public String net_peerCount() { String s = null; try { int n = channelManager.getActivePeers().size(); return s = TypeConverter.toQuantityJsonHex(n); } finally { if (logger.isDebugEnabled()) { logger.debug("net_peerCount(): {}", s); } } } protected Web3Impl(
Ethereum et... |
@Test public void encodeBinaryPathOneByte() { byte[] path = new byte[] { 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01 }; byte[] encoded = PathEncoder.encode(path); Assert.assertNotNull(encoded); Assert.assertArrayEquals(new byte[] { 0x6d }, encoded); } | @Nonnull public static byte[] encode(byte[] path) { if (path == null) { throw new IllegalArgumentException("path"); } return encodeBinaryPath(path); } | PathEncoder { @Nonnull public static byte[] encode(byte[] path) { if (path == null) { throw new IllegalArgumentException("path"); } return encodeBinaryPath(path); } } | PathEncoder { @Nonnull public static byte[] encode(byte[] path) { if (path == null) { throw new IllegalArgumentException("path"); } return encodeBinaryPath(path); } private PathEncoder(); } | PathEncoder { @Nonnull public static byte[] encode(byte[] path) { if (path == null) { throw new IllegalArgumentException("path"); } return encodeBinaryPath(path); } private PathEncoder(); @Nonnull static byte[] encode(byte[] path); @Nonnull static byte[] decode(byte[] encoded, int length); static int calculateEncodedL... | PathEncoder { @Nonnull public static byte[] encode(byte[] path) { if (path == null) { throw new IllegalArgumentException("path"); } return encodeBinaryPath(path); } private PathEncoder(); @Nonnull static byte[] encode(byte[] path); @Nonnull static byte[] decode(byte[] encoded, int length); static int calculateEncodedL... |
@Test public void encodeBinaryPathNineBits() { byte[] path = new byte[] { 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01 }; byte[] encoded = PathEncoder.encode(path); Assert.assertNotNull(encoded); Assert.assertArrayEquals(new byte[] { 0x6d, (byte)0x80 }, encoded); } | @Nonnull public static byte[] encode(byte[] path) { if (path == null) { throw new IllegalArgumentException("path"); } return encodeBinaryPath(path); } | PathEncoder { @Nonnull public static byte[] encode(byte[] path) { if (path == null) { throw new IllegalArgumentException("path"); } return encodeBinaryPath(path); } } | PathEncoder { @Nonnull public static byte[] encode(byte[] path) { if (path == null) { throw new IllegalArgumentException("path"); } return encodeBinaryPath(path); } private PathEncoder(); } | PathEncoder { @Nonnull public static byte[] encode(byte[] path) { if (path == null) { throw new IllegalArgumentException("path"); } return encodeBinaryPath(path); } private PathEncoder(); @Nonnull static byte[] encode(byte[] path); @Nonnull static byte[] decode(byte[] encoded, int length); static int calculateEncodedL... | PathEncoder { @Nonnull public static byte[] encode(byte[] path) { if (path == null) { throw new IllegalArgumentException("path"); } return encodeBinaryPath(path); } private PathEncoder(); @Nonnull static byte[] encode(byte[] path); @Nonnull static byte[] decode(byte[] encoded, int length); static int calculateEncodedL... |
@Test public void encodeBinaryPathOneAndHalfByte() { byte[] path = new byte[] { 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01 }; byte[] encoded = PathEncoder.encode(path); Assert.assertNotNull(encoded); Assert.assertArrayEquals(new byte[] { 0x6d, 0x50 }, encoded); } | @Nonnull public static byte[] encode(byte[] path) { if (path == null) { throw new IllegalArgumentException("path"); } return encodeBinaryPath(path); } | PathEncoder { @Nonnull public static byte[] encode(byte[] path) { if (path == null) { throw new IllegalArgumentException("path"); } return encodeBinaryPath(path); } } | PathEncoder { @Nonnull public static byte[] encode(byte[] path) { if (path == null) { throw new IllegalArgumentException("path"); } return encodeBinaryPath(path); } private PathEncoder(); } | PathEncoder { @Nonnull public static byte[] encode(byte[] path) { if (path == null) { throw new IllegalArgumentException("path"); } return encodeBinaryPath(path); } private PathEncoder(); @Nonnull static byte[] encode(byte[] path); @Nonnull static byte[] decode(byte[] encoded, int length); static int calculateEncodedL... | PathEncoder { @Nonnull public static byte[] encode(byte[] path) { if (path == null) { throw new IllegalArgumentException("path"); } return encodeBinaryPath(path); } private PathEncoder(); @Nonnull static byte[] encode(byte[] path); @Nonnull static byte[] decode(byte[] encoded, int length); static int calculateEncodedL... |
@Test public void decodeNullBinaryPath() { try { PathEncoder.decode(null, 0); Assert.fail(); } catch (Exception ex) { Assert.assertTrue(ex instanceof IllegalArgumentException); } } | @Nonnull public static byte[] decode(byte[] encoded, int length) { if (encoded == null) { throw new IllegalArgumentException("encoded"); } return decodeBinaryPath(encoded, length); } | PathEncoder { @Nonnull public static byte[] decode(byte[] encoded, int length) { if (encoded == null) { throw new IllegalArgumentException("encoded"); } return decodeBinaryPath(encoded, length); } } | PathEncoder { @Nonnull public static byte[] decode(byte[] encoded, int length) { if (encoded == null) { throw new IllegalArgumentException("encoded"); } return decodeBinaryPath(encoded, length); } private PathEncoder(); } | PathEncoder { @Nonnull public static byte[] decode(byte[] encoded, int length) { if (encoded == null) { throw new IllegalArgumentException("encoded"); } return decodeBinaryPath(encoded, length); } private PathEncoder(); @Nonnull static byte[] encode(byte[] path); @Nonnull static byte[] decode(byte[] encoded, int lengt... | PathEncoder { @Nonnull public static byte[] decode(byte[] encoded, int length) { if (encoded == null) { throw new IllegalArgumentException("encoded"); } return decodeBinaryPath(encoded, length); } private PathEncoder(); @Nonnull static byte[] encode(byte[] path); @Nonnull static byte[] decode(byte[] encoded, int lengt... |
@Test public void decodeBinaryPath() { byte[] encoded = new byte[] { 0x60 }; byte[] path = PathEncoder.decode(encoded, 3); Assert.assertNotNull(path); Assert.assertArrayEquals(new byte[] { 0x00, 0x01, 0x01 }, path); } | @Nonnull private static byte[] decodeBinaryPath(byte[] encoded, int bitlength) { byte[] path = new byte[bitlength]; for (int k = 0; k < bitlength; k++) { int nbyte = k / 8; int offset = k % 8; if (((encoded[nbyte] >> (7 - offset)) & 0x01) != 0) { path[k] = 1; } } return path; } | PathEncoder { @Nonnull private static byte[] decodeBinaryPath(byte[] encoded, int bitlength) { byte[] path = new byte[bitlength]; for (int k = 0; k < bitlength; k++) { int nbyte = k / 8; int offset = k % 8; if (((encoded[nbyte] >> (7 - offset)) & 0x01) != 0) { path[k] = 1; } } return path; } } | PathEncoder { @Nonnull private static byte[] decodeBinaryPath(byte[] encoded, int bitlength) { byte[] path = new byte[bitlength]; for (int k = 0; k < bitlength; k++) { int nbyte = k / 8; int offset = k % 8; if (((encoded[nbyte] >> (7 - offset)) & 0x01) != 0) { path[k] = 1; } } return path; } private PathEncoder(); } | PathEncoder { @Nonnull private static byte[] decodeBinaryPath(byte[] encoded, int bitlength) { byte[] path = new byte[bitlength]; for (int k = 0; k < bitlength; k++) { int nbyte = k / 8; int offset = k % 8; if (((encoded[nbyte] >> (7 - offset)) & 0x01) != 0) { path[k] = 1; } } return path; } private PathEncoder(); @No... | PathEncoder { @Nonnull private static byte[] decodeBinaryPath(byte[] encoded, int bitlength) { byte[] path = new byte[bitlength]; for (int k = 0; k < bitlength; k++) { int nbyte = k / 8; int offset = k % 8; if (((encoded[nbyte] >> (7 - offset)) & 0x01) != 0) { path[k] = 1; } } return path; } private PathEncoder(); @No... |
@Test public void decodeBinaryPathOneByte() { byte[] encoded = new byte[] { 0x6d }; byte[] path = PathEncoder.decode(encoded, 8); Assert.assertNotNull(path); Assert.assertArrayEquals(new byte[] { 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01 }, path); } | @Nonnull public static byte[] decode(byte[] encoded, int length) { if (encoded == null) { throw new IllegalArgumentException("encoded"); } return decodeBinaryPath(encoded, length); } | PathEncoder { @Nonnull public static byte[] decode(byte[] encoded, int length) { if (encoded == null) { throw new IllegalArgumentException("encoded"); } return decodeBinaryPath(encoded, length); } } | PathEncoder { @Nonnull public static byte[] decode(byte[] encoded, int length) { if (encoded == null) { throw new IllegalArgumentException("encoded"); } return decodeBinaryPath(encoded, length); } private PathEncoder(); } | PathEncoder { @Nonnull public static byte[] decode(byte[] encoded, int length) { if (encoded == null) { throw new IllegalArgumentException("encoded"); } return decodeBinaryPath(encoded, length); } private PathEncoder(); @Nonnull static byte[] encode(byte[] path); @Nonnull static byte[] decode(byte[] encoded, int lengt... | PathEncoder { @Nonnull public static byte[] decode(byte[] encoded, int length) { if (encoded == null) { throw new IllegalArgumentException("encoded"); } return decodeBinaryPath(encoded, length); } private PathEncoder(); @Nonnull static byte[] encode(byte[] path); @Nonnull static byte[] decode(byte[] encoded, int lengt... |
@Test public void decodeBinaryPathNineBits() { byte[] encoded = new byte[] { 0x6d, (byte)0x80 }; byte[] path = PathEncoder.decode(encoded, 9); Assert.assertNotNull(path); Assert.assertArrayEquals(new byte[] { 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x01 }, path); } | @Nonnull public static byte[] decode(byte[] encoded, int length) { if (encoded == null) { throw new IllegalArgumentException("encoded"); } return decodeBinaryPath(encoded, length); } | PathEncoder { @Nonnull public static byte[] decode(byte[] encoded, int length) { if (encoded == null) { throw new IllegalArgumentException("encoded"); } return decodeBinaryPath(encoded, length); } } | PathEncoder { @Nonnull public static byte[] decode(byte[] encoded, int length) { if (encoded == null) { throw new IllegalArgumentException("encoded"); } return decodeBinaryPath(encoded, length); } private PathEncoder(); } | PathEncoder { @Nonnull public static byte[] decode(byte[] encoded, int length) { if (encoded == null) { throw new IllegalArgumentException("encoded"); } return decodeBinaryPath(encoded, length); } private PathEncoder(); @Nonnull static byte[] encode(byte[] path); @Nonnull static byte[] decode(byte[] encoded, int lengt... | PathEncoder { @Nonnull public static byte[] decode(byte[] encoded, int length) { if (encoded == null) { throw new IllegalArgumentException("encoded"); } return decodeBinaryPath(encoded, length); } private PathEncoder(); @Nonnull static byte[] encode(byte[] path); @Nonnull static byte[] decode(byte[] encoded, int lengt... |
@Test public void decodeBinaryPathOneAndHalfByte() { byte[] encoded = new byte[] { 0x6d, 0x50 }; byte[] path = PathEncoder.decode(encoded, 12); Assert.assertNotNull(path); Assert.assertArrayEquals(new byte[] { 0x00, 0x01, 0x01, 0x00, 0x01, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01 }, path); } | @Nonnull public static byte[] decode(byte[] encoded, int length) { if (encoded == null) { throw new IllegalArgumentException("encoded"); } return decodeBinaryPath(encoded, length); } | PathEncoder { @Nonnull public static byte[] decode(byte[] encoded, int length) { if (encoded == null) { throw new IllegalArgumentException("encoded"); } return decodeBinaryPath(encoded, length); } } | PathEncoder { @Nonnull public static byte[] decode(byte[] encoded, int length) { if (encoded == null) { throw new IllegalArgumentException("encoded"); } return decodeBinaryPath(encoded, length); } private PathEncoder(); } | PathEncoder { @Nonnull public static byte[] decode(byte[] encoded, int length) { if (encoded == null) { throw new IllegalArgumentException("encoded"); } return decodeBinaryPath(encoded, length); } private PathEncoder(); @Nonnull static byte[] encode(byte[] path); @Nonnull static byte[] decode(byte[] encoded, int lengt... | PathEncoder { @Nonnull public static byte[] decode(byte[] encoded, int length) { if (encoded == null) { throw new IllegalArgumentException("encoded"); } return decodeBinaryPath(encoded, length); } private PathEncoder(); @Nonnull static byte[] encode(byte[] path); @Nonnull static byte[] decode(byte[] encoded, int lengt... |
@Test public void callsSaveOnlyOnNewestStore() { TrieStore store1 = mock(TrieStore.class); TrieStore store2 = mock(TrieStore.class); TrieStore store3 = mock(TrieStore.class); TrieStoreFactory storeFactory = mock(TrieStoreFactory.class); when(storeFactory.newInstance("46")).thenReturn(store1); when(storeFactory.newInsta... | @Override public void save(Trie trie) { getCurrentStore().save(trie); } | MultiTrieStore implements TrieStore { @Override public void save(Trie trie) { getCurrentStore().save(trie); } } | MultiTrieStore implements TrieStore { @Override public void save(Trie trie) { getCurrentStore().save(trie); } MultiTrieStore(int currentEpoch, int liveEpochs, TrieStoreFactory trieStoreFactory, OnEpochDispose disposer); } | MultiTrieStore implements TrieStore { @Override public void save(Trie trie) { getCurrentStore().save(trie); } MultiTrieStore(int currentEpoch, int liveEpochs, TrieStoreFactory trieStoreFactory, OnEpochDispose disposer); @Override void save(Trie trie); @Override void flush(); @Override Optional<Trie> retrieve(byte[] roo... | MultiTrieStore implements TrieStore { @Override public void save(Trie trie) { getCurrentStore().save(trie); } MultiTrieStore(int currentEpoch, int liveEpochs, TrieStoreFactory trieStoreFactory, OnEpochDispose disposer); @Override void save(Trie trie); @Override void flush(); @Override Optional<Trie> retrieve(byte[] roo... |
@Test public void callsFlushOnAllStores() { TrieStore store1 = mock(TrieStore.class); TrieStore store2 = mock(TrieStore.class); TrieStore store3 = mock(TrieStore.class); TrieStoreFactory storeFactory = mock(TrieStoreFactory.class); when(storeFactory.newInstance("46")).thenReturn(store1); when(storeFactory.newInstance("... | @Override public void flush() { epochs.forEach(TrieStore::flush); } | MultiTrieStore implements TrieStore { @Override public void flush() { epochs.forEach(TrieStore::flush); } } | MultiTrieStore implements TrieStore { @Override public void flush() { epochs.forEach(TrieStore::flush); } MultiTrieStore(int currentEpoch, int liveEpochs, TrieStoreFactory trieStoreFactory, OnEpochDispose disposer); } | MultiTrieStore implements TrieStore { @Override public void flush() { epochs.forEach(TrieStore::flush); } MultiTrieStore(int currentEpoch, int liveEpochs, TrieStoreFactory trieStoreFactory, OnEpochDispose disposer); @Override void save(Trie trie); @Override void flush(); @Override Optional<Trie> retrieve(byte[] rootHas... | MultiTrieStore implements TrieStore { @Override public void flush() { epochs.forEach(TrieStore::flush); } MultiTrieStore(int currentEpoch, int liveEpochs, TrieStoreFactory trieStoreFactory, OnEpochDispose disposer); @Override void save(Trie trie); @Override void flush(); @Override Optional<Trie> retrieve(byte[] rootHas... |
@Test public void testEncode_ED(){ String result = ByteUtil.toHexString(encode(0xED)); String expected = "81ed"; assertEquals(expected, result); } | public static byte[] encode(Object input) { Value val = new Value(input); if (val.isList()) { List<Object> inputArray = val.asList(); if (inputArray.isEmpty()) { return encodeLength(inputArray.size(), OFFSET_SHORT_LIST); } byte[] output = ByteUtil.EMPTY_BYTE_ARRAY; for (Object object : inputArray) { output = concatenat... | RLP { public static byte[] encode(Object input) { Value val = new Value(input); if (val.isList()) { List<Object> inputArray = val.asList(); if (inputArray.isEmpty()) { return encodeLength(inputArray.size(), OFFSET_SHORT_LIST); } byte[] output = ByteUtil.EMPTY_BYTE_ARRAY; for (Object object : inputArray) { output = conc... | RLP { public static byte[] encode(Object input) { Value val = new Value(input); if (val.isList()) { List<Object> inputArray = val.asList(); if (inputArray.isEmpty()) { return encodeLength(inputArray.size(), OFFSET_SHORT_LIST); } byte[] output = ByteUtil.EMPTY_BYTE_ARRAY; for (Object object : inputArray) { output = conc... | RLP { public static byte[] encode(Object input) { Value val = new Value(input); if (val.isList()) { List<Object> inputArray = val.asList(); if (inputArray.isEmpty()) { return encodeLength(inputArray.size(), OFFSET_SHORT_LIST); } byte[] output = ByteUtil.EMPTY_BYTE_ARRAY; for (Object object : inputArray) { output = conc... | RLP { public static byte[] encode(Object input) { Value val = new Value(input); if (val.isList()) { List<Object> inputArray = val.asList(); if (inputArray.isEmpty()) { return encodeLength(inputArray.size(), OFFSET_SHORT_LIST); } byte[] output = ByteUtil.EMPTY_BYTE_ARRAY; for (Object object : inputArray) { output = conc... |
@Test public void callsDisposeOnAllStores() { TrieStore store1 = mock(TrieStore.class); TrieStore store2 = mock(TrieStore.class); TrieStore store3 = mock(TrieStore.class); TrieStoreFactory storeFactory = mock(TrieStoreFactory.class); when(storeFactory.newInstance("46")).thenReturn(store1); when(storeFactory.newInstance... | @Override public void dispose() { epochs.forEach(TrieStore::dispose); } | MultiTrieStore implements TrieStore { @Override public void dispose() { epochs.forEach(TrieStore::dispose); } } | MultiTrieStore implements TrieStore { @Override public void dispose() { epochs.forEach(TrieStore::dispose); } MultiTrieStore(int currentEpoch, int liveEpochs, TrieStoreFactory trieStoreFactory, OnEpochDispose disposer); } | MultiTrieStore implements TrieStore { @Override public void dispose() { epochs.forEach(TrieStore::dispose); } MultiTrieStore(int currentEpoch, int liveEpochs, TrieStoreFactory trieStoreFactory, OnEpochDispose disposer); @Override void save(Trie trie); @Override void flush(); @Override Optional<Trie> retrieve(byte[] roo... | MultiTrieStore implements TrieStore { @Override public void dispose() { epochs.forEach(TrieStore::dispose); } MultiTrieStore(int currentEpoch, int liveEpochs, TrieStoreFactory trieStoreFactory, OnEpochDispose disposer); @Override void save(Trie trie); @Override void flush(); @Override Optional<Trie> retrieve(byte[] roo... |
@Test public void retrievesValueFromNewestStoreWithValue() { TrieStore store1 = mock(TrieStore.class); TrieStore store2 = mock(TrieStore.class); TrieStore store3 = mock(TrieStore.class); TrieStoreFactory storeFactory = mock(TrieStoreFactory.class); when(storeFactory.newInstance("46")).thenReturn(store1); when(storeFact... | @Override public byte[] retrieveValue(byte[] hash) { for (TrieStore epochTrieStore : epochs) { byte[] value = epochTrieStore.retrieveValue(hash); if (value != null) { return value; } } return null; } | MultiTrieStore implements TrieStore { @Override public byte[] retrieveValue(byte[] hash) { for (TrieStore epochTrieStore : epochs) { byte[] value = epochTrieStore.retrieveValue(hash); if (value != null) { return value; } } return null; } } | MultiTrieStore implements TrieStore { @Override public byte[] retrieveValue(byte[] hash) { for (TrieStore epochTrieStore : epochs) { byte[] value = epochTrieStore.retrieveValue(hash); if (value != null) { return value; } } return null; } MultiTrieStore(int currentEpoch, int liveEpochs, TrieStoreFactory trieStoreFactory... | MultiTrieStore implements TrieStore { @Override public byte[] retrieveValue(byte[] hash) { for (TrieStore epochTrieStore : epochs) { byte[] value = epochTrieStore.retrieveValue(hash); if (value != null) { return value; } } return null; } MultiTrieStore(int currentEpoch, int liveEpochs, TrieStoreFactory trieStoreFactory... | MultiTrieStore implements TrieStore { @Override public byte[] retrieveValue(byte[] hash) { for (TrieStore epochTrieStore : epochs) { byte[] value = epochTrieStore.retrieveValue(hash); if (value != null) { return value; } } return null; } MultiTrieStore(int currentEpoch, int liveEpochs, TrieStoreFactory trieStoreFactory... |
@Test public void exceptionIfGetWithNegativePosition() { BitSet set = new BitSet(17); try { set.get(-1); Assert.fail(); } catch (IndexOutOfBoundsException ex) { Assert.assertEquals("Index: -1, Size: 17", ex.getMessage()); } } | public boolean get(int position) { if (position < 0 || position >= this.size) { throw new IndexOutOfBoundsException(String.format("Index: %s, Size: %s", position, this.size)); } int offset = position / 8; int bitoffset = position % 8; return (this.bytes[offset] & 0xff & (1 << bitoffset)) != 0; } | BitSet { public boolean get(int position) { if (position < 0 || position >= this.size) { throw new IndexOutOfBoundsException(String.format("Index: %s, Size: %s", position, this.size)); } int offset = position / 8; int bitoffset = position % 8; return (this.bytes[offset] & 0xff & (1 << bitoffset)) != 0; } } | BitSet { public boolean get(int position) { if (position < 0 || position >= this.size) { throw new IndexOutOfBoundsException(String.format("Index: %s, Size: %s", position, this.size)); } int offset = position / 8; int bitoffset = position % 8; return (this.bytes[offset] & 0xff & (1 << bitoffset)) != 0; } BitSet(int siz... | BitSet { public boolean get(int position) { if (position < 0 || position >= this.size) { throw new IndexOutOfBoundsException(String.format("Index: %s, Size: %s", position, this.size)); } int offset = position / 8; int bitoffset = position % 8; return (this.bytes[offset] & 0xff & (1 << bitoffset)) != 0; } BitSet(int siz... | BitSet { public boolean get(int position) { if (position < 0 || position >= this.size) { throw new IndexOutOfBoundsException(String.format("Index: %s, Size: %s", position, this.size)); } int offset = position / 8; int bitoffset = position % 8; return (this.bytes[offset] & 0xff & (1 << bitoffset)) != 0; } BitSet(int siz... |
@Test public void exceptionIfGetWithOutOfBoundPosition() { BitSet set = new BitSet(17); try { set.get(17); Assert.fail(); } catch (IndexOutOfBoundsException ex) { Assert.assertEquals("Index: 17, Size: 17", ex.getMessage()); } } | public boolean get(int position) { if (position < 0 || position >= this.size) { throw new IndexOutOfBoundsException(String.format("Index: %s, Size: %s", position, this.size)); } int offset = position / 8; int bitoffset = position % 8; return (this.bytes[offset] & 0xff & (1 << bitoffset)) != 0; } | BitSet { public boolean get(int position) { if (position < 0 || position >= this.size) { throw new IndexOutOfBoundsException(String.format("Index: %s, Size: %s", position, this.size)); } int offset = position / 8; int bitoffset = position % 8; return (this.bytes[offset] & 0xff & (1 << bitoffset)) != 0; } } | BitSet { public boolean get(int position) { if (position < 0 || position >= this.size) { throw new IndexOutOfBoundsException(String.format("Index: %s, Size: %s", position, this.size)); } int offset = position / 8; int bitoffset = position % 8; return (this.bytes[offset] & 0xff & (1 << bitoffset)) != 0; } BitSet(int siz... | BitSet { public boolean get(int position) { if (position < 0 || position >= this.size) { throw new IndexOutOfBoundsException(String.format("Index: %s, Size: %s", position, this.size)); } int offset = position / 8; int bitoffset = position % 8; return (this.bytes[offset] & 0xff & (1 << bitoffset)) != 0; } BitSet(int siz... | BitSet { public boolean get(int position) { if (position < 0 || position >= this.size) { throw new IndexOutOfBoundsException(String.format("Index: %s, Size: %s", position, this.size)); } int offset = position / 8; int bitoffset = position % 8; return (this.bytes[offset] & 0xff & (1 << bitoffset)) != 0; } BitSet(int siz... |
@Test public void exceptionIfSetWithNegativePosition() { BitSet set = new BitSet(17); try { set.set(-1); Assert.fail(); } catch (IndexOutOfBoundsException ex) { Assert.assertEquals("Index: -1, Size: 17", ex.getMessage()); } } | public void set(int position) { if (position < 0 || position >= this.size) { throw new IndexOutOfBoundsException(String.format("Index: %s, Size: %s", position, this.size)); } int offset = position / 8; int bitoffset = position % 8; this.bytes[offset] |= 1 << bitoffset; } | BitSet { public void set(int position) { if (position < 0 || position >= this.size) { throw new IndexOutOfBoundsException(String.format("Index: %s, Size: %s", position, this.size)); } int offset = position / 8; int bitoffset = position % 8; this.bytes[offset] |= 1 << bitoffset; } } | BitSet { public void set(int position) { if (position < 0 || position >= this.size) { throw new IndexOutOfBoundsException(String.format("Index: %s, Size: %s", position, this.size)); } int offset = position / 8; int bitoffset = position % 8; this.bytes[offset] |= 1 << bitoffset; } BitSet(int size); } | BitSet { public void set(int position) { if (position < 0 || position >= this.size) { throw new IndexOutOfBoundsException(String.format("Index: %s, Size: %s", position, this.size)); } int offset = position / 8; int bitoffset = position % 8; this.bytes[offset] |= 1 << bitoffset; } BitSet(int size); void set(int position... | BitSet { public void set(int position) { if (position < 0 || position >= this.size) { throw new IndexOutOfBoundsException(String.format("Index: %s, Size: %s", position, this.size)); } int offset = position / 8; int bitoffset = position % 8; this.bytes[offset] |= 1 << bitoffset; } BitSet(int size); void set(int position... |
@Test public void exceptionIfSetWithOutOfBoundPosition() { BitSet set = new BitSet(17); try { set.set(17); Assert.fail(); } catch (IndexOutOfBoundsException ex) { Assert.assertEquals("Index: 17, Size: 17", ex.getMessage()); } } | public void set(int position) { if (position < 0 || position >= this.size) { throw new IndexOutOfBoundsException(String.format("Index: %s, Size: %s", position, this.size)); } int offset = position / 8; int bitoffset = position % 8; this.bytes[offset] |= 1 << bitoffset; } | BitSet { public void set(int position) { if (position < 0 || position >= this.size) { throw new IndexOutOfBoundsException(String.format("Index: %s, Size: %s", position, this.size)); } int offset = position / 8; int bitoffset = position % 8; this.bytes[offset] |= 1 << bitoffset; } } | BitSet { public void set(int position) { if (position < 0 || position >= this.size) { throw new IndexOutOfBoundsException(String.format("Index: %s, Size: %s", position, this.size)); } int offset = position / 8; int bitoffset = position % 8; this.bytes[offset] |= 1 << bitoffset; } BitSet(int size); } | BitSet { public void set(int position) { if (position < 0 || position >= this.size) { throw new IndexOutOfBoundsException(String.format("Index: %s, Size: %s", position, this.size)); } int offset = position / 8; int bitoffset = position % 8; this.bytes[offset] |= 1 << bitoffset; } BitSet(int size); void set(int position... | BitSet { public void set(int position) { if (position < 0 || position >= this.size) { throw new IndexOutOfBoundsException(String.format("Index: %s, Size: %s", position, this.size)); } int offset = position / 8; int bitoffset = position % 8; this.bytes[offset] |= 1 << bitoffset; } BitSet(int size); void set(int position... |
@Test public void functionSignatureOk() { CallTransaction.Function fn = method.getFunction(); Assert.assertEquals("extractPublicKeyFromExtendedPublicKey", fn.name); Assert.assertEquals(1, fn.inputs.length); Assert.assertEquals(SolidityType.getType("string").getName(), fn.inputs[0].type.getName()); Assert.assertEquals(1... | @Override public CallTransaction.Function getFunction() { return function; } | ExtractPublicKeyFromExtendedPublicKey extends NativeMethod { @Override public CallTransaction.Function getFunction() { return function; } } | ExtractPublicKeyFromExtendedPublicKey extends NativeMethod { @Override public CallTransaction.Function getFunction() { return function; } ExtractPublicKeyFromExtendedPublicKey(ExecutionEnvironment executionEnvironment, HDWalletUtilsHelper helper); } | ExtractPublicKeyFromExtendedPublicKey extends NativeMethod { @Override public CallTransaction.Function getFunction() { return function; } ExtractPublicKeyFromExtendedPublicKey(ExecutionEnvironment executionEnvironment, HDWalletUtilsHelper helper); @Override CallTransaction.Function getFunction(); @Override Object execu... | ExtractPublicKeyFromExtendedPublicKey extends NativeMethod { @Override public CallTransaction.Function getFunction() { return function; } ExtractPublicKeyFromExtendedPublicKey(ExecutionEnvironment executionEnvironment, HDWalletUtilsHelper helper); @Override CallTransaction.Function getFunction(); @Override Object execu... |
@Test public void shouldBeEnabled() { Assert.assertTrue(method.isEnabled()); } | @Override public boolean isEnabled() { return true; } | ExtractPublicKeyFromExtendedPublicKey extends NativeMethod { @Override public boolean isEnabled() { return true; } } | ExtractPublicKeyFromExtendedPublicKey extends NativeMethod { @Override public boolean isEnabled() { return true; } ExtractPublicKeyFromExtendedPublicKey(ExecutionEnvironment executionEnvironment, HDWalletUtilsHelper helper); } | ExtractPublicKeyFromExtendedPublicKey extends NativeMethod { @Override public boolean isEnabled() { return true; } ExtractPublicKeyFromExtendedPublicKey(ExecutionEnvironment executionEnvironment, HDWalletUtilsHelper helper); @Override CallTransaction.Function getFunction(); @Override Object execute(Object[] arguments);... | ExtractPublicKeyFromExtendedPublicKey extends NativeMethod { @Override public boolean isEnabled() { return true; } ExtractPublicKeyFromExtendedPublicKey(ExecutionEnvironment executionEnvironment, HDWalletUtilsHelper helper); @Override CallTransaction.Function getFunction(); @Override Object execute(Object[] arguments);... |
@Test public void shouldAllowAnyTypeOfCall() { Assert.assertFalse(method.onlyAllowsLocalCalls()); } | @Override public boolean onlyAllowsLocalCalls() { return false; } | ExtractPublicKeyFromExtendedPublicKey extends NativeMethod { @Override public boolean onlyAllowsLocalCalls() { return false; } } | ExtractPublicKeyFromExtendedPublicKey extends NativeMethod { @Override public boolean onlyAllowsLocalCalls() { return false; } ExtractPublicKeyFromExtendedPublicKey(ExecutionEnvironment executionEnvironment, HDWalletUtilsHelper helper); } | ExtractPublicKeyFromExtendedPublicKey extends NativeMethod { @Override public boolean onlyAllowsLocalCalls() { return false; } ExtractPublicKeyFromExtendedPublicKey(ExecutionEnvironment executionEnvironment, HDWalletUtilsHelper helper); @Override CallTransaction.Function getFunction(); @Override Object execute(Object[]... | ExtractPublicKeyFromExtendedPublicKey extends NativeMethod { @Override public boolean onlyAllowsLocalCalls() { return false; } ExtractPublicKeyFromExtendedPublicKey(ExecutionEnvironment executionEnvironment, HDWalletUtilsHelper helper); @Override CallTransaction.Function getFunction(); @Override Object execute(Object[]... |
@Test public void executes() { Assert.assertEquals( "02be517550b9e3be7fe42c80932d51e88e698663b4926e598b269d050e87e34d8c", ByteUtil.toHexString((byte[]) method.execute(new Object[]{ "xpub661MyMwAqRbcFMGNG2YcHvj3x63bAZN9U5cKikaiQ4zu2D1cvpnZYyXNR9nH62sGp4RR39Ui7SVQSq1PY4JbPuEuu5prVJJC3d5Pogft712", }))); } | @Override public Object execute(Object[] arguments) { if (arguments == null) { throw new NativeContractIllegalArgumentException(String.format(INVALID_EXTENDED_PUBLIC_KEY, null)); } String xpub = (String) arguments[0]; NetworkParameters params = helper.validateAndExtractNetworkFromExtendedPublicKey(xpub); DeterministicK... | ExtractPublicKeyFromExtendedPublicKey extends NativeMethod { @Override public Object execute(Object[] arguments) { if (arguments == null) { throw new NativeContractIllegalArgumentException(String.format(INVALID_EXTENDED_PUBLIC_KEY, null)); } String xpub = (String) arguments[0]; NetworkParameters params = helper.validat... | ExtractPublicKeyFromExtendedPublicKey extends NativeMethod { @Override public Object execute(Object[] arguments) { if (arguments == null) { throw new NativeContractIllegalArgumentException(String.format(INVALID_EXTENDED_PUBLIC_KEY, null)); } String xpub = (String) arguments[0]; NetworkParameters params = helper.validat... | ExtractPublicKeyFromExtendedPublicKey extends NativeMethod { @Override public Object execute(Object[] arguments) { if (arguments == null) { throw new NativeContractIllegalArgumentException(String.format(INVALID_EXTENDED_PUBLIC_KEY, null)); } String xpub = (String) arguments[0]; NetworkParameters params = helper.validat... | ExtractPublicKeyFromExtendedPublicKey extends NativeMethod { @Override public Object execute(Object[] arguments) { if (arguments == null) { throw new NativeContractIllegalArgumentException(String.format(INVALID_EXTENDED_PUBLIC_KEY, null)); } String xpub = (String) arguments[0]; NetworkParameters params = helper.validat... |
@Test public void partialDataParseTest() { String hex = "000080c180000000000000000000000042699b1104e93abf0008be55f912c2ff"; RLPList el = (RLPList) decode2OneItem(Hex.decode(hex), 3); assertEquals(1, el.size()); } | @Nullable public static RLPElement decode2OneItem(@CheckForNull byte[] msgData, int startPos) { if (msgData == null) { return null; } return RLP.decodeFirstElement(msgData, startPos); } | RLP { @Nullable public static RLPElement decode2OneItem(@CheckForNull byte[] msgData, int startPos) { if (msgData == null) { return null; } return RLP.decodeFirstElement(msgData, startPos); } } | RLP { @Nullable public static RLPElement decode2OneItem(@CheckForNull byte[] msgData, int startPos) { if (msgData == null) { return null; } return RLP.decodeFirstElement(msgData, startPos); } } | RLP { @Nullable public static RLPElement decode2OneItem(@CheckForNull byte[] msgData, int startPos) { if (msgData == null) { return null; } return RLP.decodeFirstElement(msgData, startPos); } static int decodeInt(byte[] data, int index); static BigInteger decodeBigInteger(byte[] data, int index); static byte[] decodeI... | RLP { @Nullable public static RLPElement decode2OneItem(@CheckForNull byte[] msgData, int startPos) { if (msgData == null) { return null; } return RLP.decodeFirstElement(msgData, startPos); } static int decodeInt(byte[] data, int index); static BigInteger decodeBigInteger(byte[] data, int index); static byte[] decodeI... |
@Test public void validatesExtendedPublicKeyFormat() { try { method.execute(new Object[]{ "this-is-not-an-xpub", }); Assert.fail(); } catch (NativeContractIllegalArgumentException e) { Assert.assertTrue(e.getMessage().contains("Invalid extended public key")); } } | @Override public Object execute(Object[] arguments) { if (arguments == null) { throw new NativeContractIllegalArgumentException(String.format(INVALID_EXTENDED_PUBLIC_KEY, null)); } String xpub = (String) arguments[0]; NetworkParameters params = helper.validateAndExtractNetworkFromExtendedPublicKey(xpub); DeterministicK... | ExtractPublicKeyFromExtendedPublicKey extends NativeMethod { @Override public Object execute(Object[] arguments) { if (arguments == null) { throw new NativeContractIllegalArgumentException(String.format(INVALID_EXTENDED_PUBLIC_KEY, null)); } String xpub = (String) arguments[0]; NetworkParameters params = helper.validat... | ExtractPublicKeyFromExtendedPublicKey extends NativeMethod { @Override public Object execute(Object[] arguments) { if (arguments == null) { throw new NativeContractIllegalArgumentException(String.format(INVALID_EXTENDED_PUBLIC_KEY, null)); } String xpub = (String) arguments[0]; NetworkParameters params = helper.validat... | ExtractPublicKeyFromExtendedPublicKey extends NativeMethod { @Override public Object execute(Object[] arguments) { if (arguments == null) { throw new NativeContractIllegalArgumentException(String.format(INVALID_EXTENDED_PUBLIC_KEY, null)); } String xpub = (String) arguments[0]; NetworkParameters params = helper.validat... | ExtractPublicKeyFromExtendedPublicKey extends NativeMethod { @Override public Object execute(Object[] arguments) { if (arguments == null) { throw new NativeContractIllegalArgumentException(String.format(INVALID_EXTENDED_PUBLIC_KEY, null)); } String xpub = (String) arguments[0]; NetworkParameters params = helper.validat... |
@Test public void failsUponInvalidPublicKey() { try { method.execute(new Object[]{ "tpubD6NzVbkrYhZ4YHQqwWz3Tm1ESZ9AidobeyLG4mEezB6hN8gFFWrcjczyF77Lw3HEs6Rjd2R11BEJ8Y9ptfxx9DFknkdujp58mFMx9H5dc1s", }); Assert.fail(); } catch (NativeContractIllegalArgumentException e) { Assert.assertTrue(e.getMessage().contains("Invalid... | @Override public Object execute(Object[] arguments) { if (arguments == null) { throw new NativeContractIllegalArgumentException(String.format(INVALID_EXTENDED_PUBLIC_KEY, null)); } String xpub = (String) arguments[0]; NetworkParameters params = helper.validateAndExtractNetworkFromExtendedPublicKey(xpub); DeterministicK... | ExtractPublicKeyFromExtendedPublicKey extends NativeMethod { @Override public Object execute(Object[] arguments) { if (arguments == null) { throw new NativeContractIllegalArgumentException(String.format(INVALID_EXTENDED_PUBLIC_KEY, null)); } String xpub = (String) arguments[0]; NetworkParameters params = helper.validat... | ExtractPublicKeyFromExtendedPublicKey extends NativeMethod { @Override public Object execute(Object[] arguments) { if (arguments == null) { throw new NativeContractIllegalArgumentException(String.format(INVALID_EXTENDED_PUBLIC_KEY, null)); } String xpub = (String) arguments[0]; NetworkParameters params = helper.validat... | ExtractPublicKeyFromExtendedPublicKey extends NativeMethod { @Override public Object execute(Object[] arguments) { if (arguments == null) { throw new NativeContractIllegalArgumentException(String.format(INVALID_EXTENDED_PUBLIC_KEY, null)); } String xpub = (String) arguments[0]; NetworkParameters params = helper.validat... | ExtractPublicKeyFromExtendedPublicKey extends NativeMethod { @Override public Object execute(Object[] arguments) { if (arguments == null) { throw new NativeContractIllegalArgumentException(String.format(INVALID_EXTENDED_PUBLIC_KEY, null)); } String xpub = (String) arguments[0]; NetworkParameters params = helper.validat... |
@Test public void failsUponNull() { try { method.execute(null); Assert.fail(); } catch (NativeContractIllegalArgumentException e) { Assert.assertTrue(e.getMessage().contains("Invalid extended public key")); } } | @Override public Object execute(Object[] arguments) { if (arguments == null) { throw new NativeContractIllegalArgumentException(String.format(INVALID_EXTENDED_PUBLIC_KEY, null)); } String xpub = (String) arguments[0]; NetworkParameters params = helper.validateAndExtractNetworkFromExtendedPublicKey(xpub); DeterministicK... | ExtractPublicKeyFromExtendedPublicKey extends NativeMethod { @Override public Object execute(Object[] arguments) { if (arguments == null) { throw new NativeContractIllegalArgumentException(String.format(INVALID_EXTENDED_PUBLIC_KEY, null)); } String xpub = (String) arguments[0]; NetworkParameters params = helper.validat... | ExtractPublicKeyFromExtendedPublicKey extends NativeMethod { @Override public Object execute(Object[] arguments) { if (arguments == null) { throw new NativeContractIllegalArgumentException(String.format(INVALID_EXTENDED_PUBLIC_KEY, null)); } String xpub = (String) arguments[0]; NetworkParameters params = helper.validat... | ExtractPublicKeyFromExtendedPublicKey extends NativeMethod { @Override public Object execute(Object[] arguments) { if (arguments == null) { throw new NativeContractIllegalArgumentException(String.format(INVALID_EXTENDED_PUBLIC_KEY, null)); } String xpub = (String) arguments[0]; NetworkParameters params = helper.validat... | ExtractPublicKeyFromExtendedPublicKey extends NativeMethod { @Override public Object execute(Object[] arguments) { if (arguments == null) { throw new NativeContractIllegalArgumentException(String.format(INVALID_EXTENDED_PUBLIC_KEY, null)); } String xpub = (String) arguments[0]; NetworkParameters params = helper.validat... |
@Test public void gasIsCorrect() { Assert.assertEquals(11_300, method.getGas(new Object[]{ "xpub661MyMwAqRbcFMGNG2YcHvj3x63bAZN9U5cKikaiQ4zu2D1cvpnZYyXNR9nH62sGp4RR39Ui7SVQSq1PY4JbPuEuu5prVJJC3d5Pogft712" }, new byte[]{})); } | @Override public long getGas(Object[] parsedArguments, byte[] originalData) { return 11_300L; } | ExtractPublicKeyFromExtendedPublicKey extends NativeMethod { @Override public long getGas(Object[] parsedArguments, byte[] originalData) { return 11_300L; } } | ExtractPublicKeyFromExtendedPublicKey extends NativeMethod { @Override public long getGas(Object[] parsedArguments, byte[] originalData) { return 11_300L; } ExtractPublicKeyFromExtendedPublicKey(ExecutionEnvironment executionEnvironment, HDWalletUtilsHelper helper); } | ExtractPublicKeyFromExtendedPublicKey extends NativeMethod { @Override public long getGas(Object[] parsedArguments, byte[] originalData) { return 11_300L; } ExtractPublicKeyFromExtendedPublicKey(ExecutionEnvironment executionEnvironment, HDWalletUtilsHelper helper); @Override CallTransaction.Function getFunction(); @Ov... | ExtractPublicKeyFromExtendedPublicKey extends NativeMethod { @Override public long getGas(Object[] parsedArguments, byte[] originalData) { return 11_300L; } ExtractPublicKeyFromExtendedPublicKey(ExecutionEnvironment executionEnvironment, HDWalletUtilsHelper helper); @Override CallTransaction.Function getFunction(); @Ov... |
@Test public void functionSignatureOk() { CallTransaction.Function fn = method.getFunction(); Assert.assertEquals("getMultisigScriptHash", fn.name); Assert.assertEquals(2, fn.inputs.length); Assert.assertEquals(SolidityType.getType("int256").getName(), fn.inputs[0].type.getName()); Assert.assertEquals(SolidityType.getT... | @Override public CallTransaction.Function getFunction() { return function; } | GetMultisigScriptHash extends NativeMethod { @Override public CallTransaction.Function getFunction() { return function; } } | GetMultisigScriptHash extends NativeMethod { @Override public CallTransaction.Function getFunction() { return function; } GetMultisigScriptHash(ExecutionEnvironment executionEnvironment); } | GetMultisigScriptHash extends NativeMethod { @Override public CallTransaction.Function getFunction() { return function; } GetMultisigScriptHash(ExecutionEnvironment executionEnvironment); @Override CallTransaction.Function getFunction(); @Override Object execute(Object[] arguments); @Override long getGas(Object[] parse... | GetMultisigScriptHash extends NativeMethod { @Override public CallTransaction.Function getFunction() { return function; } GetMultisigScriptHash(ExecutionEnvironment executionEnvironment); @Override CallTransaction.Function getFunction(); @Override Object execute(Object[] arguments); @Override long getGas(Object[] parse... |
@Test public void shouldBeEnabled() { Assert.assertTrue(method.isEnabled()); } | @Override public boolean isEnabled() { return true; } | GetMultisigScriptHash extends NativeMethod { @Override public boolean isEnabled() { return true; } } | GetMultisigScriptHash extends NativeMethod { @Override public boolean isEnabled() { return true; } GetMultisigScriptHash(ExecutionEnvironment executionEnvironment); } | GetMultisigScriptHash extends NativeMethod { @Override public boolean isEnabled() { return true; } GetMultisigScriptHash(ExecutionEnvironment executionEnvironment); @Override CallTransaction.Function getFunction(); @Override Object execute(Object[] arguments); @Override long getGas(Object[] parsedArguments, byte[] orig... | GetMultisigScriptHash extends NativeMethod { @Override public boolean isEnabled() { return true; } GetMultisigScriptHash(ExecutionEnvironment executionEnvironment); @Override CallTransaction.Function getFunction(); @Override Object execute(Object[] arguments); @Override long getGas(Object[] parsedArguments, byte[] orig... |
@Test public void shouldAllowAnyTypeOfCall() { Assert.assertFalse(method.onlyAllowsLocalCalls()); } | @Override public boolean onlyAllowsLocalCalls() { return false; } | GetMultisigScriptHash extends NativeMethod { @Override public boolean onlyAllowsLocalCalls() { return false; } } | GetMultisigScriptHash extends NativeMethod { @Override public boolean onlyAllowsLocalCalls() { return false; } GetMultisigScriptHash(ExecutionEnvironment executionEnvironment); } | GetMultisigScriptHash extends NativeMethod { @Override public boolean onlyAllowsLocalCalls() { return false; } GetMultisigScriptHash(ExecutionEnvironment executionEnvironment); @Override CallTransaction.Function getFunction(); @Override Object execute(Object[] arguments); @Override long getGas(Object[] parsedArguments,... | GetMultisigScriptHash extends NativeMethod { @Override public boolean onlyAllowsLocalCalls() { return false; } GetMultisigScriptHash(ExecutionEnvironment executionEnvironment); @Override CallTransaction.Function getFunction(); @Override Object execute(Object[] arguments); @Override long getGas(Object[] parsedArguments,... |
@Test public void executesWithAllCompressed() { Assert.assertEquals( "51f103320b435b5fe417b3f3e0f18972ccc710a0", ByteUtil.toHexString((byte[]) method.execute(new Object[]{ BigInteger.valueOf(8L), new byte[][] { Hex.decode("03b53899c390573471ba30e5054f78376c5f797fda26dde7a760789f02908cbad2"), Hex.decode("027319afb15481d... | @Override public Object execute(Object[] arguments) { if (arguments == null || arguments[0] == null) { throw new NativeContractIllegalArgumentException(REQUIRED_SIGNATURE_NULL_OR_ZERO); } int minimumSignatures = ((BigInteger) arguments[0]).intValueExact(); Object[] publicKeys = (Object[]) arguments[1]; if (minimumSigna... | GetMultisigScriptHash extends NativeMethod { @Override public Object execute(Object[] arguments) { if (arguments == null || arguments[0] == null) { throw new NativeContractIllegalArgumentException(REQUIRED_SIGNATURE_NULL_OR_ZERO); } int minimumSignatures = ((BigInteger) arguments[0]).intValueExact(); Object[] publicKey... | GetMultisigScriptHash extends NativeMethod { @Override public Object execute(Object[] arguments) { if (arguments == null || arguments[0] == null) { throw new NativeContractIllegalArgumentException(REQUIRED_SIGNATURE_NULL_OR_ZERO); } int minimumSignatures = ((BigInteger) arguments[0]).intValueExact(); Object[] publicKey... | GetMultisigScriptHash extends NativeMethod { @Override public Object execute(Object[] arguments) { if (arguments == null || arguments[0] == null) { throw new NativeContractIllegalArgumentException(REQUIRED_SIGNATURE_NULL_OR_ZERO); } int minimumSignatures = ((BigInteger) arguments[0]).intValueExact(); Object[] publicKey... | GetMultisigScriptHash extends NativeMethod { @Override public Object execute(Object[] arguments) { if (arguments == null || arguments[0] == null) { throw new NativeContractIllegalArgumentException(REQUIRED_SIGNATURE_NULL_OR_ZERO); } int minimumSignatures = ((BigInteger) arguments[0]).intValueExact(); Object[] publicKey... |
@Test public void executesWithMixed() { Assert.assertEquals( "51f103320b435b5fe417b3f3e0f18972ccc710a0", ByteUtil.toHexString((byte[]) method.execute(new Object[]{ BigInteger.valueOf(8L), new byte[][] { Hex.decode("04b53899c390573471ba30e5054f78376c5f797fda26dde7a760789f02908cbad2aafaaa2611606699ec4f82777a268b708dab346... | @Override public Object execute(Object[] arguments) { if (arguments == null || arguments[0] == null) { throw new NativeContractIllegalArgumentException(REQUIRED_SIGNATURE_NULL_OR_ZERO); } int minimumSignatures = ((BigInteger) arguments[0]).intValueExact(); Object[] publicKeys = (Object[]) arguments[1]; if (minimumSigna... | GetMultisigScriptHash extends NativeMethod { @Override public Object execute(Object[] arguments) { if (arguments == null || arguments[0] == null) { throw new NativeContractIllegalArgumentException(REQUIRED_SIGNATURE_NULL_OR_ZERO); } int minimumSignatures = ((BigInteger) arguments[0]).intValueExact(); Object[] publicKey... | GetMultisigScriptHash extends NativeMethod { @Override public Object execute(Object[] arguments) { if (arguments == null || arguments[0] == null) { throw new NativeContractIllegalArgumentException(REQUIRED_SIGNATURE_NULL_OR_ZERO); } int minimumSignatures = ((BigInteger) arguments[0]).intValueExact(); Object[] publicKey... | GetMultisigScriptHash extends NativeMethod { @Override public Object execute(Object[] arguments) { if (arguments == null || arguments[0] == null) { throw new NativeContractIllegalArgumentException(REQUIRED_SIGNATURE_NULL_OR_ZERO); } int minimumSignatures = ((BigInteger) arguments[0]).intValueExact(); Object[] publicKey... | GetMultisigScriptHash extends NativeMethod { @Override public Object execute(Object[] arguments) { if (arguments == null || arguments[0] == null) { throw new NativeContractIllegalArgumentException(REQUIRED_SIGNATURE_NULL_OR_ZERO); } int minimumSignatures = ((BigInteger) arguments[0]).intValueExact(); Object[] publicKey... |
@Test public void minimumSignaturesMustBePresent() { assertFails( () -> method.execute(new Object[]{ null, new Object[]{} }), "Minimum required signatures" ); } | @Override public Object execute(Object[] arguments) { if (arguments == null || arguments[0] == null) { throw new NativeContractIllegalArgumentException(REQUIRED_SIGNATURE_NULL_OR_ZERO); } int minimumSignatures = ((BigInteger) arguments[0]).intValueExact(); Object[] publicKeys = (Object[]) arguments[1]; if (minimumSigna... | GetMultisigScriptHash extends NativeMethod { @Override public Object execute(Object[] arguments) { if (arguments == null || arguments[0] == null) { throw new NativeContractIllegalArgumentException(REQUIRED_SIGNATURE_NULL_OR_ZERO); } int minimumSignatures = ((BigInteger) arguments[0]).intValueExact(); Object[] publicKey... | GetMultisigScriptHash extends NativeMethod { @Override public Object execute(Object[] arguments) { if (arguments == null || arguments[0] == null) { throw new NativeContractIllegalArgumentException(REQUIRED_SIGNATURE_NULL_OR_ZERO); } int minimumSignatures = ((BigInteger) arguments[0]).intValueExact(); Object[] publicKey... | GetMultisigScriptHash extends NativeMethod { @Override public Object execute(Object[] arguments) { if (arguments == null || arguments[0] == null) { throw new NativeContractIllegalArgumentException(REQUIRED_SIGNATURE_NULL_OR_ZERO); } int minimumSignatures = ((BigInteger) arguments[0]).intValueExact(); Object[] publicKey... | GetMultisigScriptHash extends NativeMethod { @Override public Object execute(Object[] arguments) { if (arguments == null || arguments[0] == null) { throw new NativeContractIllegalArgumentException(REQUIRED_SIGNATURE_NULL_OR_ZERO); } int minimumSignatures = ((BigInteger) arguments[0]).intValueExact(); Object[] publicKey... |
@Test public void testAppendByte() { byte[] bytes = "tes".getBytes(); byte b = 0x74; Assert.assertArrayEquals("test".getBytes(), ByteUtil.appendByte(bytes, b)); } | public static byte[] appendByte(byte[] bytes, byte b) { byte[] result = Arrays.copyOf(bytes, bytes.length + 1); result[result.length - 1] = b; return result; } | ByteUtil { public static byte[] appendByte(byte[] bytes, byte b) { byte[] result = Arrays.copyOf(bytes, bytes.length + 1); result[result.length - 1] = b; return result; } } | ByteUtil { public static byte[] appendByte(byte[] bytes, byte b) { byte[] result = Arrays.copyOf(bytes, bytes.length + 1); result[result.length - 1] = b; return result; } private ByteUtil(); } | ByteUtil { public static byte[] appendByte(byte[] bytes, byte b) { byte[] result = Arrays.copyOf(bytes, bytes.length + 1); result[result.length - 1] = b; return result; } private ByteUtil(); static byte[] appendByte(byte[] bytes, byte b); static byte[] cloneBytes(byte[] bytes); static byte[] bigIntegerToBytes(BigInteg... | ByteUtil { public static byte[] appendByte(byte[] bytes, byte b) { byte[] result = Arrays.copyOf(bytes, bytes.length + 1); result[result.length - 1] = b; return result; } private ByteUtil(); static byte[] appendByte(byte[] bytes, byte b); static byte[] cloneBytes(byte[] bytes); static byte[] bigIntegerToBytes(BigInteg... |
@Test public void minimumSignaturesMustBeGreaterThanZero() { assertFails( () -> method.execute(new Object[]{ BigInteger.ZERO, new Object[]{} }), "Minimum required signatures" ); } | @Override public Object execute(Object[] arguments) { if (arguments == null || arguments[0] == null) { throw new NativeContractIllegalArgumentException(REQUIRED_SIGNATURE_NULL_OR_ZERO); } int minimumSignatures = ((BigInteger) arguments[0]).intValueExact(); Object[] publicKeys = (Object[]) arguments[1]; if (minimumSigna... | GetMultisigScriptHash extends NativeMethod { @Override public Object execute(Object[] arguments) { if (arguments == null || arguments[0] == null) { throw new NativeContractIllegalArgumentException(REQUIRED_SIGNATURE_NULL_OR_ZERO); } int minimumSignatures = ((BigInteger) arguments[0]).intValueExact(); Object[] publicKey... | GetMultisigScriptHash extends NativeMethod { @Override public Object execute(Object[] arguments) { if (arguments == null || arguments[0] == null) { throw new NativeContractIllegalArgumentException(REQUIRED_SIGNATURE_NULL_OR_ZERO); } int minimumSignatures = ((BigInteger) arguments[0]).intValueExact(); Object[] publicKey... | GetMultisigScriptHash extends NativeMethod { @Override public Object execute(Object[] arguments) { if (arguments == null || arguments[0] == null) { throw new NativeContractIllegalArgumentException(REQUIRED_SIGNATURE_NULL_OR_ZERO); } int minimumSignatures = ((BigInteger) arguments[0]).intValueExact(); Object[] publicKey... | GetMultisigScriptHash extends NativeMethod { @Override public Object execute(Object[] arguments) { if (arguments == null || arguments[0] == null) { throw new NativeContractIllegalArgumentException(REQUIRED_SIGNATURE_NULL_OR_ZERO); } int minimumSignatures = ((BigInteger) arguments[0]).intValueExact(); Object[] publicKey... |
@Test public void mustProvideAtLeastTwoPublicKey() { assertFails( () -> method.execute(new Object[]{ BigInteger.ONE, new Object[]{} }), "At least 2 public keys" ); assertFails( () -> method.execute(new Object[]{ BigInteger.ONE, null }), "At least 2 public keys" ); assertFails( () -> method.execute(new Object[]{ BigInte... | @Override public Object execute(Object[] arguments) { if (arguments == null || arguments[0] == null) { throw new NativeContractIllegalArgumentException(REQUIRED_SIGNATURE_NULL_OR_ZERO); } int minimumSignatures = ((BigInteger) arguments[0]).intValueExact(); Object[] publicKeys = (Object[]) arguments[1]; if (minimumSigna... | GetMultisigScriptHash extends NativeMethod { @Override public Object execute(Object[] arguments) { if (arguments == null || arguments[0] == null) { throw new NativeContractIllegalArgumentException(REQUIRED_SIGNATURE_NULL_OR_ZERO); } int minimumSignatures = ((BigInteger) arguments[0]).intValueExact(); Object[] publicKey... | GetMultisigScriptHash extends NativeMethod { @Override public Object execute(Object[] arguments) { if (arguments == null || arguments[0] == null) { throw new NativeContractIllegalArgumentException(REQUIRED_SIGNATURE_NULL_OR_ZERO); } int minimumSignatures = ((BigInteger) arguments[0]).intValueExact(); Object[] publicKey... | GetMultisigScriptHash extends NativeMethod { @Override public Object execute(Object[] arguments) { if (arguments == null || arguments[0] == null) { throw new NativeContractIllegalArgumentException(REQUIRED_SIGNATURE_NULL_OR_ZERO); } int minimumSignatures = ((BigInteger) arguments[0]).intValueExact(); Object[] publicKey... | GetMultisigScriptHash extends NativeMethod { @Override public Object execute(Object[] arguments) { if (arguments == null || arguments[0] == null) { throw new NativeContractIllegalArgumentException(REQUIRED_SIGNATURE_NULL_OR_ZERO); } int minimumSignatures = ((BigInteger) arguments[0]).intValueExact(); Object[] publicKey... |
@Test public void atLeastAsManyPublicKeyAsMinimumSignatures() { assertFails( () -> method.execute(new Object[]{ BigInteger.valueOf(3L), new Object[]{ Hex.decode("03b65694ccccda83cbb1e56b31308acd08e993114c33f66a456b627c2c1c68bed6"), Hex.decode("02566d5ded7c7db1aa7ee4ef6f76989fb42527fcfdcddcd447d6793b7d869e46f7"), } }), ... | @Override public Object execute(Object[] arguments) { if (arguments == null || arguments[0] == null) { throw new NativeContractIllegalArgumentException(REQUIRED_SIGNATURE_NULL_OR_ZERO); } int minimumSignatures = ((BigInteger) arguments[0]).intValueExact(); Object[] publicKeys = (Object[]) arguments[1]; if (minimumSigna... | GetMultisigScriptHash extends NativeMethod { @Override public Object execute(Object[] arguments) { if (arguments == null || arguments[0] == null) { throw new NativeContractIllegalArgumentException(REQUIRED_SIGNATURE_NULL_OR_ZERO); } int minimumSignatures = ((BigInteger) arguments[0]).intValueExact(); Object[] publicKey... | GetMultisigScriptHash extends NativeMethod { @Override public Object execute(Object[] arguments) { if (arguments == null || arguments[0] == null) { throw new NativeContractIllegalArgumentException(REQUIRED_SIGNATURE_NULL_OR_ZERO); } int minimumSignatures = ((BigInteger) arguments[0]).intValueExact(); Object[] publicKey... | GetMultisigScriptHash extends NativeMethod { @Override public Object execute(Object[] arguments) { if (arguments == null || arguments[0] == null) { throw new NativeContractIllegalArgumentException(REQUIRED_SIGNATURE_NULL_OR_ZERO); } int minimumSignatures = ((BigInteger) arguments[0]).intValueExact(); Object[] publicKey... | GetMultisigScriptHash extends NativeMethod { @Override public Object execute(Object[] arguments) { if (arguments == null || arguments[0] == null) { throw new NativeContractIllegalArgumentException(REQUIRED_SIGNATURE_NULL_OR_ZERO); } int minimumSignatures = ((BigInteger) arguments[0]).intValueExact(); Object[] publicKey... |
@Test public void atMostFifteenPublicKeys() { byte[][] keys = new byte[16][]; for (int i = 0; i < 16; i++) { keys[i] = new BtcECKey().getPubKeyPoint().getEncoded(true); } assertFails( () -> method.execute(new Object[]{ BigInteger.valueOf(3L), keys }), "are more than the maximum allowed signatures" ); } | @Override public Object execute(Object[] arguments) { if (arguments == null || arguments[0] == null) { throw new NativeContractIllegalArgumentException(REQUIRED_SIGNATURE_NULL_OR_ZERO); } int minimumSignatures = ((BigInteger) arguments[0]).intValueExact(); Object[] publicKeys = (Object[]) arguments[1]; if (minimumSigna... | GetMultisigScriptHash extends NativeMethod { @Override public Object execute(Object[] arguments) { if (arguments == null || arguments[0] == null) { throw new NativeContractIllegalArgumentException(REQUIRED_SIGNATURE_NULL_OR_ZERO); } int minimumSignatures = ((BigInteger) arguments[0]).intValueExact(); Object[] publicKey... | GetMultisigScriptHash extends NativeMethod { @Override public Object execute(Object[] arguments) { if (arguments == null || arguments[0] == null) { throw new NativeContractIllegalArgumentException(REQUIRED_SIGNATURE_NULL_OR_ZERO); } int minimumSignatures = ((BigInteger) arguments[0]).intValueExact(); Object[] publicKey... | GetMultisigScriptHash extends NativeMethod { @Override public Object execute(Object[] arguments) { if (arguments == null || arguments[0] == null) { throw new NativeContractIllegalArgumentException(REQUIRED_SIGNATURE_NULL_OR_ZERO); } int minimumSignatures = ((BigInteger) arguments[0]).intValueExact(); Object[] publicKey... | GetMultisigScriptHash extends NativeMethod { @Override public Object execute(Object[] arguments) { if (arguments == null || arguments[0] == null) { throw new NativeContractIllegalArgumentException(REQUIRED_SIGNATURE_NULL_OR_ZERO); } int minimumSignatures = ((BigInteger) arguments[0]).intValueExact(); Object[] publicKey... |
@Test public void keyLengthIsValidated() { assertFails( () -> method.execute(new Object[]{ BigInteger.valueOf(1L), new Object[]{ Hex.decode("02566d5ded7c7db1aa7ee4ef6f76989fb42527fcfdcddcd447d6793b7d869e46f7"), Hex.decode("aabbcc"), } }), "Invalid public key length" ); } | @Override public Object execute(Object[] arguments) { if (arguments == null || arguments[0] == null) { throw new NativeContractIllegalArgumentException(REQUIRED_SIGNATURE_NULL_OR_ZERO); } int minimumSignatures = ((BigInteger) arguments[0]).intValueExact(); Object[] publicKeys = (Object[]) arguments[1]; if (minimumSigna... | GetMultisigScriptHash extends NativeMethod { @Override public Object execute(Object[] arguments) { if (arguments == null || arguments[0] == null) { throw new NativeContractIllegalArgumentException(REQUIRED_SIGNATURE_NULL_OR_ZERO); } int minimumSignatures = ((BigInteger) arguments[0]).intValueExact(); Object[] publicKey... | GetMultisigScriptHash extends NativeMethod { @Override public Object execute(Object[] arguments) { if (arguments == null || arguments[0] == null) { throw new NativeContractIllegalArgumentException(REQUIRED_SIGNATURE_NULL_OR_ZERO); } int minimumSignatures = ((BigInteger) arguments[0]).intValueExact(); Object[] publicKey... | GetMultisigScriptHash extends NativeMethod { @Override public Object execute(Object[] arguments) { if (arguments == null || arguments[0] == null) { throw new NativeContractIllegalArgumentException(REQUIRED_SIGNATURE_NULL_OR_ZERO); } int minimumSignatures = ((BigInteger) arguments[0]).intValueExact(); Object[] publicKey... | GetMultisigScriptHash extends NativeMethod { @Override public Object execute(Object[] arguments) { if (arguments == null || arguments[0] == null) { throw new NativeContractIllegalArgumentException(REQUIRED_SIGNATURE_NULL_OR_ZERO); } int minimumSignatures = ((BigInteger) arguments[0]).intValueExact(); Object[] publicKey... |
@Test public void keyFormatIsValidated() { assertFails( () -> method.execute(new Object[]{ BigInteger.valueOf(1L), new Object[]{ Hex.decode("03566d5ded7c7db1aa7ee4ef6f76989fb42527fcfdcddcd447d6793b7d869e46f7"), Hex.decode("08566d5ded7c7db1aa7ee4ef6f76989fb42527fcfdcddcd447d6793b7d869e46f7"), } }), "Invalid public key f... | @Override public Object execute(Object[] arguments) { if (arguments == null || arguments[0] == null) { throw new NativeContractIllegalArgumentException(REQUIRED_SIGNATURE_NULL_OR_ZERO); } int minimumSignatures = ((BigInteger) arguments[0]).intValueExact(); Object[] publicKeys = (Object[]) arguments[1]; if (minimumSigna... | GetMultisigScriptHash extends NativeMethod { @Override public Object execute(Object[] arguments) { if (arguments == null || arguments[0] == null) { throw new NativeContractIllegalArgumentException(REQUIRED_SIGNATURE_NULL_OR_ZERO); } int minimumSignatures = ((BigInteger) arguments[0]).intValueExact(); Object[] publicKey... | GetMultisigScriptHash extends NativeMethod { @Override public Object execute(Object[] arguments) { if (arguments == null || arguments[0] == null) { throw new NativeContractIllegalArgumentException(REQUIRED_SIGNATURE_NULL_OR_ZERO); } int minimumSignatures = ((BigInteger) arguments[0]).intValueExact(); Object[] publicKey... | GetMultisigScriptHash extends NativeMethod { @Override public Object execute(Object[] arguments) { if (arguments == null || arguments[0] == null) { throw new NativeContractIllegalArgumentException(REQUIRED_SIGNATURE_NULL_OR_ZERO); } int minimumSignatures = ((BigInteger) arguments[0]).intValueExact(); Object[] publicKey... | GetMultisigScriptHash extends NativeMethod { @Override public Object execute(Object[] arguments) { if (arguments == null || arguments[0] == null) { throw new NativeContractIllegalArgumentException(REQUIRED_SIGNATURE_NULL_OR_ZERO); } int minimumSignatures = ((BigInteger) arguments[0]).intValueExact(); Object[] publicKey... |
@Test public void gasIsBaseIfLessThanOrEqualstoTwoKeysPassed() { Assert.assertEquals(20_000L, method.getGas(new Object[]{ BigInteger.valueOf(1L), null }, new byte[]{})); Assert.assertEquals(20_000L, method.getGas(new Object[]{ BigInteger.valueOf(1L), new Object[]{ } }, new byte[]{})); Assert.assertEquals(20_000L, metho... | @Override public long getGas(Object[] parsedArguments, byte[] originalData) { Object[] keys = ((Object[]) parsedArguments[1]); if (keys == null || keys.length < 2) { return BASE_COST; } return BASE_COST + (keys.length - 2) * COST_PER_EXTRA_KEY; } | GetMultisigScriptHash extends NativeMethod { @Override public long getGas(Object[] parsedArguments, byte[] originalData) { Object[] keys = ((Object[]) parsedArguments[1]); if (keys == null || keys.length < 2) { return BASE_COST; } return BASE_COST + (keys.length - 2) * COST_PER_EXTRA_KEY; } } | GetMultisigScriptHash extends NativeMethod { @Override public long getGas(Object[] parsedArguments, byte[] originalData) { Object[] keys = ((Object[]) parsedArguments[1]); if (keys == null || keys.length < 2) { return BASE_COST; } return BASE_COST + (keys.length - 2) * COST_PER_EXTRA_KEY; } GetMultisigScriptHash(Execut... | GetMultisigScriptHash extends NativeMethod { @Override public long getGas(Object[] parsedArguments, byte[] originalData) { Object[] keys = ((Object[]) parsedArguments[1]); if (keys == null || keys.length < 2) { return BASE_COST; } return BASE_COST + (keys.length - 2) * COST_PER_EXTRA_KEY; } GetMultisigScriptHash(Execut... | GetMultisigScriptHash extends NativeMethod { @Override public long getGas(Object[] parsedArguments, byte[] originalData) { Object[] keys = ((Object[]) parsedArguments[1]); if (keys == null || keys.length < 2) { return BASE_COST; } return BASE_COST + (keys.length - 2) * COST_PER_EXTRA_KEY; } GetMultisigScriptHash(Execut... |
@Test public void functionSignatureOk() { CallTransaction.Function fn = method.getFunction(); Assert.assertEquals("deriveExtendedPublicKey", fn.name); Assert.assertEquals(2, fn.inputs.length); Assert.assertEquals(SolidityType.getType("string").getName(), fn.inputs[0].type.getName()); Assert.assertEquals(SolidityType.ge... | @Override public CallTransaction.Function getFunction() { return function; } | DeriveExtendedPublicKey extends NativeMethod { @Override public CallTransaction.Function getFunction() { return function; } } | DeriveExtendedPublicKey extends NativeMethod { @Override public CallTransaction.Function getFunction() { return function; } DeriveExtendedPublicKey(ExecutionEnvironment executionEnvironment, HDWalletUtilsHelper helper); } | DeriveExtendedPublicKey extends NativeMethod { @Override public CallTransaction.Function getFunction() { return function; } DeriveExtendedPublicKey(ExecutionEnvironment executionEnvironment, HDWalletUtilsHelper helper); @Override CallTransaction.Function getFunction(); @Override Object execute(Object[] arguments); @Ove... | DeriveExtendedPublicKey extends NativeMethod { @Override public CallTransaction.Function getFunction() { return function; } DeriveExtendedPublicKey(ExecutionEnvironment executionEnvironment, HDWalletUtilsHelper helper); @Override CallTransaction.Function getFunction(); @Override Object execute(Object[] arguments); @Ove... |
@Test public void shouldBeEnabled() { Assert.assertTrue(method.isEnabled()); } | @Override public boolean isEnabled() { return true; } | DeriveExtendedPublicKey extends NativeMethod { @Override public boolean isEnabled() { return true; } } | DeriveExtendedPublicKey extends NativeMethod { @Override public boolean isEnabled() { return true; } DeriveExtendedPublicKey(ExecutionEnvironment executionEnvironment, HDWalletUtilsHelper helper); } | DeriveExtendedPublicKey extends NativeMethod { @Override public boolean isEnabled() { return true; } DeriveExtendedPublicKey(ExecutionEnvironment executionEnvironment, HDWalletUtilsHelper helper); @Override CallTransaction.Function getFunction(); @Override Object execute(Object[] arguments); @Override boolean isEnabled... | DeriveExtendedPublicKey extends NativeMethod { @Override public boolean isEnabled() { return true; } DeriveExtendedPublicKey(ExecutionEnvironment executionEnvironment, HDWalletUtilsHelper helper); @Override CallTransaction.Function getFunction(); @Override Object execute(Object[] arguments); @Override boolean isEnabled... |
@Test public void shouldAllowAnyTypeOfCall() { Assert.assertFalse(method.onlyAllowsLocalCalls()); } | @Override public boolean onlyAllowsLocalCalls() { return false; } | DeriveExtendedPublicKey extends NativeMethod { @Override public boolean onlyAllowsLocalCalls() { return false; } } | DeriveExtendedPublicKey extends NativeMethod { @Override public boolean onlyAllowsLocalCalls() { return false; } DeriveExtendedPublicKey(ExecutionEnvironment executionEnvironment, HDWalletUtilsHelper helper); } | DeriveExtendedPublicKey extends NativeMethod { @Override public boolean onlyAllowsLocalCalls() { return false; } DeriveExtendedPublicKey(ExecutionEnvironment executionEnvironment, HDWalletUtilsHelper helper); @Override CallTransaction.Function getFunction(); @Override Object execute(Object[] arguments); @Override boole... | DeriveExtendedPublicKey extends NativeMethod { @Override public boolean onlyAllowsLocalCalls() { return false; } DeriveExtendedPublicKey(ExecutionEnvironment executionEnvironment, HDWalletUtilsHelper helper); @Override CallTransaction.Function getFunction(); @Override Object execute(Object[] arguments); @Override boole... |
@Test public void testBigIntegerToBytes() { byte[] expecteds = new byte[]{(byte) 0xff, (byte) 0xec, 0x78}; BigInteger b = BigInteger.valueOf(16772216); byte[] actuals = ByteUtil.bigIntegerToBytes(b); assertArrayEquals(expecteds, actuals); } | public static byte[] bigIntegerToBytes(BigInteger b, int numBytes) { if (b == null) { return EMPTY_BYTE_ARRAY; } byte[] bytes = new byte[numBytes]; byte[] biBytes = b.toByteArray(); int start = (biBytes.length == numBytes + 1) ? 1 : 0; int length = Math.min(biBytes.length, numBytes); System.arraycopy(biBytes, start, by... | ByteUtil { public static byte[] bigIntegerToBytes(BigInteger b, int numBytes) { if (b == null) { return EMPTY_BYTE_ARRAY; } byte[] bytes = new byte[numBytes]; byte[] biBytes = b.toByteArray(); int start = (biBytes.length == numBytes + 1) ? 1 : 0; int length = Math.min(biBytes.length, numBytes); System.arraycopy(biBytes... | ByteUtil { public static byte[] bigIntegerToBytes(BigInteger b, int numBytes) { if (b == null) { return EMPTY_BYTE_ARRAY; } byte[] bytes = new byte[numBytes]; byte[] biBytes = b.toByteArray(); int start = (biBytes.length == numBytes + 1) ? 1 : 0; int length = Math.min(biBytes.length, numBytes); System.arraycopy(biBytes... | ByteUtil { public static byte[] bigIntegerToBytes(BigInteger b, int numBytes) { if (b == null) { return EMPTY_BYTE_ARRAY; } byte[] bytes = new byte[numBytes]; byte[] biBytes = b.toByteArray(); int start = (biBytes.length == numBytes + 1) ? 1 : 0; int length = Math.min(biBytes.length, numBytes); System.arraycopy(biBytes... | ByteUtil { public static byte[] bigIntegerToBytes(BigInteger b, int numBytes) { if (b == null) { return EMPTY_BYTE_ARRAY; } byte[] bytes = new byte[numBytes]; byte[] biBytes = b.toByteArray(); int start = (biBytes.length == numBytes + 1) ? 1 : 0; int length = Math.min(biBytes.length, numBytes); System.arraycopy(biBytes... |
@Test public void executes() { Assert.assertEquals( "tpubDCGMkPKredy7oh6zw8f4ExWFdTgQCrAHToF1ytny3gbVy9GkUNK2Nqh7NbKbh8dkd5VtjUiLJPkbEkeg29NVHwxYwzHJFt9SazGLZrrU4Y4", method.execute(new Object[]{ "tpubD6NzVbkrYhZ4YHQqwWz3Tm1ESZ9AidobeyLG4mEezB6hN8gFFWrcjczyF77Lw3HEs6Rjd2R11BEJ8Y9ptfxx9DFknkdujp58mFMx9H5dc1r", "2/3/4" }... | @Override public Object execute(Object[] arguments) { if (arguments == null) { throw new NativeContractIllegalArgumentException("Must provide xpub and path arguments. None was provided"); } String xpub = (String) arguments[0]; String path = (String) arguments[1]; NetworkParameters params = helper.validateAndExtractNetw... | DeriveExtendedPublicKey extends NativeMethod { @Override public Object execute(Object[] arguments) { if (arguments == null) { throw new NativeContractIllegalArgumentException("Must provide xpub and path arguments. None was provided"); } String xpub = (String) arguments[0]; String path = (String) arguments[1]; NetworkPa... | DeriveExtendedPublicKey extends NativeMethod { @Override public Object execute(Object[] arguments) { if (arguments == null) { throw new NativeContractIllegalArgumentException("Must provide xpub and path arguments. None was provided"); } String xpub = (String) arguments[0]; String path = (String) arguments[1]; NetworkPa... | DeriveExtendedPublicKey extends NativeMethod { @Override public Object execute(Object[] arguments) { if (arguments == null) { throw new NativeContractIllegalArgumentException("Must provide xpub and path arguments. None was provided"); } String xpub = (String) arguments[0]; String path = (String) arguments[1]; NetworkPa... | DeriveExtendedPublicKey extends NativeMethod { @Override public Object execute(Object[] arguments) { if (arguments == null) { throw new NativeContractIllegalArgumentException("Must provide xpub and path arguments. None was provided"); } String xpub = (String) arguments[0]; String path = (String) arguments[1]; NetworkPa... |
@Test public void validatesExtendedPublicKeyFormat() { assertFailsWithMessage(() -> { method.execute(new Object[]{ "this-is-not-an-xpub", "this-doesnt-matter" }); }, "Invalid extended public key"); } | @Override public Object execute(Object[] arguments) { if (arguments == null) { throw new NativeContractIllegalArgumentException("Must provide xpub and path arguments. None was provided"); } String xpub = (String) arguments[0]; String path = (String) arguments[1]; NetworkParameters params = helper.validateAndExtractNetw... | DeriveExtendedPublicKey extends NativeMethod { @Override public Object execute(Object[] arguments) { if (arguments == null) { throw new NativeContractIllegalArgumentException("Must provide xpub and path arguments. None was provided"); } String xpub = (String) arguments[0]; String path = (String) arguments[1]; NetworkPa... | DeriveExtendedPublicKey extends NativeMethod { @Override public Object execute(Object[] arguments) { if (arguments == null) { throw new NativeContractIllegalArgumentException("Must provide xpub and path arguments. None was provided"); } String xpub = (String) arguments[0]; String path = (String) arguments[1]; NetworkPa... | DeriveExtendedPublicKey extends NativeMethod { @Override public Object execute(Object[] arguments) { if (arguments == null) { throw new NativeContractIllegalArgumentException("Must provide xpub and path arguments. None was provided"); } String xpub = (String) arguments[0]; String path = (String) arguments[1]; NetworkPa... | DeriveExtendedPublicKey extends NativeMethod { @Override public Object execute(Object[] arguments) { if (arguments == null) { throw new NativeContractIllegalArgumentException("Must provide xpub and path arguments. None was provided"); } String xpub = (String) arguments[0]; String path = (String) arguments[1]; NetworkPa... |
@Test public void ExtendedPublicKeyCannotBeNull() { assertFailsWithMessage(() -> { method.execute(new Object[]{ null, "M/0/1/2" }); }, "Invalid extended public key 'null"); } | @Override public Object execute(Object[] arguments) { if (arguments == null) { throw new NativeContractIllegalArgumentException("Must provide xpub and path arguments. None was provided"); } String xpub = (String) arguments[0]; String path = (String) arguments[1]; NetworkParameters params = helper.validateAndExtractNetw... | DeriveExtendedPublicKey extends NativeMethod { @Override public Object execute(Object[] arguments) { if (arguments == null) { throw new NativeContractIllegalArgumentException("Must provide xpub and path arguments. None was provided"); } String xpub = (String) arguments[0]; String path = (String) arguments[1]; NetworkPa... | DeriveExtendedPublicKey extends NativeMethod { @Override public Object execute(Object[] arguments) { if (arguments == null) { throw new NativeContractIllegalArgumentException("Must provide xpub and path arguments. None was provided"); } String xpub = (String) arguments[0]; String path = (String) arguments[1]; NetworkPa... | DeriveExtendedPublicKey extends NativeMethod { @Override public Object execute(Object[] arguments) { if (arguments == null) { throw new NativeContractIllegalArgumentException("Must provide xpub and path arguments. None was provided"); } String xpub = (String) arguments[0]; String path = (String) arguments[1]; NetworkPa... | DeriveExtendedPublicKey extends NativeMethod { @Override public Object execute(Object[] arguments) { if (arguments == null) { throw new NativeContractIllegalArgumentException("Must provide xpub and path arguments. None was provided"); } String xpub = (String) arguments[0]; String path = (String) arguments[1]; NetworkPa... |
@Test public void pathCannotBeAnything() { assertFailsWithMessage(() -> { method.execute(new Object[]{ "tpubD6NzVbkrYhZ4YHQqwWz3Tm1ESZ9AidobeyLG4mEezB6hN8gFFWrcjczyF77Lw3HEs6Rjd2R11BEJ8Y9ptfxx9DFknkdujp58mFMx9H5dc1r", "this-is-not-a-path" }); }, "Invalid path"); } | @Override public Object execute(Object[] arguments) { if (arguments == null) { throw new NativeContractIllegalArgumentException("Must provide xpub and path arguments. None was provided"); } String xpub = (String) arguments[0]; String path = (String) arguments[1]; NetworkParameters params = helper.validateAndExtractNetw... | DeriveExtendedPublicKey extends NativeMethod { @Override public Object execute(Object[] arguments) { if (arguments == null) { throw new NativeContractIllegalArgumentException("Must provide xpub and path arguments. None was provided"); } String xpub = (String) arguments[0]; String path = (String) arguments[1]; NetworkPa... | DeriveExtendedPublicKey extends NativeMethod { @Override public Object execute(Object[] arguments) { if (arguments == null) { throw new NativeContractIllegalArgumentException("Must provide xpub and path arguments. None was provided"); } String xpub = (String) arguments[0]; String path = (String) arguments[1]; NetworkPa... | DeriveExtendedPublicKey extends NativeMethod { @Override public Object execute(Object[] arguments) { if (arguments == null) { throw new NativeContractIllegalArgumentException("Must provide xpub and path arguments. None was provided"); } String xpub = (String) arguments[0]; String path = (String) arguments[1]; NetworkPa... | DeriveExtendedPublicKey extends NativeMethod { @Override public Object execute(Object[] arguments) { if (arguments == null) { throw new NativeContractIllegalArgumentException("Must provide xpub and path arguments. None was provided"); } String xpub = (String) arguments[0]; String path = (String) arguments[1]; NetworkPa... |
@Test public void pathCannotBeNull() { assertFailsWithMessage(() -> { method.execute(new Object[]{ "tpubD6NzVbkrYhZ4YHQqwWz3Tm1ESZ9AidobeyLG4mEezB6hN8gFFWrcjczyF77Lw3HEs6Rjd2R11BEJ8Y9ptfxx9DFknkdujp58mFMx9H5dc1r", null }); }, "Invalid path"); } | @Override public Object execute(Object[] arguments) { if (arguments == null) { throw new NativeContractIllegalArgumentException("Must provide xpub and path arguments. None was provided"); } String xpub = (String) arguments[0]; String path = (String) arguments[1]; NetworkParameters params = helper.validateAndExtractNetw... | DeriveExtendedPublicKey extends NativeMethod { @Override public Object execute(Object[] arguments) { if (arguments == null) { throw new NativeContractIllegalArgumentException("Must provide xpub and path arguments. None was provided"); } String xpub = (String) arguments[0]; String path = (String) arguments[1]; NetworkPa... | DeriveExtendedPublicKey extends NativeMethod { @Override public Object execute(Object[] arguments) { if (arguments == null) { throw new NativeContractIllegalArgumentException("Must provide xpub and path arguments. None was provided"); } String xpub = (String) arguments[0]; String path = (String) arguments[1]; NetworkPa... | DeriveExtendedPublicKey extends NativeMethod { @Override public Object execute(Object[] arguments) { if (arguments == null) { throw new NativeContractIllegalArgumentException("Must provide xpub and path arguments. None was provided"); } String xpub = (String) arguments[0]; String path = (String) arguments[1]; NetworkPa... | DeriveExtendedPublicKey extends NativeMethod { @Override public Object execute(Object[] arguments) { if (arguments == null) { throw new NativeContractIllegalArgumentException("Must provide xpub and path arguments. None was provided"); } String xpub = (String) arguments[0]; String path = (String) arguments[1]; NetworkPa... |
@Test public void pathCannotBeEmpty() { assertFailsWithMessage(() -> { method.execute(new Object[]{ "tpubD6NzVbkrYhZ4YHQqwWz3Tm1ESZ9AidobeyLG4mEezB6hN8gFFWrcjczyF77Lw3HEs6Rjd2R11BEJ8Y9ptfxx9DFknkdujp58mFMx9H5dc1r", "" }); }, "Invalid path"); } | @Override public Object execute(Object[] arguments) { if (arguments == null) { throw new NativeContractIllegalArgumentException("Must provide xpub and path arguments. None was provided"); } String xpub = (String) arguments[0]; String path = (String) arguments[1]; NetworkParameters params = helper.validateAndExtractNetw... | DeriveExtendedPublicKey extends NativeMethod { @Override public Object execute(Object[] arguments) { if (arguments == null) { throw new NativeContractIllegalArgumentException("Must provide xpub and path arguments. None was provided"); } String xpub = (String) arguments[0]; String path = (String) arguments[1]; NetworkPa... | DeriveExtendedPublicKey extends NativeMethod { @Override public Object execute(Object[] arguments) { if (arguments == null) { throw new NativeContractIllegalArgumentException("Must provide xpub and path arguments. None was provided"); } String xpub = (String) arguments[0]; String path = (String) arguments[1]; NetworkPa... | DeriveExtendedPublicKey extends NativeMethod { @Override public Object execute(Object[] arguments) { if (arguments == null) { throw new NativeContractIllegalArgumentException("Must provide xpub and path arguments. None was provided"); } String xpub = (String) arguments[0]; String path = (String) arguments[1]; NetworkPa... | DeriveExtendedPublicKey extends NativeMethod { @Override public Object execute(Object[] arguments) { if (arguments == null) { throw new NativeContractIllegalArgumentException("Must provide xpub and path arguments. None was provided"); } String xpub = (String) arguments[0]; String path = (String) arguments[1]; NetworkPa... |
@Test public void pathCannotContainALeadingM() { assertFailsWithMessage(() -> { method.execute(new Object[]{ "tpubD6NzVbkrYhZ4YHQqwWz3Tm1ESZ9AidobeyLG4mEezB6hN8gFFWrcjczyF77Lw3HEs6Rjd2R11BEJ8Y9ptfxx9DFknkdujp58mFMx9H5dc1r", "M/0/1/2" }); }, "Invalid path"); } | @Override public Object execute(Object[] arguments) { if (arguments == null) { throw new NativeContractIllegalArgumentException("Must provide xpub and path arguments. None was provided"); } String xpub = (String) arguments[0]; String path = (String) arguments[1]; NetworkParameters params = helper.validateAndExtractNetw... | DeriveExtendedPublicKey extends NativeMethod { @Override public Object execute(Object[] arguments) { if (arguments == null) { throw new NativeContractIllegalArgumentException("Must provide xpub and path arguments. None was provided"); } String xpub = (String) arguments[0]; String path = (String) arguments[1]; NetworkPa... | DeriveExtendedPublicKey extends NativeMethod { @Override public Object execute(Object[] arguments) { if (arguments == null) { throw new NativeContractIllegalArgumentException("Must provide xpub and path arguments. None was provided"); } String xpub = (String) arguments[0]; String path = (String) arguments[1]; NetworkPa... | DeriveExtendedPublicKey extends NativeMethod { @Override public Object execute(Object[] arguments) { if (arguments == null) { throw new NativeContractIllegalArgumentException("Must provide xpub and path arguments. None was provided"); } String xpub = (String) arguments[0]; String path = (String) arguments[1]; NetworkPa... | DeriveExtendedPublicKey extends NativeMethod { @Override public Object execute(Object[] arguments) { if (arguments == null) { throw new NativeContractIllegalArgumentException("Must provide xpub and path arguments. None was provided"); } String xpub = (String) arguments[0]; String path = (String) arguments[1]; NetworkPa... |
@Test public void pathCannotContainALeadingSlash() { assertFailsWithMessage(() -> { method.execute(new Object[]{ "tpubD6NzVbkrYhZ4YHQqwWz3Tm1ESZ9AidobeyLG4mEezB6hN8gFFWrcjczyF77Lw3HEs6Rjd2R11BEJ8Y9ptfxx9DFknkdujp58mFMx9H5dc1r", "/0" }); }, "Invalid path"); } | @Override public Object execute(Object[] arguments) { if (arguments == null) { throw new NativeContractIllegalArgumentException("Must provide xpub and path arguments. None was provided"); } String xpub = (String) arguments[0]; String path = (String) arguments[1]; NetworkParameters params = helper.validateAndExtractNetw... | DeriveExtendedPublicKey extends NativeMethod { @Override public Object execute(Object[] arguments) { if (arguments == null) { throw new NativeContractIllegalArgumentException("Must provide xpub and path arguments. None was provided"); } String xpub = (String) arguments[0]; String path = (String) arguments[1]; NetworkPa... | DeriveExtendedPublicKey extends NativeMethod { @Override public Object execute(Object[] arguments) { if (arguments == null) { throw new NativeContractIllegalArgumentException("Must provide xpub and path arguments. None was provided"); } String xpub = (String) arguments[0]; String path = (String) arguments[1]; NetworkPa... | DeriveExtendedPublicKey extends NativeMethod { @Override public Object execute(Object[] arguments) { if (arguments == null) { throw new NativeContractIllegalArgumentException("Must provide xpub and path arguments. None was provided"); } String xpub = (String) arguments[0]; String path = (String) arguments[1]; NetworkPa... | DeriveExtendedPublicKey extends NativeMethod { @Override public Object execute(Object[] arguments) { if (arguments == null) { throw new NativeContractIllegalArgumentException("Must provide xpub and path arguments. None was provided"); } String xpub = (String) arguments[0]; String path = (String) arguments[1]; NetworkPa... |
@Test public void pathCannotContainATrailingSlash() { assertFailsWithMessage(() -> { method.execute(new Object[]{ "tpubD6NzVbkrYhZ4YHQqwWz3Tm1ESZ9AidobeyLG4mEezB6hN8gFFWrcjczyF77Lw3HEs6Rjd2R11BEJ8Y9ptfxx9DFknkdujp58mFMx9H5dc1r", "0/" }); }, "Invalid path"); } | @Override public Object execute(Object[] arguments) { if (arguments == null) { throw new NativeContractIllegalArgumentException("Must provide xpub and path arguments. None was provided"); } String xpub = (String) arguments[0]; String path = (String) arguments[1]; NetworkParameters params = helper.validateAndExtractNetw... | DeriveExtendedPublicKey extends NativeMethod { @Override public Object execute(Object[] arguments) { if (arguments == null) { throw new NativeContractIllegalArgumentException("Must provide xpub and path arguments. None was provided"); } String xpub = (String) arguments[0]; String path = (String) arguments[1]; NetworkPa... | DeriveExtendedPublicKey extends NativeMethod { @Override public Object execute(Object[] arguments) { if (arguments == null) { throw new NativeContractIllegalArgumentException("Must provide xpub and path arguments. None was provided"); } String xpub = (String) arguments[0]; String path = (String) arguments[1]; NetworkPa... | DeriveExtendedPublicKey extends NativeMethod { @Override public Object execute(Object[] arguments) { if (arguments == null) { throw new NativeContractIllegalArgumentException("Must provide xpub and path arguments. None was provided"); } String xpub = (String) arguments[0]; String path = (String) arguments[1]; NetworkPa... | DeriveExtendedPublicKey extends NativeMethod { @Override public Object execute(Object[] arguments) { if (arguments == null) { throw new NativeContractIllegalArgumentException("Must provide xpub and path arguments. None was provided"); } String xpub = (String) arguments[0]; String path = (String) arguments[1]; NetworkPa... |
@Test public void pathCannotContainHardening() { assertFailsWithMessage(() -> { method.execute(new Object[]{ "tpubD6NzVbkrYhZ4YHQqwWz3Tm1ESZ9AidobeyLG4mEezB6hN8gFFWrcjczyF77Lw3HEs6Rjd2R11BEJ8Y9ptfxx9DFknkdujp58mFMx9H5dc1r", "4'/5" }); }, "Invalid path"); } | @Override public Object execute(Object[] arguments) { if (arguments == null) { throw new NativeContractIllegalArgumentException("Must provide xpub and path arguments. None was provided"); } String xpub = (String) arguments[0]; String path = (String) arguments[1]; NetworkParameters params = helper.validateAndExtractNetw... | DeriveExtendedPublicKey extends NativeMethod { @Override public Object execute(Object[] arguments) { if (arguments == null) { throw new NativeContractIllegalArgumentException("Must provide xpub and path arguments. None was provided"); } String xpub = (String) arguments[0]; String path = (String) arguments[1]; NetworkPa... | DeriveExtendedPublicKey extends NativeMethod { @Override public Object execute(Object[] arguments) { if (arguments == null) { throw new NativeContractIllegalArgumentException("Must provide xpub and path arguments. None was provided"); } String xpub = (String) arguments[0]; String path = (String) arguments[1]; NetworkPa... | DeriveExtendedPublicKey extends NativeMethod { @Override public Object execute(Object[] arguments) { if (arguments == null) { throw new NativeContractIllegalArgumentException("Must provide xpub and path arguments. None was provided"); } String xpub = (String) arguments[0]; String path = (String) arguments[1]; NetworkPa... | DeriveExtendedPublicKey extends NativeMethod { @Override public Object execute(Object[] arguments) { if (arguments == null) { throw new NativeContractIllegalArgumentException("Must provide xpub and path arguments. None was provided"); } String xpub = (String) arguments[0]; String path = (String) arguments[1]; NetworkPa... |
@Test public void testBigIntegerToBytesNegative() { byte[] expecteds = new byte[]{(byte) 0xff, 0x0, 0x13, (byte) 0x88}; BigInteger b = BigInteger.valueOf(-16772216); byte[] actuals = ByteUtil.bigIntegerToBytes(b); assertArrayEquals(expecteds, actuals); } | public static byte[] bigIntegerToBytes(BigInteger b, int numBytes) { if (b == null) { return EMPTY_BYTE_ARRAY; } byte[] bytes = new byte[numBytes]; byte[] biBytes = b.toByteArray(); int start = (biBytes.length == numBytes + 1) ? 1 : 0; int length = Math.min(biBytes.length, numBytes); System.arraycopy(biBytes, start, by... | ByteUtil { public static byte[] bigIntegerToBytes(BigInteger b, int numBytes) { if (b == null) { return EMPTY_BYTE_ARRAY; } byte[] bytes = new byte[numBytes]; byte[] biBytes = b.toByteArray(); int start = (biBytes.length == numBytes + 1) ? 1 : 0; int length = Math.min(biBytes.length, numBytes); System.arraycopy(biBytes... | ByteUtil { public static byte[] bigIntegerToBytes(BigInteger b, int numBytes) { if (b == null) { return EMPTY_BYTE_ARRAY; } byte[] bytes = new byte[numBytes]; byte[] biBytes = b.toByteArray(); int start = (biBytes.length == numBytes + 1) ? 1 : 0; int length = Math.min(biBytes.length, numBytes); System.arraycopy(biBytes... | ByteUtil { public static byte[] bigIntegerToBytes(BigInteger b, int numBytes) { if (b == null) { return EMPTY_BYTE_ARRAY; } byte[] bytes = new byte[numBytes]; byte[] biBytes = b.toByteArray(); int start = (biBytes.length == numBytes + 1) ? 1 : 0; int length = Math.min(biBytes.length, numBytes); System.arraycopy(biBytes... | ByteUtil { public static byte[] bigIntegerToBytes(BigInteger b, int numBytes) { if (b == null) { return EMPTY_BYTE_ARRAY; } byte[] bytes = new byte[numBytes]; byte[] biBytes = b.toByteArray(); int start = (biBytes.length == numBytes + 1) ? 1 : 0; int length = Math.min(biBytes.length, numBytes); System.arraycopy(biBytes... |
@Test public void pathCannotContainNegativeNumbers() { assertFailsWithMessage(() -> { method.execute(new Object[]{ "tpubD6NzVbkrYhZ4YHQqwWz3Tm1ESZ9AidobeyLG4mEezB6hN8gFFWrcjczyF77Lw3HEs6Rjd2R11BEJ8Y9ptfxx9DFknkdujp58mFMx9H5dc1r", "0/-1" }); }, "Invalid path"); } | @Override public Object execute(Object[] arguments) { if (arguments == null) { throw new NativeContractIllegalArgumentException("Must provide xpub and path arguments. None was provided"); } String xpub = (String) arguments[0]; String path = (String) arguments[1]; NetworkParameters params = helper.validateAndExtractNetw... | DeriveExtendedPublicKey extends NativeMethod { @Override public Object execute(Object[] arguments) { if (arguments == null) { throw new NativeContractIllegalArgumentException("Must provide xpub and path arguments. None was provided"); } String xpub = (String) arguments[0]; String path = (String) arguments[1]; NetworkPa... | DeriveExtendedPublicKey extends NativeMethod { @Override public Object execute(Object[] arguments) { if (arguments == null) { throw new NativeContractIllegalArgumentException("Must provide xpub and path arguments. None was provided"); } String xpub = (String) arguments[0]; String path = (String) arguments[1]; NetworkPa... | DeriveExtendedPublicKey extends NativeMethod { @Override public Object execute(Object[] arguments) { if (arguments == null) { throw new NativeContractIllegalArgumentException("Must provide xpub and path arguments. None was provided"); } String xpub = (String) arguments[0]; String path = (String) arguments[1]; NetworkPa... | DeriveExtendedPublicKey extends NativeMethod { @Override public Object execute(Object[] arguments) { if (arguments == null) { throw new NativeContractIllegalArgumentException("Must provide xpub and path arguments. None was provided"); } String xpub = (String) arguments[0]; String path = (String) arguments[1]; NetworkPa... |
@Test public void pathCannotContainPartsBiggerOrEqualThan2Pwr31() { assertFailsWithMessage(() -> { method.execute(new Object[]{ "tpubD6NzVbkrYhZ4YHQqwWz3Tm1ESZ9AidobeyLG4mEezB6hN8gFFWrcjczyF77Lw3HEs6Rjd2R11BEJ8Y9ptfxx9DFknkdujp58mFMx9H5dc1r", "0/1/2/2147483648" }); }, "Invalid path"); } | @Override public Object execute(Object[] arguments) { if (arguments == null) { throw new NativeContractIllegalArgumentException("Must provide xpub and path arguments. None was provided"); } String xpub = (String) arguments[0]; String path = (String) arguments[1]; NetworkParameters params = helper.validateAndExtractNetw... | DeriveExtendedPublicKey extends NativeMethod { @Override public Object execute(Object[] arguments) { if (arguments == null) { throw new NativeContractIllegalArgumentException("Must provide xpub and path arguments. None was provided"); } String xpub = (String) arguments[0]; String path = (String) arguments[1]; NetworkPa... | DeriveExtendedPublicKey extends NativeMethod { @Override public Object execute(Object[] arguments) { if (arguments == null) { throw new NativeContractIllegalArgumentException("Must provide xpub and path arguments. None was provided"); } String xpub = (String) arguments[0]; String path = (String) arguments[1]; NetworkPa... | DeriveExtendedPublicKey extends NativeMethod { @Override public Object execute(Object[] arguments) { if (arguments == null) { throw new NativeContractIllegalArgumentException("Must provide xpub and path arguments. None was provided"); } String xpub = (String) arguments[0]; String path = (String) arguments[1]; NetworkPa... | DeriveExtendedPublicKey extends NativeMethod { @Override public Object execute(Object[] arguments) { if (arguments == null) { throw new NativeContractIllegalArgumentException("Must provide xpub and path arguments. None was provided"); } String xpub = (String) arguments[0]; String path = (String) arguments[1]; NetworkPa... |
@Test public void pathCannotContainMoreThanTenParts() { assertFailsWithMessage(() -> { method.execute(new Object[]{ "tpubD6NzVbkrYhZ4YHQqwWz3Tm1ESZ9AidobeyLG4mEezB6hN8gFFWrcjczyF77Lw3HEs6Rjd2R11BEJ8Y9ptfxx9DFknkdujp58mFMx9H5dc1r", "0/1/2/3/4/5/6/7/8/9/10" }); }, "Path should contain 10 levels at most"); } | @Override public Object execute(Object[] arguments) { if (arguments == null) { throw new NativeContractIllegalArgumentException("Must provide xpub and path arguments. None was provided"); } String xpub = (String) arguments[0]; String path = (String) arguments[1]; NetworkParameters params = helper.validateAndExtractNetw... | DeriveExtendedPublicKey extends NativeMethod { @Override public Object execute(Object[] arguments) { if (arguments == null) { throw new NativeContractIllegalArgumentException("Must provide xpub and path arguments. None was provided"); } String xpub = (String) arguments[0]; String path = (String) arguments[1]; NetworkPa... | DeriveExtendedPublicKey extends NativeMethod { @Override public Object execute(Object[] arguments) { if (arguments == null) { throw new NativeContractIllegalArgumentException("Must provide xpub and path arguments. None was provided"); } String xpub = (String) arguments[0]; String path = (String) arguments[1]; NetworkPa... | DeriveExtendedPublicKey extends NativeMethod { @Override public Object execute(Object[] arguments) { if (arguments == null) { throw new NativeContractIllegalArgumentException("Must provide xpub and path arguments. None was provided"); } String xpub = (String) arguments[0]; String path = (String) arguments[1]; NetworkPa... | DeriveExtendedPublicKey extends NativeMethod { @Override public Object execute(Object[] arguments) { if (arguments == null) { throw new NativeContractIllegalArgumentException("Must provide xpub and path arguments. None was provided"); } String xpub = (String) arguments[0]; String path = (String) arguments[1]; NetworkPa... |
@Test public void gasIsCorrect() { Assert.assertEquals(107_000, method.getGas(new Object[]{ "tpubD6NzVbkrYhZ4YHQqwWz3Tm1ESZ9AidobeyLG4mEezB6hN8gFFWrcjczyF77Lw3HEs6Rjd2R11BEJ8Y9ptfxx9DFknkdujp58mFMx9H5dc1r", "2/3/4" }, new byte[]{})); } | @Override public long getGas(Object[] parsedArguments, byte[] originalData) { return 107_000L; } | DeriveExtendedPublicKey extends NativeMethod { @Override public long getGas(Object[] parsedArguments, byte[] originalData) { return 107_000L; } } | DeriveExtendedPublicKey extends NativeMethod { @Override public long getGas(Object[] parsedArguments, byte[] originalData) { return 107_000L; } DeriveExtendedPublicKey(ExecutionEnvironment executionEnvironment, HDWalletUtilsHelper helper); } | DeriveExtendedPublicKey extends NativeMethod { @Override public long getGas(Object[] parsedArguments, byte[] originalData) { return 107_000L; } DeriveExtendedPublicKey(ExecutionEnvironment executionEnvironment, HDWalletUtilsHelper helper); @Override CallTransaction.Function getFunction(); @Override Object execute(Objec... | DeriveExtendedPublicKey extends NativeMethod { @Override public long getGas(Object[] parsedArguments, byte[] originalData) { return 107_000L; } DeriveExtendedPublicKey(ExecutionEnvironment executionEnvironment, HDWalletUtilsHelper helper); @Override CallTransaction.Function getFunction(); @Override Object execute(Objec... |
@Test public void validateAndExtractNetworkFromExtendedPublicKeyMainnet() { Assert.assertEquals( NetworkParameters.fromID(NetworkParameters.ID_MAINNET), helper.validateAndExtractNetworkFromExtendedPublicKey("xpubSomethingSomething") ); } | public NetworkParameters validateAndExtractNetworkFromExtendedPublicKey(String xpub) { if (xpub == null) { throw new NativeContractIllegalArgumentException(String.format("Invalid extended public key '%s'", xpub)); } if (xpub.startsWith("xpub")) { return NetworkParameters.fromID(NetworkParameters.ID_MAINNET); } else if ... | HDWalletUtilsHelper { public NetworkParameters validateAndExtractNetworkFromExtendedPublicKey(String xpub) { if (xpub == null) { throw new NativeContractIllegalArgumentException(String.format("Invalid extended public key '%s'", xpub)); } if (xpub.startsWith("xpub")) { return NetworkParameters.fromID(NetworkParameters.I... | HDWalletUtilsHelper { public NetworkParameters validateAndExtractNetworkFromExtendedPublicKey(String xpub) { if (xpub == null) { throw new NativeContractIllegalArgumentException(String.format("Invalid extended public key '%s'", xpub)); } if (xpub.startsWith("xpub")) { return NetworkParameters.fromID(NetworkParameters.I... | HDWalletUtilsHelper { public NetworkParameters validateAndExtractNetworkFromExtendedPublicKey(String xpub) { if (xpub == null) { throw new NativeContractIllegalArgumentException(String.format("Invalid extended public key '%s'", xpub)); } if (xpub.startsWith("xpub")) { return NetworkParameters.fromID(NetworkParameters.I... | HDWalletUtilsHelper { public NetworkParameters validateAndExtractNetworkFromExtendedPublicKey(String xpub) { if (xpub == null) { throw new NativeContractIllegalArgumentException(String.format("Invalid extended public key '%s'", xpub)); } if (xpub.startsWith("xpub")) { return NetworkParameters.fromID(NetworkParameters.I... |
@Test public void validateAndExtractNetworkFromExtendedPublicKeyTestnet() { Assert.assertEquals( NetworkParameters.fromID(NetworkParameters.ID_TESTNET), helper.validateAndExtractNetworkFromExtendedPublicKey("tpubSomethingSomething") ); } | public NetworkParameters validateAndExtractNetworkFromExtendedPublicKey(String xpub) { if (xpub == null) { throw new NativeContractIllegalArgumentException(String.format("Invalid extended public key '%s'", xpub)); } if (xpub.startsWith("xpub")) { return NetworkParameters.fromID(NetworkParameters.ID_MAINNET); } else if ... | HDWalletUtilsHelper { public NetworkParameters validateAndExtractNetworkFromExtendedPublicKey(String xpub) { if (xpub == null) { throw new NativeContractIllegalArgumentException(String.format("Invalid extended public key '%s'", xpub)); } if (xpub.startsWith("xpub")) { return NetworkParameters.fromID(NetworkParameters.I... | HDWalletUtilsHelper { public NetworkParameters validateAndExtractNetworkFromExtendedPublicKey(String xpub) { if (xpub == null) { throw new NativeContractIllegalArgumentException(String.format("Invalid extended public key '%s'", xpub)); } if (xpub.startsWith("xpub")) { return NetworkParameters.fromID(NetworkParameters.I... | HDWalletUtilsHelper { public NetworkParameters validateAndExtractNetworkFromExtendedPublicKey(String xpub) { if (xpub == null) { throw new NativeContractIllegalArgumentException(String.format("Invalid extended public key '%s'", xpub)); } if (xpub.startsWith("xpub")) { return NetworkParameters.fromID(NetworkParameters.I... | HDWalletUtilsHelper { public NetworkParameters validateAndExtractNetworkFromExtendedPublicKey(String xpub) { if (xpub == null) { throw new NativeContractIllegalArgumentException(String.format("Invalid extended public key '%s'", xpub)); } if (xpub.startsWith("xpub")) { return NetworkParameters.fromID(NetworkParameters.I... |
@Test(expected = NativeContractIllegalArgumentException.class) public void validateAndExtractNetworkFromExtendedPublicKeyInvalid() { helper.validateAndExtractNetworkFromExtendedPublicKey("completelyInvalidStuff"); } | public NetworkParameters validateAndExtractNetworkFromExtendedPublicKey(String xpub) { if (xpub == null) { throw new NativeContractIllegalArgumentException(String.format("Invalid extended public key '%s'", xpub)); } if (xpub.startsWith("xpub")) { return NetworkParameters.fromID(NetworkParameters.ID_MAINNET); } else if ... | HDWalletUtilsHelper { public NetworkParameters validateAndExtractNetworkFromExtendedPublicKey(String xpub) { if (xpub == null) { throw new NativeContractIllegalArgumentException(String.format("Invalid extended public key '%s'", xpub)); } if (xpub.startsWith("xpub")) { return NetworkParameters.fromID(NetworkParameters.I... | HDWalletUtilsHelper { public NetworkParameters validateAndExtractNetworkFromExtendedPublicKey(String xpub) { if (xpub == null) { throw new NativeContractIllegalArgumentException(String.format("Invalid extended public key '%s'", xpub)); } if (xpub.startsWith("xpub")) { return NetworkParameters.fromID(NetworkParameters.I... | HDWalletUtilsHelper { public NetworkParameters validateAndExtractNetworkFromExtendedPublicKey(String xpub) { if (xpub == null) { throw new NativeContractIllegalArgumentException(String.format("Invalid extended public key '%s'", xpub)); } if (xpub.startsWith("xpub")) { return NetworkParameters.fromID(NetworkParameters.I... | HDWalletUtilsHelper { public NetworkParameters validateAndExtractNetworkFromExtendedPublicKey(String xpub) { if (xpub == null) { throw new NativeContractIllegalArgumentException(String.format("Invalid extended public key '%s'", xpub)); } if (xpub.startsWith("xpub")) { return NetworkParameters.fromID(NetworkParameters.I... |
@Test public void functionSignatureOk() { CallTransaction.Function fn = method.getFunction(); Assert.assertEquals("toBase58Check", fn.name); Assert.assertEquals(2, fn.inputs.length); Assert.assertEquals(SolidityType.getType("bytes").getName(), fn.inputs[0].type.getName()); Assert.assertEquals(SolidityType.getType("int2... | @Override public CallTransaction.Function getFunction() { return function; } | ToBase58Check extends NativeMethod { @Override public CallTransaction.Function getFunction() { return function; } } | ToBase58Check extends NativeMethod { @Override public CallTransaction.Function getFunction() { return function; } ToBase58Check(ExecutionEnvironment executionEnvironment); } | ToBase58Check extends NativeMethod { @Override public CallTransaction.Function getFunction() { return function; } ToBase58Check(ExecutionEnvironment executionEnvironment); @Override CallTransaction.Function getFunction(); @Override Object execute(Object[] arguments); @Override boolean isEnabled(); @Override boolean onl... | ToBase58Check extends NativeMethod { @Override public CallTransaction.Function getFunction() { return function; } ToBase58Check(ExecutionEnvironment executionEnvironment); @Override CallTransaction.Function getFunction(); @Override Object execute(Object[] arguments); @Override boolean isEnabled(); @Override boolean onl... |
@Test public void shouldBeEnabled() { Assert.assertTrue(method.isEnabled()); } | @Override public boolean isEnabled() { return true; } | ToBase58Check extends NativeMethod { @Override public boolean isEnabled() { return true; } } | ToBase58Check extends NativeMethod { @Override public boolean isEnabled() { return true; } ToBase58Check(ExecutionEnvironment executionEnvironment); } | ToBase58Check extends NativeMethod { @Override public boolean isEnabled() { return true; } ToBase58Check(ExecutionEnvironment executionEnvironment); @Override CallTransaction.Function getFunction(); @Override Object execute(Object[] arguments); @Override boolean isEnabled(); @Override boolean onlyAllowsLocalCalls(); @O... | ToBase58Check extends NativeMethod { @Override public boolean isEnabled() { return true; } ToBase58Check(ExecutionEnvironment executionEnvironment); @Override CallTransaction.Function getFunction(); @Override Object execute(Object[] arguments); @Override boolean isEnabled(); @Override boolean onlyAllowsLocalCalls(); @O... |
@Test public void shouldAllowAnyTypeOfCall() { Assert.assertFalse(method.onlyAllowsLocalCalls()); } | @Override public boolean onlyAllowsLocalCalls() { return false; } | ToBase58Check extends NativeMethod { @Override public boolean onlyAllowsLocalCalls() { return false; } } | ToBase58Check extends NativeMethod { @Override public boolean onlyAllowsLocalCalls() { return false; } ToBase58Check(ExecutionEnvironment executionEnvironment); } | ToBase58Check extends NativeMethod { @Override public boolean onlyAllowsLocalCalls() { return false; } ToBase58Check(ExecutionEnvironment executionEnvironment); @Override CallTransaction.Function getFunction(); @Override Object execute(Object[] arguments); @Override boolean isEnabled(); @Override boolean onlyAllowsLoca... | ToBase58Check extends NativeMethod { @Override public boolean onlyAllowsLocalCalls() { return false; } ToBase58Check(ExecutionEnvironment executionEnvironment); @Override CallTransaction.Function getFunction(); @Override Object execute(Object[] arguments); @Override boolean isEnabled(); @Override boolean onlyAllowsLoca... |
@Test public void testBigIntegerToBytesZero() { byte[] expecteds = new byte[]{0x00}; BigInteger b = BigInteger.ZERO; byte[] actuals = ByteUtil.bigIntegerToBytes(b); assertArrayEquals(expecteds, actuals); } | public static byte[] bigIntegerToBytes(BigInteger b, int numBytes) { if (b == null) { return EMPTY_BYTE_ARRAY; } byte[] bytes = new byte[numBytes]; byte[] biBytes = b.toByteArray(); int start = (biBytes.length == numBytes + 1) ? 1 : 0; int length = Math.min(biBytes.length, numBytes); System.arraycopy(biBytes, start, by... | ByteUtil { public static byte[] bigIntegerToBytes(BigInteger b, int numBytes) { if (b == null) { return EMPTY_BYTE_ARRAY; } byte[] bytes = new byte[numBytes]; byte[] biBytes = b.toByteArray(); int start = (biBytes.length == numBytes + 1) ? 1 : 0; int length = Math.min(biBytes.length, numBytes); System.arraycopy(biBytes... | ByteUtil { public static byte[] bigIntegerToBytes(BigInteger b, int numBytes) { if (b == null) { return EMPTY_BYTE_ARRAY; } byte[] bytes = new byte[numBytes]; byte[] biBytes = b.toByteArray(); int start = (biBytes.length == numBytes + 1) ? 1 : 0; int length = Math.min(biBytes.length, numBytes); System.arraycopy(biBytes... | ByteUtil { public static byte[] bigIntegerToBytes(BigInteger b, int numBytes) { if (b == null) { return EMPTY_BYTE_ARRAY; } byte[] bytes = new byte[numBytes]; byte[] biBytes = b.toByteArray(); int start = (biBytes.length == numBytes + 1) ? 1 : 0; int length = Math.min(biBytes.length, numBytes); System.arraycopy(biBytes... | ByteUtil { public static byte[] bigIntegerToBytes(BigInteger b, int numBytes) { if (b == null) { return EMPTY_BYTE_ARRAY; } byte[] bytes = new byte[numBytes]; byte[] biBytes = b.toByteArray(); int start = (biBytes.length == numBytes + 1) ? 1 : 0; int length = Math.min(biBytes.length, numBytes); System.arraycopy(biBytes... |
@Test public void executes() { Assert.assertEquals( "mgivuh9jErcGdRr81cJ3A7YfgbJV7WNyZV", method.execute(new Object[]{ Hex.decode("0d3bf5f30dda7584645546079318e97f0e1d044f"), BigInteger.valueOf(111L) })); } | @Override public Object execute(Object[] arguments) { if (arguments == null) { throw new NativeContractIllegalArgumentException(HASH_NOT_PRESENT); } byte[] hash = (byte[]) arguments[0]; if (hash == null) { throw new NativeContractIllegalArgumentException(HASH_NOT_PRESENT); } if (hash.length != 20) { throw new NativeCon... | ToBase58Check extends NativeMethod { @Override public Object execute(Object[] arguments) { if (arguments == null) { throw new NativeContractIllegalArgumentException(HASH_NOT_PRESENT); } byte[] hash = (byte[]) arguments[0]; if (hash == null) { throw new NativeContractIllegalArgumentException(HASH_NOT_PRESENT); } if (has... | ToBase58Check extends NativeMethod { @Override public Object execute(Object[] arguments) { if (arguments == null) { throw new NativeContractIllegalArgumentException(HASH_NOT_PRESENT); } byte[] hash = (byte[]) arguments[0]; if (hash == null) { throw new NativeContractIllegalArgumentException(HASH_NOT_PRESENT); } if (has... | ToBase58Check extends NativeMethod { @Override public Object execute(Object[] arguments) { if (arguments == null) { throw new NativeContractIllegalArgumentException(HASH_NOT_PRESENT); } byte[] hash = (byte[]) arguments[0]; if (hash == null) { throw new NativeContractIllegalArgumentException(HASH_NOT_PRESENT); } if (has... | ToBase58Check extends NativeMethod { @Override public Object execute(Object[] arguments) { if (arguments == null) { throw new NativeContractIllegalArgumentException(HASH_NOT_PRESENT); } byte[] hash = (byte[]) arguments[0]; if (hash == null) { throw new NativeContractIllegalArgumentException(HASH_NOT_PRESENT); } if (has... |
@Test public void validatesHashPresence() { try { method.execute(new Object[]{ Hex.decode("aabbcc"), BigInteger.valueOf(111L) }); Assert.fail(); } catch (NativeContractIllegalArgumentException e) { Assert.assertTrue(e.getMessage().contains("Invalid hash160")); } } | @Override public Object execute(Object[] arguments) { if (arguments == null) { throw new NativeContractIllegalArgumentException(HASH_NOT_PRESENT); } byte[] hash = (byte[]) arguments[0]; if (hash == null) { throw new NativeContractIllegalArgumentException(HASH_NOT_PRESENT); } if (hash.length != 20) { throw new NativeCon... | ToBase58Check extends NativeMethod { @Override public Object execute(Object[] arguments) { if (arguments == null) { throw new NativeContractIllegalArgumentException(HASH_NOT_PRESENT); } byte[] hash = (byte[]) arguments[0]; if (hash == null) { throw new NativeContractIllegalArgumentException(HASH_NOT_PRESENT); } if (has... | ToBase58Check extends NativeMethod { @Override public Object execute(Object[] arguments) { if (arguments == null) { throw new NativeContractIllegalArgumentException(HASH_NOT_PRESENT); } byte[] hash = (byte[]) arguments[0]; if (hash == null) { throw new NativeContractIllegalArgumentException(HASH_NOT_PRESENT); } if (has... | ToBase58Check extends NativeMethod { @Override public Object execute(Object[] arguments) { if (arguments == null) { throw new NativeContractIllegalArgumentException(HASH_NOT_PRESENT); } byte[] hash = (byte[]) arguments[0]; if (hash == null) { throw new NativeContractIllegalArgumentException(HASH_NOT_PRESENT); } if (has... | ToBase58Check extends NativeMethod { @Override public Object execute(Object[] arguments) { if (arguments == null) { throw new NativeContractIllegalArgumentException(HASH_NOT_PRESENT); } byte[] hash = (byte[]) arguments[0]; if (hash == null) { throw new NativeContractIllegalArgumentException(HASH_NOT_PRESENT); } if (has... |
@Test public void validatesHashLength() { try { method.execute(new Object[]{ Hex.decode("aabbcc"), BigInteger.valueOf(111L) }); Assert.fail(); } catch (NativeContractIllegalArgumentException e) { Assert.assertTrue(e.getMessage().contains("Invalid hash160")); } } | @Override public Object execute(Object[] arguments) { if (arguments == null) { throw new NativeContractIllegalArgumentException(HASH_NOT_PRESENT); } byte[] hash = (byte[]) arguments[0]; if (hash == null) { throw new NativeContractIllegalArgumentException(HASH_NOT_PRESENT); } if (hash.length != 20) { throw new NativeCon... | ToBase58Check extends NativeMethod { @Override public Object execute(Object[] arguments) { if (arguments == null) { throw new NativeContractIllegalArgumentException(HASH_NOT_PRESENT); } byte[] hash = (byte[]) arguments[0]; if (hash == null) { throw new NativeContractIllegalArgumentException(HASH_NOT_PRESENT); } if (has... | ToBase58Check extends NativeMethod { @Override public Object execute(Object[] arguments) { if (arguments == null) { throw new NativeContractIllegalArgumentException(HASH_NOT_PRESENT); } byte[] hash = (byte[]) arguments[0]; if (hash == null) { throw new NativeContractIllegalArgumentException(HASH_NOT_PRESENT); } if (has... | ToBase58Check extends NativeMethod { @Override public Object execute(Object[] arguments) { if (arguments == null) { throw new NativeContractIllegalArgumentException(HASH_NOT_PRESENT); } byte[] hash = (byte[]) arguments[0]; if (hash == null) { throw new NativeContractIllegalArgumentException(HASH_NOT_PRESENT); } if (has... | ToBase58Check extends NativeMethod { @Override public Object execute(Object[] arguments) { if (arguments == null) { throw new NativeContractIllegalArgumentException(HASH_NOT_PRESENT); } byte[] hash = (byte[]) arguments[0]; if (hash == null) { throw new NativeContractIllegalArgumentException(HASH_NOT_PRESENT); } if (has... |
@Test public void validatesVersion() { try { method.execute(new Object[]{ Hex.decode("0d3bf5f30dda7584645546079318e97f0e1d044f"), BigInteger.valueOf(-1L) }); Assert.fail(); } catch (NativeContractIllegalArgumentException e) { Assert.assertTrue(e.getMessage().contains("version must be a numeric value between 0 and 255")... | @Override public Object execute(Object[] arguments) { if (arguments == null) { throw new NativeContractIllegalArgumentException(HASH_NOT_PRESENT); } byte[] hash = (byte[]) arguments[0]; if (hash == null) { throw new NativeContractIllegalArgumentException(HASH_NOT_PRESENT); } if (hash.length != 20) { throw new NativeCon... | ToBase58Check extends NativeMethod { @Override public Object execute(Object[] arguments) { if (arguments == null) { throw new NativeContractIllegalArgumentException(HASH_NOT_PRESENT); } byte[] hash = (byte[]) arguments[0]; if (hash == null) { throw new NativeContractIllegalArgumentException(HASH_NOT_PRESENT); } if (has... | ToBase58Check extends NativeMethod { @Override public Object execute(Object[] arguments) { if (arguments == null) { throw new NativeContractIllegalArgumentException(HASH_NOT_PRESENT); } byte[] hash = (byte[]) arguments[0]; if (hash == null) { throw new NativeContractIllegalArgumentException(HASH_NOT_PRESENT); } if (has... | ToBase58Check extends NativeMethod { @Override public Object execute(Object[] arguments) { if (arguments == null) { throw new NativeContractIllegalArgumentException(HASH_NOT_PRESENT); } byte[] hash = (byte[]) arguments[0]; if (hash == null) { throw new NativeContractIllegalArgumentException(HASH_NOT_PRESENT); } if (has... | ToBase58Check extends NativeMethod { @Override public Object execute(Object[] arguments) { if (arguments == null) { throw new NativeContractIllegalArgumentException(HASH_NOT_PRESENT); } byte[] hash = (byte[]) arguments[0]; if (hash == null) { throw new NativeContractIllegalArgumentException(HASH_NOT_PRESENT); } if (has... |
@Test public void gasIsCorrect() { Assert.assertEquals(13_000, method.getGas(new Object[]{ Hex.decode("0d3bf5f30dda7584645546079318e97f0e1d044f"), BigInteger.valueOf(111L) }, new byte[]{})); } | @Override public long getGas(Object[] parsedArguments, byte[] originalData) { return 13_000L; } | ToBase58Check extends NativeMethod { @Override public long getGas(Object[] parsedArguments, byte[] originalData) { return 13_000L; } } | ToBase58Check extends NativeMethod { @Override public long getGas(Object[] parsedArguments, byte[] originalData) { return 13_000L; } ToBase58Check(ExecutionEnvironment executionEnvironment); } | ToBase58Check extends NativeMethod { @Override public long getGas(Object[] parsedArguments, byte[] originalData) { return 13_000L; } ToBase58Check(ExecutionEnvironment executionEnvironment); @Override CallTransaction.Function getFunction(); @Override Object execute(Object[] arguments); @Override boolean isEnabled(); @O... | ToBase58Check extends NativeMethod { @Override public long getGas(Object[] parsedArguments, byte[] originalData) { return 13_000L; } ToBase58Check(ExecutionEnvironment executionEnvironment); @Override CallTransaction.Function getFunction(); @Override Object execute(Object[] arguments); @Override boolean isEnabled(); @O... |
@Test public void hasNoDefaultMethod() { Assert.assertFalse(contract.getDefaultMethod().isPresent()); } | @Override public Optional<NativeMethod> getDefaultMethod() { return Optional.empty(); } | HDWalletUtils extends NativeContract { @Override public Optional<NativeMethod> getDefaultMethod() { return Optional.empty(); } } | HDWalletUtils extends NativeContract { @Override public Optional<NativeMethod> getDefaultMethod() { return Optional.empty(); } HDWalletUtils(ActivationConfig config, RskAddress contractAddress); } | HDWalletUtils extends NativeContract { @Override public Optional<NativeMethod> getDefaultMethod() { return Optional.empty(); } HDWalletUtils(ActivationConfig config, RskAddress contractAddress); @Override List<NativeMethod> getMethods(); @Override Optional<NativeMethod> getDefaultMethod(); } | HDWalletUtils extends NativeContract { @Override public Optional<NativeMethod> getDefaultMethod() { return Optional.empty(); } HDWalletUtils(ActivationConfig config, RskAddress contractAddress); @Override List<NativeMethod> getMethods(); @Override Optional<NativeMethod> getDefaultMethod(); } |
@Test public void hasFourMethods() { Assert.assertEquals(4, contract.getMethods().size()); } | @Override public List<NativeMethod> getMethods() { return Arrays.asList( new ToBase58Check(getExecutionEnvironment()), new DeriveExtendedPublicKey(getExecutionEnvironment(), helper), new ExtractPublicKeyFromExtendedPublicKey(getExecutionEnvironment(), helper), new GetMultisigScriptHash(getExecutionEnvironment()) ); } | HDWalletUtils extends NativeContract { @Override public List<NativeMethod> getMethods() { return Arrays.asList( new ToBase58Check(getExecutionEnvironment()), new DeriveExtendedPublicKey(getExecutionEnvironment(), helper), new ExtractPublicKeyFromExtendedPublicKey(getExecutionEnvironment(), helper), new GetMultisigScrip... | HDWalletUtils extends NativeContract { @Override public List<NativeMethod> getMethods() { return Arrays.asList( new ToBase58Check(getExecutionEnvironment()), new DeriveExtendedPublicKey(getExecutionEnvironment(), helper), new ExtractPublicKeyFromExtendedPublicKey(getExecutionEnvironment(), helper), new GetMultisigScrip... | HDWalletUtils extends NativeContract { @Override public List<NativeMethod> getMethods() { return Arrays.asList( new ToBase58Check(getExecutionEnvironment()), new DeriveExtendedPublicKey(getExecutionEnvironment(), helper), new ExtractPublicKeyFromExtendedPublicKey(getExecutionEnvironment(), helper), new GetMultisigScrip... | HDWalletUtils extends NativeContract { @Override public List<NativeMethod> getMethods() { return Arrays.asList( new ToBase58Check(getExecutionEnvironment()), new DeriveExtendedPublicKey(getExecutionEnvironment(), helper), new ExtractPublicKeyFromExtendedPublicKey(getExecutionEnvironment(), helper), new GetMultisigScrip... |
@Test public void getBlockBeyondMaximumBlockDepth() { executionEnvironment = mock(ExecutionEnvironment.class); Assert.assertFalse(blockAccessor.getBlock(MAXIMUM_BLOCK_DEPTH, executionEnvironment).isPresent()); Assert.assertFalse(blockAccessor.getBlock((short) (MAXIMUM_BLOCK_DEPTH + 1), executionEnvironment).isPresent()... | public Optional<Block> getBlock(short blockDepth, ExecutionEnvironment environment) { if (blockDepth < 0) { throw new NativeContractIllegalArgumentException(String.format( "Invalid block depth '%d' (should be a non-negative value)", blockDepth )); } if (blockDepth >= maximumBlockDepth) { return Optional.empty(); } Bloc... | BlockAccessor { public Optional<Block> getBlock(short blockDepth, ExecutionEnvironment environment) { if (blockDepth < 0) { throw new NativeContractIllegalArgumentException(String.format( "Invalid block depth '%d' (should be a non-negative value)", blockDepth )); } if (blockDepth >= maximumBlockDepth) { return Optional... | BlockAccessor { public Optional<Block> getBlock(short blockDepth, ExecutionEnvironment environment) { if (blockDepth < 0) { throw new NativeContractIllegalArgumentException(String.format( "Invalid block depth '%d' (should be a non-negative value)", blockDepth )); } if (blockDepth >= maximumBlockDepth) { return Optional... | BlockAccessor { public Optional<Block> getBlock(short blockDepth, ExecutionEnvironment environment) { if (blockDepth < 0) { throw new NativeContractIllegalArgumentException(String.format( "Invalid block depth '%d' (should be a non-negative value)", blockDepth )); } if (blockDepth >= maximumBlockDepth) { return Optional... | BlockAccessor { public Optional<Block> getBlock(short blockDepth, ExecutionEnvironment environment) { if (blockDepth < 0) { throw new NativeContractIllegalArgumentException(String.format( "Invalid block depth '%d' (should be a non-negative value)", blockDepth )); } if (blockDepth >= maximumBlockDepth) { return Optional... |
@Test(expected = NativeContractIllegalArgumentException.class) public void getBlockWithNegativeDepth() { executionEnvironment = mock(ExecutionEnvironment.class); blockAccessor.getBlock(NEGATIVE_BLOCK_DEPTH, executionEnvironment); } | public Optional<Block> getBlock(short blockDepth, ExecutionEnvironment environment) { if (blockDepth < 0) { throw new NativeContractIllegalArgumentException(String.format( "Invalid block depth '%d' (should be a non-negative value)", blockDepth )); } if (blockDepth >= maximumBlockDepth) { return Optional.empty(); } Bloc... | BlockAccessor { public Optional<Block> getBlock(short blockDepth, ExecutionEnvironment environment) { if (blockDepth < 0) { throw new NativeContractIllegalArgumentException(String.format( "Invalid block depth '%d' (should be a non-negative value)", blockDepth )); } if (blockDepth >= maximumBlockDepth) { return Optional... | BlockAccessor { public Optional<Block> getBlock(short blockDepth, ExecutionEnvironment environment) { if (blockDepth < 0) { throw new NativeContractIllegalArgumentException(String.format( "Invalid block depth '%d' (should be a non-negative value)", blockDepth )); } if (blockDepth >= maximumBlockDepth) { return Optional... | BlockAccessor { public Optional<Block> getBlock(short blockDepth, ExecutionEnvironment environment) { if (blockDepth < 0) { throw new NativeContractIllegalArgumentException(String.format( "Invalid block depth '%d' (should be a non-negative value)", blockDepth )); } if (blockDepth >= maximumBlockDepth) { return Optional... | BlockAccessor { public Optional<Block> getBlock(short blockDepth, ExecutionEnvironment environment) { if (blockDepth < 0) { throw new NativeContractIllegalArgumentException(String.format( "Invalid block depth '%d' (should be a non-negative value)", blockDepth )); } if (blockDepth >= maximumBlockDepth) { return Optional... |
@Test public void getGenesisBlock() { ExecutionEnvironment executionEnvironment = EnvironmentUtils.getEnvironmentWithBlockchainOfLength(1); Optional<Block> genesis = blockAccessor.getBlock(ZERO_BLOCK_DEPTH, executionEnvironment); Optional<Block> firstBlock = blockAccessor.getBlock(ONE_BLOCK_DEPTH, executionEnvironment)... | public Optional<Block> getBlock(short blockDepth, ExecutionEnvironment environment) { if (blockDepth < 0) { throw new NativeContractIllegalArgumentException(String.format( "Invalid block depth '%d' (should be a non-negative value)", blockDepth )); } if (blockDepth >= maximumBlockDepth) { return Optional.empty(); } Bloc... | BlockAccessor { public Optional<Block> getBlock(short blockDepth, ExecutionEnvironment environment) { if (blockDepth < 0) { throw new NativeContractIllegalArgumentException(String.format( "Invalid block depth '%d' (should be a non-negative value)", blockDepth )); } if (blockDepth >= maximumBlockDepth) { return Optional... | BlockAccessor { public Optional<Block> getBlock(short blockDepth, ExecutionEnvironment environment) { if (blockDepth < 0) { throw new NativeContractIllegalArgumentException(String.format( "Invalid block depth '%d' (should be a non-negative value)", blockDepth )); } if (blockDepth >= maximumBlockDepth) { return Optional... | BlockAccessor { public Optional<Block> getBlock(short blockDepth, ExecutionEnvironment environment) { if (blockDepth < 0) { throw new NativeContractIllegalArgumentException(String.format( "Invalid block depth '%d' (should be a non-negative value)", blockDepth )); } if (blockDepth >= maximumBlockDepth) { return Optional... | BlockAccessor { public Optional<Block> getBlock(short blockDepth, ExecutionEnvironment environment) { if (blockDepth < 0) { throw new NativeContractIllegalArgumentException(String.format( "Invalid block depth '%d' (should be a non-negative value)", blockDepth )); } if (blockDepth >= maximumBlockDepth) { return Optional... |
@Test public void testToHexString_ProducedHex() { byte[] data = new byte[] {(byte) 0xff, 0x0, 0x13, (byte) 0x88}; assertEquals(Hex.toHexString(data), ByteUtil.toHexString(data)); } | @Nonnull public static String toHexString(@Nonnull byte[] data) { return Hex.toHexString(Objects.requireNonNull(data)); } | ByteUtil { @Nonnull public static String toHexString(@Nonnull byte[] data) { return Hex.toHexString(Objects.requireNonNull(data)); } } | ByteUtil { @Nonnull public static String toHexString(@Nonnull byte[] data) { return Hex.toHexString(Objects.requireNonNull(data)); } private ByteUtil(); } | ByteUtil { @Nonnull public static String toHexString(@Nonnull byte[] data) { return Hex.toHexString(Objects.requireNonNull(data)); } private ByteUtil(); static byte[] appendByte(byte[] bytes, byte b); static byte[] cloneBytes(byte[] bytes); static byte[] bigIntegerToBytes(BigInteger b, int numBytes); static byte[] big... | ByteUtil { @Nonnull public static String toHexString(@Nonnull byte[] data) { return Hex.toHexString(Objects.requireNonNull(data)); } private ByteUtil(); static byte[] appendByte(byte[] bytes, byte b); static byte[] cloneBytes(byte[] bytes); static byte[] bigIntegerToBytes(BigInteger b, int numBytes); static byte[] big... |
@Test public void getTenBlocksFromTheTip() { ExecutionEnvironment executionEnvironment = EnvironmentUtils.getEnvironmentWithBlockchainOfLength(100); for(short i = 0; i < 10; i++) { Optional<Block> block = blockAccessor.getBlock(i, executionEnvironment); Assert.assertTrue(block.isPresent()); Assert.assertEquals(99 - i, ... | public Optional<Block> getBlock(short blockDepth, ExecutionEnvironment environment) { if (blockDepth < 0) { throw new NativeContractIllegalArgumentException(String.format( "Invalid block depth '%d' (should be a non-negative value)", blockDepth )); } if (blockDepth >= maximumBlockDepth) { return Optional.empty(); } Bloc... | BlockAccessor { public Optional<Block> getBlock(short blockDepth, ExecutionEnvironment environment) { if (blockDepth < 0) { throw new NativeContractIllegalArgumentException(String.format( "Invalid block depth '%d' (should be a non-negative value)", blockDepth )); } if (blockDepth >= maximumBlockDepth) { return Optional... | BlockAccessor { public Optional<Block> getBlock(short blockDepth, ExecutionEnvironment environment) { if (blockDepth < 0) { throw new NativeContractIllegalArgumentException(String.format( "Invalid block depth '%d' (should be a non-negative value)", blockDepth )); } if (blockDepth >= maximumBlockDepth) { return Optional... | BlockAccessor { public Optional<Block> getBlock(short blockDepth, ExecutionEnvironment environment) { if (blockDepth < 0) { throw new NativeContractIllegalArgumentException(String.format( "Invalid block depth '%d' (should be a non-negative value)", blockDepth )); } if (blockDepth >= maximumBlockDepth) { return Optional... | BlockAccessor { public Optional<Block> getBlock(short blockDepth, ExecutionEnvironment environment) { if (blockDepth < 0) { throw new NativeContractIllegalArgumentException(String.format( "Invalid block depth '%d' (should be a non-negative value)", blockDepth )); } if (blockDepth >= maximumBlockDepth) { return Optional... |
@Test public void hasNoDefaultMethod() { Assert.assertFalse(contract.getDefaultMethod().isPresent()); } | @Override public Optional<NativeMethod> getDefaultMethod() { return Optional.empty(); } | BlockHeaderContract extends NativeContract { @Override public Optional<NativeMethod> getDefaultMethod() { return Optional.empty(); } } | BlockHeaderContract extends NativeContract { @Override public Optional<NativeMethod> getDefaultMethod() { return Optional.empty(); } BlockHeaderContract(ActivationConfig activationConfig, RskAddress contractAddress); } | BlockHeaderContract extends NativeContract { @Override public Optional<NativeMethod> getDefaultMethod() { return Optional.empty(); } BlockHeaderContract(ActivationConfig activationConfig, RskAddress contractAddress); @Override List<NativeMethod> getMethods(); @Override Optional<NativeMethod> getDefaultMethod(); } | BlockHeaderContract extends NativeContract { @Override public Optional<NativeMethod> getDefaultMethod() { return Optional.empty(); } BlockHeaderContract(ActivationConfig activationConfig, RskAddress contractAddress); @Override List<NativeMethod> getMethods(); @Override Optional<NativeMethod> getDefaultMethod(); } |
@Test public void hasNineMethods() { Assert.assertEquals(9, contract.getMethods().size()); } | @Override public List<NativeMethod> getMethods() { return Arrays.asList( new GetCoinbaseAddress(getExecutionEnvironment(), this.blockAccessor), new GetBlockHash(getExecutionEnvironment(), this.blockAccessor), new GetMergedMiningTags(getExecutionEnvironment(), this.blockAccessor), new GetMinimumGasPrice(getExecutionEnvi... | BlockHeaderContract extends NativeContract { @Override public List<NativeMethod> getMethods() { return Arrays.asList( new GetCoinbaseAddress(getExecutionEnvironment(), this.blockAccessor), new GetBlockHash(getExecutionEnvironment(), this.blockAccessor), new GetMergedMiningTags(getExecutionEnvironment(), this.blockAcces... | BlockHeaderContract extends NativeContract { @Override public List<NativeMethod> getMethods() { return Arrays.asList( new GetCoinbaseAddress(getExecutionEnvironment(), this.blockAccessor), new GetBlockHash(getExecutionEnvironment(), this.blockAccessor), new GetMergedMiningTags(getExecutionEnvironment(), this.blockAcces... | BlockHeaderContract extends NativeContract { @Override public List<NativeMethod> getMethods() { return Arrays.asList( new GetCoinbaseAddress(getExecutionEnvironment(), this.blockAccessor), new GetBlockHash(getExecutionEnvironment(), this.blockAccessor), new GetMergedMiningTags(getExecutionEnvironment(), this.blockAcces... | BlockHeaderContract extends NativeContract { @Override public List<NativeMethod> getMethods() { return Arrays.asList( new GetCoinbaseAddress(getExecutionEnvironment(), this.blockAccessor), new GetBlockHash(getExecutionEnvironment(), this.blockAccessor), new GetMergedMiningTags(getExecutionEnvironment(), this.blockAcces... |
@Test public void executionEnvironmentGetter() { Assert.assertEquals(executionEnvironment, method.getExecutionEnvironment()); } | public ExecutionEnvironment getExecutionEnvironment() { return executionEnvironment; } | NativeMethod { public ExecutionEnvironment getExecutionEnvironment() { return executionEnvironment; } } | NativeMethod { public ExecutionEnvironment getExecutionEnvironment() { return executionEnvironment; } NativeMethod(ExecutionEnvironment executionEnvironment); } | NativeMethod { public ExecutionEnvironment getExecutionEnvironment() { return executionEnvironment; } NativeMethod(ExecutionEnvironment executionEnvironment); ExecutionEnvironment getExecutionEnvironment(); abstract CallTransaction.Function getFunction(); abstract Object execute(Object[] arguments); long getGas(Object[... | NativeMethod { public ExecutionEnvironment getExecutionEnvironment() { return executionEnvironment; } NativeMethod(ExecutionEnvironment executionEnvironment); ExecutionEnvironment getExecutionEnvironment(); abstract CallTransaction.Function getFunction(); abstract Object execute(Object[] arguments); long getGas(Object[... |
@Test public void getGasWithNullData() { Assert.assertEquals(0L, method.getGas(null, null)); } | public long getGas(Object[] parsedArguments, byte[] originalData) { return originalData == null ? 0 : originalData.length * 2; } | NativeMethod { public long getGas(Object[] parsedArguments, byte[] originalData) { return originalData == null ? 0 : originalData.length * 2; } } | NativeMethod { public long getGas(Object[] parsedArguments, byte[] originalData) { return originalData == null ? 0 : originalData.length * 2; } NativeMethod(ExecutionEnvironment executionEnvironment); } | NativeMethod { public long getGas(Object[] parsedArguments, byte[] originalData) { return originalData == null ? 0 : originalData.length * 2; } NativeMethod(ExecutionEnvironment executionEnvironment); ExecutionEnvironment getExecutionEnvironment(); abstract CallTransaction.Function getFunction(); abstract Object execut... | NativeMethod { public long getGas(Object[] parsedArguments, byte[] originalData) { return originalData == null ? 0 : originalData.length * 2; } NativeMethod(ExecutionEnvironment executionEnvironment); ExecutionEnvironment getExecutionEnvironment(); abstract CallTransaction.Function getFunction(); abstract Object execut... |
@Test public void getGasWithNonNullData() { Assert.assertEquals(6L, method.getGas(null, Hex.decode("aabbcc"))); Assert.assertEquals(10L, method.getGas(null, Hex.decode("aabbccddee"))); } | public long getGas(Object[] parsedArguments, byte[] originalData) { return originalData == null ? 0 : originalData.length * 2; } | NativeMethod { public long getGas(Object[] parsedArguments, byte[] originalData) { return originalData == null ? 0 : originalData.length * 2; } } | NativeMethod { public long getGas(Object[] parsedArguments, byte[] originalData) { return originalData == null ? 0 : originalData.length * 2; } NativeMethod(ExecutionEnvironment executionEnvironment); } | NativeMethod { public long getGas(Object[] parsedArguments, byte[] originalData) { return originalData == null ? 0 : originalData.length * 2; } NativeMethod(ExecutionEnvironment executionEnvironment); ExecutionEnvironment getExecutionEnvironment(); abstract CallTransaction.Function getFunction(); abstract Object execut... | NativeMethod { public long getGas(Object[] parsedArguments, byte[] originalData) { return originalData == null ? 0 : originalData.length * 2; } NativeMethod(ExecutionEnvironment executionEnvironment); ExecutionEnvironment getExecutionEnvironment(); abstract CallTransaction.Function getFunction(); abstract Object execut... |
@Test public void getName() { function.name = "a-method-name"; Assert.assertEquals("a-method-name", method.getName()); } | public String getName() { return getFunction().name; } | NativeMethod { public String getName() { return getFunction().name; } } | NativeMethod { public String getName() { return getFunction().name; } NativeMethod(ExecutionEnvironment executionEnvironment); } | NativeMethod { public String getName() { return getFunction().name; } NativeMethod(ExecutionEnvironment executionEnvironment); ExecutionEnvironment getExecutionEnvironment(); abstract CallTransaction.Function getFunction(); abstract Object execute(Object[] arguments); long getGas(Object[] parsedArguments, byte[] origin... | NativeMethod { public String getName() { return getFunction().name; } NativeMethod(ExecutionEnvironment executionEnvironment); ExecutionEnvironment getExecutionEnvironment(); abstract CallTransaction.Function getFunction(); abstract Object execute(Object[] arguments); long getGas(Object[] parsedArguments, byte[] origin... |
@Test public void withArgumentsGetsGas() { Assert.assertEquals(6L, withArguments.getGas()); } | public long getGas(Object[] parsedArguments, byte[] originalData) { return originalData == null ? 0 : originalData.length * 2; } | NativeMethod { public long getGas(Object[] parsedArguments, byte[] originalData) { return originalData == null ? 0 : originalData.length * 2; } } | NativeMethod { public long getGas(Object[] parsedArguments, byte[] originalData) { return originalData == null ? 0 : originalData.length * 2; } NativeMethod(ExecutionEnvironment executionEnvironment); } | NativeMethod { public long getGas(Object[] parsedArguments, byte[] originalData) { return originalData == null ? 0 : originalData.length * 2; } NativeMethod(ExecutionEnvironment executionEnvironment); ExecutionEnvironment getExecutionEnvironment(); abstract CallTransaction.Function getFunction(); abstract Object execut... | NativeMethod { public long getGas(Object[] parsedArguments, byte[] originalData) { return originalData == null ? 0 : originalData.length * 2; } NativeMethod(ExecutionEnvironment executionEnvironment); ExecutionEnvironment getExecutionEnvironment(); abstract CallTransaction.Function getFunction(); abstract Object execut... |
@Test public void withArgumentsExecutesMethod() { Assert.assertEquals("execution-result", withArguments.execute()); } | public abstract Object execute(Object[] arguments); | NativeMethod { public abstract Object execute(Object[] arguments); } | NativeMethod { public abstract Object execute(Object[] arguments); NativeMethod(ExecutionEnvironment executionEnvironment); } | NativeMethod { public abstract Object execute(Object[] arguments); NativeMethod(ExecutionEnvironment executionEnvironment); ExecutionEnvironment getExecutionEnvironment(); abstract CallTransaction.Function getFunction(); abstract Object execute(Object[] arguments); long getGas(Object[] parsedArguments, byte[] originalD... | NativeMethod { public abstract Object execute(Object[] arguments); NativeMethod(ExecutionEnvironment executionEnvironment); ExecutionEnvironment getExecutionEnvironment(); abstract CallTransaction.Function getFunction(); abstract Object execute(Object[] arguments); long getGas(Object[] parsedArguments, byte[] originalD... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.