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 remove() { Assert.assertTrue(whitelist.isWhitelisted(existingAddress)); Assert.assertTrue(whitelist.isWhitelisted(existingAddress.getHash160())); Assert.assertTrue(whitelist.remove(existingAddress)); Assert.assertFalse(whitelist.isWhitelisted(existingAddress)); Assert.assertFalse(whitelist.isWhitelist... | public boolean remove(Address address) { return whitelistedAddresses.remove(address) != null; } | LockWhitelist { public boolean remove(Address address) { return whitelistedAddresses.remove(address) != null; } } | LockWhitelist { public boolean remove(Address address) { return whitelistedAddresses.remove(address) != null; } LockWhitelist(Map<Address, LockWhitelistEntry> whitelistedAddresses); LockWhitelist(Map<Address, LockWhitelistEntry> whitelistedAddresses, int disableBlockHeight); } | LockWhitelist { public boolean remove(Address address) { return whitelistedAddresses.remove(address) != null; } LockWhitelist(Map<Address, LockWhitelistEntry> whitelistedAddresses); LockWhitelist(Map<Address, LockWhitelistEntry> whitelistedAddresses, int disableBlockHeight); boolean isWhitelisted(Address address); boo... | LockWhitelist { public boolean remove(Address address) { return whitelistedAddresses.remove(address) != null; } LockWhitelist(Map<Address, LockWhitelistEntry> whitelistedAddresses); LockWhitelist(Map<Address, LockWhitelistEntry> whitelistedAddresses, int disableBlockHeight); boolean isWhitelisted(Address address); boo... |
@Test public void consume() { assertExistance(existingAddress, true); whitelist.consume(existingAddress); assertExistance(existingAddress, false); Assert.assertFalse(whitelist.remove(existingAddress)); } | public void consume(Address address) { LockWhitelistEntry entry = whitelistedAddresses.get(address); if (entry == null) { return; } entry.consume(); if (entry.isConsumed()) { this.remove(address); } } | LockWhitelist { public void consume(Address address) { LockWhitelistEntry entry = whitelistedAddresses.get(address); if (entry == null) { return; } entry.consume(); if (entry.isConsumed()) { this.remove(address); } } } | LockWhitelist { public void consume(Address address) { LockWhitelistEntry entry = whitelistedAddresses.get(address); if (entry == null) { return; } entry.consume(); if (entry.isConsumed()) { this.remove(address); } } LockWhitelist(Map<Address, LockWhitelistEntry> whitelistedAddresses); LockWhitelist(Map<Address, LockW... | LockWhitelist { public void consume(Address address) { LockWhitelistEntry entry = whitelistedAddresses.get(address); if (entry == null) { return; } entry.consume(); if (entry.isConsumed()) { this.remove(address); } } LockWhitelist(Map<Address, LockWhitelistEntry> whitelistedAddresses); LockWhitelist(Map<Address, LockW... | LockWhitelist { public void consume(Address address) { LockWhitelistEntry entry = whitelistedAddresses.get(address); if (entry == null) { return; } entry.consume(); if (entry.isConsumed()) { this.remove(address); } } LockWhitelist(Map<Address, LockWhitelistEntry> whitelistedAddresses); LockWhitelist(Map<Address, LockW... |
@Test public void test1() throws UnknownHostException { String peersPacket = "F8 4E 11 F8 4B C5 36 81 " + "CC 0A 29 82 76 5F B8 40 D8 D6 0C 25 80 FA 79 5C " + "FC 03 13 EF DE BA 86 9D 21 94 E7 9E 7C B2 B5 22 " + "F7 82 FF A0 39 2C BB AB 8D 1B AC 30 12 08 B1 37 " + "E0 DE 49 98 33 4F 3B CF 73 FA 11 7E F2 13 F8 74 " + "1... | public static byte[] decodeIP4Bytes(byte[] data, int index) { int offset = 1; final byte[] result = new byte[4]; for (int i = 0; i < 4; i++) { result[i] = decodeOneByteItem(data, index + offset); if ((data[index + offset] & 0xFF) > OFFSET_SHORT_ITEM) { offset += 2; } else { offset += 1; } } return result; } | RLP { public static byte[] decodeIP4Bytes(byte[] data, int index) { int offset = 1; final byte[] result = new byte[4]; for (int i = 0; i < 4; i++) { result[i] = decodeOneByteItem(data, index + offset); if ((data[index + offset] & 0xFF) > OFFSET_SHORT_ITEM) { offset += 2; } else { offset += 1; } } return result; } } | RLP { public static byte[] decodeIP4Bytes(byte[] data, int index) { int offset = 1; final byte[] result = new byte[4]; for (int i = 0; i < 4; i++) { result[i] = decodeOneByteItem(data, index + offset); if ((data[index + offset] & 0xFF) > OFFSET_SHORT_ITEM) { offset += 2; } else { offset += 1; } } return result; } } | RLP { public static byte[] decodeIP4Bytes(byte[] data, int index) { int offset = 1; final byte[] result = new byte[4]; for (int i = 0; i < 4; i++) { result[i] = decodeOneByteItem(data, index + offset); if ((data[index + offset] & 0xFF) > OFFSET_SHORT_ITEM) { offset += 2; } else { offset += 1; } } return result; } stat... | RLP { public static byte[] decodeIP4Bytes(byte[] data, int index) { int offset = 1; final byte[] result = new byte[4]; for (int i = 0; i < 4; i++) { result[i] = decodeOneByteItem(data, index + offset); if ((data[index + offset] & 0xFF) > OFFSET_SHORT_ITEM) { offset += 2; } else { offset += 1; } } return result; } stat... |
@Test public void cantLockOneOffAfterConsume() { Address randomAddress = Address.fromBase58( NetworkParameters.fromID(NetworkParameters.ID_REGTEST), "n3WzdjG7S2GjDbY1pJYxsY1VSQDkm4KDcm" ); OneOffWhiteListEntry entry = new OneOffWhiteListEntry(randomAddress, Coin.COIN); Assert.assertTrue(entry.canLock(Coin.COIN)); entry... | public void consume(Address address) { LockWhitelistEntry entry = whitelistedAddresses.get(address); if (entry == null) { return; } entry.consume(); if (entry.isConsumed()) { this.remove(address); } } | LockWhitelist { public void consume(Address address) { LockWhitelistEntry entry = whitelistedAddresses.get(address); if (entry == null) { return; } entry.consume(); if (entry.isConsumed()) { this.remove(address); } } } | LockWhitelist { public void consume(Address address) { LockWhitelistEntry entry = whitelistedAddresses.get(address); if (entry == null) { return; } entry.consume(); if (entry.isConsumed()) { this.remove(address); } } LockWhitelist(Map<Address, LockWhitelistEntry> whitelistedAddresses); LockWhitelist(Map<Address, LockW... | LockWhitelist { public void consume(Address address) { LockWhitelistEntry entry = whitelistedAddresses.get(address); if (entry == null) { return; } entry.consume(); if (entry.isConsumed()) { this.remove(address); } } LockWhitelist(Map<Address, LockWhitelistEntry> whitelistedAddresses); LockWhitelist(Map<Address, LockW... | LockWhitelist { public void consume(Address address) { LockWhitelistEntry entry = whitelistedAddresses.get(address); if (entry == null) { return; } entry.consume(); if (entry.isConsumed()) { this.remove(address); } } LockWhitelist(Map<Address, LockWhitelistEntry> whitelistedAddresses); LockWhitelist(Map<Address, LockW... |
@Test public void canLockUnlimitedAfterConsume() { Address randomAddress = Address.fromBase58( NetworkParameters.fromID(NetworkParameters.ID_REGTEST), "n3WzdjG7S2GjDbY1pJYxsY1VSQDkm4KDcm" ); UnlimitedWhiteListEntry entry = new UnlimitedWhiteListEntry(randomAddress); Assert.assertTrue(entry.canLock(Coin.COIN)); entry.co... | public void consume(Address address) { LockWhitelistEntry entry = whitelistedAddresses.get(address); if (entry == null) { return; } entry.consume(); if (entry.isConsumed()) { this.remove(address); } } | LockWhitelist { public void consume(Address address) { LockWhitelistEntry entry = whitelistedAddresses.get(address); if (entry == null) { return; } entry.consume(); if (entry.isConsumed()) { this.remove(address); } } } | LockWhitelist { public void consume(Address address) { LockWhitelistEntry entry = whitelistedAddresses.get(address); if (entry == null) { return; } entry.consume(); if (entry.isConsumed()) { this.remove(address); } } LockWhitelist(Map<Address, LockWhitelistEntry> whitelistedAddresses); LockWhitelist(Map<Address, LockW... | LockWhitelist { public void consume(Address address) { LockWhitelistEntry entry = whitelistedAddresses.get(address); if (entry == null) { return; } entry.consume(); if (entry.isConsumed()) { this.remove(address); } } LockWhitelist(Map<Address, LockWhitelistEntry> whitelistedAddresses); LockWhitelist(Map<Address, LockW... | LockWhitelist { public void consume(Address address) { LockWhitelistEntry entry = whitelistedAddresses.get(address); if (entry == null) { return; } entry.consume(); if (entry.isConsumed()) { this.remove(address); } } LockWhitelist(Map<Address, LockWhitelistEntry> whitelistedAddresses); LockWhitelist(Map<Address, LockW... |
@Test public void getAllByType() { Assert.assertArrayEquals( addresses.values().stream().filter(e -> e.getClass() == OneOffWhiteListEntry.class).map(e-> e.address()).sorted().toArray(), whitelist.getAll(OneOffWhiteListEntry.class).stream().map(e-> e.address()).toArray() ); Assert.assertArrayEquals( addresses.values().s... | public <T extends LockWhitelistEntry> List<T> getAll(Class<T> type) { return whitelistedAddresses.values().stream() .filter(e -> e.getClass() == type) .map(type::cast) .collect(Collectors.toList()); } | LockWhitelist { public <T extends LockWhitelistEntry> List<T> getAll(Class<T> type) { return whitelistedAddresses.values().stream() .filter(e -> e.getClass() == type) .map(type::cast) .collect(Collectors.toList()); } } | LockWhitelist { public <T extends LockWhitelistEntry> List<T> getAll(Class<T> type) { return whitelistedAddresses.values().stream() .filter(e -> e.getClass() == type) .map(type::cast) .collect(Collectors.toList()); } LockWhitelist(Map<Address, LockWhitelistEntry> whitelistedAddresses); LockWhitelist(Map<Address, LockW... | LockWhitelist { public <T extends LockWhitelistEntry> List<T> getAll(Class<T> type) { return whitelistedAddresses.values().stream() .filter(e -> e.getClass() == type) .map(type::cast) .collect(Collectors.toList()); } LockWhitelist(Map<Address, LockWhitelistEntry> whitelistedAddresses); LockWhitelist(Map<Address, LockW... | LockWhitelist { public <T extends LockWhitelistEntry> List<T> getAll(Class<T> type) { return whitelistedAddresses.values().stream() .filter(e -> e.getClass() == type) .map(type::cast) .collect(Collectors.toList()); } LockWhitelist(Map<Address, LockWhitelistEntry> whitelistedAddresses); LockWhitelist(Map<Address, LockW... |
@Test public void getAll() { Assert.assertEquals(addresses.size(), whitelist.getAll().size()); } | public <T extends LockWhitelistEntry> List<T> getAll(Class<T> type) { return whitelistedAddresses.values().stream() .filter(e -> e.getClass() == type) .map(type::cast) .collect(Collectors.toList()); } | LockWhitelist { public <T extends LockWhitelistEntry> List<T> getAll(Class<T> type) { return whitelistedAddresses.values().stream() .filter(e -> e.getClass() == type) .map(type::cast) .collect(Collectors.toList()); } } | LockWhitelist { public <T extends LockWhitelistEntry> List<T> getAll(Class<T> type) { return whitelistedAddresses.values().stream() .filter(e -> e.getClass() == type) .map(type::cast) .collect(Collectors.toList()); } LockWhitelist(Map<Address, LockWhitelistEntry> whitelistedAddresses); LockWhitelist(Map<Address, LockW... | LockWhitelist { public <T extends LockWhitelistEntry> List<T> getAll(Class<T> type) { return whitelistedAddresses.values().stream() .filter(e -> e.getClass() == type) .map(type::cast) .collect(Collectors.toList()); } LockWhitelist(Map<Address, LockWhitelistEntry> whitelistedAddresses); LockWhitelist(Map<Address, LockW... | LockWhitelist { public <T extends LockWhitelistEntry> List<T> getAll(Class<T> type) { return whitelistedAddresses.values().stream() .filter(e -> e.getClass() == type) .map(type::cast) .collect(Collectors.toList()); } LockWhitelist(Map<Address, LockWhitelistEntry> whitelistedAddresses); LockWhitelist(Map<Address, LockW... |
@Test public void getWitnessMerkleRoot() { Sha256Hash secondHashTx = Sha256Hash.wrap(Hex.decode("e3d0840a0825fb7d880e5cb8306745352920a8c7e8a30fac882b275e26c6bb65")); Sha256Hash witnessRoot = MerkleTreeUtils.combineLeftRight(Sha256Hash.ZERO_HASH, secondHashTx); CoinbaseInformation instance = new CoinbaseInformation(witn... | public Sha256Hash getWitnessMerkleRoot() { return witnessMerkleRoot; } | CoinbaseInformation { public Sha256Hash getWitnessMerkleRoot() { return witnessMerkleRoot; } } | CoinbaseInformation { public Sha256Hash getWitnessMerkleRoot() { return witnessMerkleRoot; } CoinbaseInformation(Sha256Hash witnessMerkleRoot); } | CoinbaseInformation { public Sha256Hash getWitnessMerkleRoot() { return witnessMerkleRoot; } CoinbaseInformation(Sha256Hash witnessMerkleRoot); Sha256Hash getWitnessMerkleRoot(); } | CoinbaseInformation { public Sha256Hash getWitnessMerkleRoot() { return witnessMerkleRoot; } CoinbaseInformation(Sha256Hash witnessMerkleRoot); Sha256Hash getWitnessMerkleRoot(); } |
@Test public void getNewFederation_initialVersion() throws IOException { List<Integer> storageCalls = new ArrayList<>(); List<Integer> deserializeCalls = new ArrayList<>(); Federation newFederation = buildMockFederation(100, 200, 300); PowerMockito.mockStatic(BridgeSerializationUtils.class); Repository repositoryMock =... | public Federation getNewFederation() { if (newFederation != null) { return newFederation; } Optional<Integer> storageVersion = getStorageVersion(NEW_FEDERATION_FORMAT_VERSION); newFederation = safeGetFromRepository(NEW_FEDERATION_KEY, data -> data == null ? null : deserializeFederationAccordingToVersion(data, storageVe... | BridgeStorageProvider { public Federation getNewFederation() { if (newFederation != null) { return newFederation; } Optional<Integer> storageVersion = getStorageVersion(NEW_FEDERATION_FORMAT_VERSION); newFederation = safeGetFromRepository(NEW_FEDERATION_KEY, data -> data == null ? null : deserializeFederationAccordingT... | BridgeStorageProvider { public Federation getNewFederation() { if (newFederation != null) { return newFederation; } Optional<Integer> storageVersion = getStorageVersion(NEW_FEDERATION_FORMAT_VERSION); newFederation = safeGetFromRepository(NEW_FEDERATION_KEY, data -> data == null ? null : deserializeFederationAccordingT... | BridgeStorageProvider { public Federation getNewFederation() { if (newFederation != null) { return newFederation; } Optional<Integer> storageVersion = getStorageVersion(NEW_FEDERATION_FORMAT_VERSION); newFederation = safeGetFromRepository(NEW_FEDERATION_KEY, data -> data == null ? null : deserializeFederationAccordingT... | BridgeStorageProvider { public Federation getNewFederation() { if (newFederation != null) { return newFederation; } Optional<Integer> storageVersion = getStorageVersion(NEW_FEDERATION_FORMAT_VERSION); newFederation = safeGetFromRepository(NEW_FEDERATION_KEY, data -> data == null ? null : deserializeFederationAccordingT... |
@Test public void getNewFederation_initialVersion_nullBytes() throws IOException { List<Integer> storageCalls = new ArrayList<>(); PowerMockito.mockStatic(BridgeSerializationUtils.class); Repository repositoryMock = mock(Repository.class); BridgeStorageProvider storageProvider = new BridgeStorageProvider(repositoryMock... | public Federation getNewFederation() { if (newFederation != null) { return newFederation; } Optional<Integer> storageVersion = getStorageVersion(NEW_FEDERATION_FORMAT_VERSION); newFederation = safeGetFromRepository(NEW_FEDERATION_KEY, data -> data == null ? null : deserializeFederationAccordingToVersion(data, storageVe... | BridgeStorageProvider { public Federation getNewFederation() { if (newFederation != null) { return newFederation; } Optional<Integer> storageVersion = getStorageVersion(NEW_FEDERATION_FORMAT_VERSION); newFederation = safeGetFromRepository(NEW_FEDERATION_KEY, data -> data == null ? null : deserializeFederationAccordingT... | BridgeStorageProvider { public Federation getNewFederation() { if (newFederation != null) { return newFederation; } Optional<Integer> storageVersion = getStorageVersion(NEW_FEDERATION_FORMAT_VERSION); newFederation = safeGetFromRepository(NEW_FEDERATION_KEY, data -> data == null ? null : deserializeFederationAccordingT... | BridgeStorageProvider { public Federation getNewFederation() { if (newFederation != null) { return newFederation; } Optional<Integer> storageVersion = getStorageVersion(NEW_FEDERATION_FORMAT_VERSION); newFederation = safeGetFromRepository(NEW_FEDERATION_KEY, data -> data == null ? null : deserializeFederationAccordingT... | BridgeStorageProvider { public Federation getNewFederation() { if (newFederation != null) { return newFederation; } Optional<Integer> storageVersion = getStorageVersion(NEW_FEDERATION_FORMAT_VERSION); newFederation = safeGetFromRepository(NEW_FEDERATION_KEY, data -> data == null ? null : deserializeFederationAccordingT... |
@Test public void getNewFederation_multiKeyVersion() throws IOException { List<Integer> storageCalls = new ArrayList<>(); List<Integer> deserializeCalls = new ArrayList<>(); Federation newFederation = buildMockFederation(100, 200, 300); PowerMockito.mockStatic(BridgeSerializationUtils.class); Repository repositoryMock ... | public Federation getNewFederation() { if (newFederation != null) { return newFederation; } Optional<Integer> storageVersion = getStorageVersion(NEW_FEDERATION_FORMAT_VERSION); newFederation = safeGetFromRepository(NEW_FEDERATION_KEY, data -> data == null ? null : deserializeFederationAccordingToVersion(data, storageVe... | BridgeStorageProvider { public Federation getNewFederation() { if (newFederation != null) { return newFederation; } Optional<Integer> storageVersion = getStorageVersion(NEW_FEDERATION_FORMAT_VERSION); newFederation = safeGetFromRepository(NEW_FEDERATION_KEY, data -> data == null ? null : deserializeFederationAccordingT... | BridgeStorageProvider { public Federation getNewFederation() { if (newFederation != null) { return newFederation; } Optional<Integer> storageVersion = getStorageVersion(NEW_FEDERATION_FORMAT_VERSION); newFederation = safeGetFromRepository(NEW_FEDERATION_KEY, data -> data == null ? null : deserializeFederationAccordingT... | BridgeStorageProvider { public Federation getNewFederation() { if (newFederation != null) { return newFederation; } Optional<Integer> storageVersion = getStorageVersion(NEW_FEDERATION_FORMAT_VERSION); newFederation = safeGetFromRepository(NEW_FEDERATION_KEY, data -> data == null ? null : deserializeFederationAccordingT... | BridgeStorageProvider { public Federation getNewFederation() { if (newFederation != null) { return newFederation; } Optional<Integer> storageVersion = getStorageVersion(NEW_FEDERATION_FORMAT_VERSION); newFederation = safeGetFromRepository(NEW_FEDERATION_KEY, data -> data == null ? null : deserializeFederationAccordingT... |
@Test public void getNewFederation_multiKeyVersion_nullBytes() throws IOException { List<Integer> storageCalls = new ArrayList<>(); PowerMockito.mockStatic(BridgeSerializationUtils.class); Repository repositoryMock = mock(Repository.class); BridgeStorageProvider storageProvider = new BridgeStorageProvider(repositoryMoc... | public Federation getNewFederation() { if (newFederation != null) { return newFederation; } Optional<Integer> storageVersion = getStorageVersion(NEW_FEDERATION_FORMAT_VERSION); newFederation = safeGetFromRepository(NEW_FEDERATION_KEY, data -> data == null ? null : deserializeFederationAccordingToVersion(data, storageVe... | BridgeStorageProvider { public Federation getNewFederation() { if (newFederation != null) { return newFederation; } Optional<Integer> storageVersion = getStorageVersion(NEW_FEDERATION_FORMAT_VERSION); newFederation = safeGetFromRepository(NEW_FEDERATION_KEY, data -> data == null ? null : deserializeFederationAccordingT... | BridgeStorageProvider { public Federation getNewFederation() { if (newFederation != null) { return newFederation; } Optional<Integer> storageVersion = getStorageVersion(NEW_FEDERATION_FORMAT_VERSION); newFederation = safeGetFromRepository(NEW_FEDERATION_KEY, data -> data == null ? null : deserializeFederationAccordingT... | BridgeStorageProvider { public Federation getNewFederation() { if (newFederation != null) { return newFederation; } Optional<Integer> storageVersion = getStorageVersion(NEW_FEDERATION_FORMAT_VERSION); newFederation = safeGetFromRepository(NEW_FEDERATION_KEY, data -> data == null ? null : deserializeFederationAccordingT... | BridgeStorageProvider { public Federation getNewFederation() { if (newFederation != null) { return newFederation; } Optional<Integer> storageVersion = getStorageVersion(NEW_FEDERATION_FORMAT_VERSION); newFederation = safeGetFromRepository(NEW_FEDERATION_KEY, data -> data == null ? null : deserializeFederationAccordingT... |
@Test public void getOldFederation_initialVersion() throws IOException { List<Integer> storageCalls = new ArrayList<>(); List<Integer> deserializeCalls = new ArrayList<>(); Federation oldFederation = buildMockFederation(100, 200, 300); PowerMockito.mockStatic(BridgeSerializationUtils.class); Repository repositoryMock =... | public Federation getOldFederation() { if (oldFederation != null || shouldSaveOldFederation) { return oldFederation; } Optional<Integer> storageVersion = getStorageVersion(OLD_FEDERATION_FORMAT_VERSION); oldFederation = safeGetFromRepository(OLD_FEDERATION_KEY, data -> data == null ? null : deserializeFederationAccordi... | BridgeStorageProvider { public Federation getOldFederation() { if (oldFederation != null || shouldSaveOldFederation) { return oldFederation; } Optional<Integer> storageVersion = getStorageVersion(OLD_FEDERATION_FORMAT_VERSION); oldFederation = safeGetFromRepository(OLD_FEDERATION_KEY, data -> data == null ? null : dese... | BridgeStorageProvider { public Federation getOldFederation() { if (oldFederation != null || shouldSaveOldFederation) { return oldFederation; } Optional<Integer> storageVersion = getStorageVersion(OLD_FEDERATION_FORMAT_VERSION); oldFederation = safeGetFromRepository(OLD_FEDERATION_KEY, data -> data == null ? null : dese... | BridgeStorageProvider { public Federation getOldFederation() { if (oldFederation != null || shouldSaveOldFederation) { return oldFederation; } Optional<Integer> storageVersion = getStorageVersion(OLD_FEDERATION_FORMAT_VERSION); oldFederation = safeGetFromRepository(OLD_FEDERATION_KEY, data -> data == null ? null : dese... | BridgeStorageProvider { public Federation getOldFederation() { if (oldFederation != null || shouldSaveOldFederation) { return oldFederation; } Optional<Integer> storageVersion = getStorageVersion(OLD_FEDERATION_FORMAT_VERSION); oldFederation = safeGetFromRepository(OLD_FEDERATION_KEY, data -> data == null ? null : dese... |
@Test public void test2() throws UnknownHostException { String peersPacket = "F8 4E 11 F8 4B C5 36 81 " + "CC 0A 29 82 76 5F B8 40 D8 D6 0C 25 80 FA 79 5C " + "FC 03 13 EF DE BA 86 9D 21 94 E7 9E 7C B2 B5 22 " + "F7 82 FF A0 39 2C BB AB 8D 1B AC 30 12 08 B1 37 " + "E0 DE 49 98 33 4F 3B CF 73 FA 11 7E F2 13 F8 74 " + "1... | public static int decodeInt(byte[] data, int index) { int value = 0; if ((data[index] & 0xFF) < OFFSET_SHORT_ITEM) { return data[index]; } else if ((data[index] & 0xFF) >= OFFSET_SHORT_ITEM && (data[index] & 0xFF) < OFFSET_LONG_ITEM) { byte length = (byte) (data[index] - OFFSET_SHORT_ITEM); byte pow = (byte) (length - ... | RLP { public static int decodeInt(byte[] data, int index) { int value = 0; if ((data[index] & 0xFF) < OFFSET_SHORT_ITEM) { return data[index]; } else if ((data[index] & 0xFF) >= OFFSET_SHORT_ITEM && (data[index] & 0xFF) < OFFSET_LONG_ITEM) { byte length = (byte) (data[index] - OFFSET_SHORT_ITEM); byte pow = (byte) (len... | RLP { public static int decodeInt(byte[] data, int index) { int value = 0; if ((data[index] & 0xFF) < OFFSET_SHORT_ITEM) { return data[index]; } else if ((data[index] & 0xFF) >= OFFSET_SHORT_ITEM && (data[index] & 0xFF) < OFFSET_LONG_ITEM) { byte length = (byte) (data[index] - OFFSET_SHORT_ITEM); byte pow = (byte) (len... | RLP { public static int decodeInt(byte[] data, int index) { int value = 0; if ((data[index] & 0xFF) < OFFSET_SHORT_ITEM) { return data[index]; } else if ((data[index] & 0xFF) >= OFFSET_SHORT_ITEM && (data[index] & 0xFF) < OFFSET_LONG_ITEM) { byte length = (byte) (data[index] - OFFSET_SHORT_ITEM); byte pow = (byte) (len... | RLP { public static int decodeInt(byte[] data, int index) { int value = 0; if ((data[index] & 0xFF) < OFFSET_SHORT_ITEM) { return data[index]; } else if ((data[index] & 0xFF) >= OFFSET_SHORT_ITEM && (data[index] & 0xFF) < OFFSET_LONG_ITEM) { byte length = (byte) (data[index] - OFFSET_SHORT_ITEM); byte pow = (byte) (len... |
@Test public void getOldFederation_initialVersion_nullBytes() throws IOException { List<Integer> storageCalls = new ArrayList<>(); PowerMockito.mockStatic(BridgeSerializationUtils.class); Repository repositoryMock = mock(Repository.class); BridgeStorageProvider storageProvider = new BridgeStorageProvider(repositoryMock... | public Federation getOldFederation() { if (oldFederation != null || shouldSaveOldFederation) { return oldFederation; } Optional<Integer> storageVersion = getStorageVersion(OLD_FEDERATION_FORMAT_VERSION); oldFederation = safeGetFromRepository(OLD_FEDERATION_KEY, data -> data == null ? null : deserializeFederationAccordi... | BridgeStorageProvider { public Federation getOldFederation() { if (oldFederation != null || shouldSaveOldFederation) { return oldFederation; } Optional<Integer> storageVersion = getStorageVersion(OLD_FEDERATION_FORMAT_VERSION); oldFederation = safeGetFromRepository(OLD_FEDERATION_KEY, data -> data == null ? null : dese... | BridgeStorageProvider { public Federation getOldFederation() { if (oldFederation != null || shouldSaveOldFederation) { return oldFederation; } Optional<Integer> storageVersion = getStorageVersion(OLD_FEDERATION_FORMAT_VERSION); oldFederation = safeGetFromRepository(OLD_FEDERATION_KEY, data -> data == null ? null : dese... | BridgeStorageProvider { public Federation getOldFederation() { if (oldFederation != null || shouldSaveOldFederation) { return oldFederation; } Optional<Integer> storageVersion = getStorageVersion(OLD_FEDERATION_FORMAT_VERSION); oldFederation = safeGetFromRepository(OLD_FEDERATION_KEY, data -> data == null ? null : dese... | BridgeStorageProvider { public Federation getOldFederation() { if (oldFederation != null || shouldSaveOldFederation) { return oldFederation; } Optional<Integer> storageVersion = getStorageVersion(OLD_FEDERATION_FORMAT_VERSION); oldFederation = safeGetFromRepository(OLD_FEDERATION_KEY, data -> data == null ? null : dese... |
@Test public void getOldFederation_multiKeyVersion() throws IOException { List<Integer> storageCalls = new ArrayList<>(); List<Integer> deserializeCalls = new ArrayList<>(); Federation oldFederation = buildMockFederation(100, 200, 300); PowerMockito.mockStatic(BridgeSerializationUtils.class); Repository repositoryMock ... | public Federation getOldFederation() { if (oldFederation != null || shouldSaveOldFederation) { return oldFederation; } Optional<Integer> storageVersion = getStorageVersion(OLD_FEDERATION_FORMAT_VERSION); oldFederation = safeGetFromRepository(OLD_FEDERATION_KEY, data -> data == null ? null : deserializeFederationAccordi... | BridgeStorageProvider { public Federation getOldFederation() { if (oldFederation != null || shouldSaveOldFederation) { return oldFederation; } Optional<Integer> storageVersion = getStorageVersion(OLD_FEDERATION_FORMAT_VERSION); oldFederation = safeGetFromRepository(OLD_FEDERATION_KEY, data -> data == null ? null : dese... | BridgeStorageProvider { public Federation getOldFederation() { if (oldFederation != null || shouldSaveOldFederation) { return oldFederation; } Optional<Integer> storageVersion = getStorageVersion(OLD_FEDERATION_FORMAT_VERSION); oldFederation = safeGetFromRepository(OLD_FEDERATION_KEY, data -> data == null ? null : dese... | BridgeStorageProvider { public Federation getOldFederation() { if (oldFederation != null || shouldSaveOldFederation) { return oldFederation; } Optional<Integer> storageVersion = getStorageVersion(OLD_FEDERATION_FORMAT_VERSION); oldFederation = safeGetFromRepository(OLD_FEDERATION_KEY, data -> data == null ? null : dese... | BridgeStorageProvider { public Federation getOldFederation() { if (oldFederation != null || shouldSaveOldFederation) { return oldFederation; } Optional<Integer> storageVersion = getStorageVersion(OLD_FEDERATION_FORMAT_VERSION); oldFederation = safeGetFromRepository(OLD_FEDERATION_KEY, data -> data == null ? null : dese... |
@Test public void getOldFederation_multiKeyVersion_nullBytes() throws IOException { List<Integer> storageCalls = new ArrayList<>(); PowerMockito.mockStatic(BridgeSerializationUtils.class); Repository repositoryMock = mock(Repository.class); BridgeStorageProvider storageProvider = new BridgeStorageProvider(repositoryMoc... | public Federation getOldFederation() { if (oldFederation != null || shouldSaveOldFederation) { return oldFederation; } Optional<Integer> storageVersion = getStorageVersion(OLD_FEDERATION_FORMAT_VERSION); oldFederation = safeGetFromRepository(OLD_FEDERATION_KEY, data -> data == null ? null : deserializeFederationAccordi... | BridgeStorageProvider { public Federation getOldFederation() { if (oldFederation != null || shouldSaveOldFederation) { return oldFederation; } Optional<Integer> storageVersion = getStorageVersion(OLD_FEDERATION_FORMAT_VERSION); oldFederation = safeGetFromRepository(OLD_FEDERATION_KEY, data -> data == null ? null : dese... | BridgeStorageProvider { public Federation getOldFederation() { if (oldFederation != null || shouldSaveOldFederation) { return oldFederation; } Optional<Integer> storageVersion = getStorageVersion(OLD_FEDERATION_FORMAT_VERSION); oldFederation = safeGetFromRepository(OLD_FEDERATION_KEY, data -> data == null ? null : dese... | BridgeStorageProvider { public Federation getOldFederation() { if (oldFederation != null || shouldSaveOldFederation) { return oldFederation; } Optional<Integer> storageVersion = getStorageVersion(OLD_FEDERATION_FORMAT_VERSION); oldFederation = safeGetFromRepository(OLD_FEDERATION_KEY, data -> data == null ? null : dese... | BridgeStorageProvider { public Federation getOldFederation() { if (oldFederation != null || shouldSaveOldFederation) { return oldFederation; } Optional<Integer> storageVersion = getStorageVersion(OLD_FEDERATION_FORMAT_VERSION); oldFederation = safeGetFromRepository(OLD_FEDERATION_KEY, data -> data == null ? null : dese... |
@Test public void getPendingFederation_initialVersion() throws IOException { List<Integer> storageCalls = new ArrayList<>(); List<Integer> deserializeCalls = new ArrayList<>(); PendingFederation pendingFederation = buildMockPendingFederation(100, 200, 300); PowerMockito.mockStatic(BridgeSerializationUtils.class); Repos... | public PendingFederation getPendingFederation() { if (pendingFederation != null || shouldSavePendingFederation) { return pendingFederation; } Optional<Integer> storageVersion = getStorageVersion(PENDING_FEDERATION_FORMAT_VERSION); pendingFederation = safeGetFromRepository(PENDING_FEDERATION_KEY, data -> data == null ? ... | BridgeStorageProvider { public PendingFederation getPendingFederation() { if (pendingFederation != null || shouldSavePendingFederation) { return pendingFederation; } Optional<Integer> storageVersion = getStorageVersion(PENDING_FEDERATION_FORMAT_VERSION); pendingFederation = safeGetFromRepository(PENDING_FEDERATION_KEY,... | BridgeStorageProvider { public PendingFederation getPendingFederation() { if (pendingFederation != null || shouldSavePendingFederation) { return pendingFederation; } Optional<Integer> storageVersion = getStorageVersion(PENDING_FEDERATION_FORMAT_VERSION); pendingFederation = safeGetFromRepository(PENDING_FEDERATION_KEY,... | BridgeStorageProvider { public PendingFederation getPendingFederation() { if (pendingFederation != null || shouldSavePendingFederation) { return pendingFederation; } Optional<Integer> storageVersion = getStorageVersion(PENDING_FEDERATION_FORMAT_VERSION); pendingFederation = safeGetFromRepository(PENDING_FEDERATION_KEY,... | BridgeStorageProvider { public PendingFederation getPendingFederation() { if (pendingFederation != null || shouldSavePendingFederation) { return pendingFederation; } Optional<Integer> storageVersion = getStorageVersion(PENDING_FEDERATION_FORMAT_VERSION); pendingFederation = safeGetFromRepository(PENDING_FEDERATION_KEY,... |
@Test public void getPendingFederation_initialVersion_nullBytes() throws IOException { List<Integer> storageCalls = new ArrayList<>(); PowerMockito.mockStatic(BridgeSerializationUtils.class); Repository repositoryMock = mock(Repository.class); BridgeStorageProvider storageProvider = new BridgeStorageProvider(repository... | public PendingFederation getPendingFederation() { if (pendingFederation != null || shouldSavePendingFederation) { return pendingFederation; } Optional<Integer> storageVersion = getStorageVersion(PENDING_FEDERATION_FORMAT_VERSION); pendingFederation = safeGetFromRepository(PENDING_FEDERATION_KEY, data -> data == null ? ... | BridgeStorageProvider { public PendingFederation getPendingFederation() { if (pendingFederation != null || shouldSavePendingFederation) { return pendingFederation; } Optional<Integer> storageVersion = getStorageVersion(PENDING_FEDERATION_FORMAT_VERSION); pendingFederation = safeGetFromRepository(PENDING_FEDERATION_KEY,... | BridgeStorageProvider { public PendingFederation getPendingFederation() { if (pendingFederation != null || shouldSavePendingFederation) { return pendingFederation; } Optional<Integer> storageVersion = getStorageVersion(PENDING_FEDERATION_FORMAT_VERSION); pendingFederation = safeGetFromRepository(PENDING_FEDERATION_KEY,... | BridgeStorageProvider { public PendingFederation getPendingFederation() { if (pendingFederation != null || shouldSavePendingFederation) { return pendingFederation; } Optional<Integer> storageVersion = getStorageVersion(PENDING_FEDERATION_FORMAT_VERSION); pendingFederation = safeGetFromRepository(PENDING_FEDERATION_KEY,... | BridgeStorageProvider { public PendingFederation getPendingFederation() { if (pendingFederation != null || shouldSavePendingFederation) { return pendingFederation; } Optional<Integer> storageVersion = getStorageVersion(PENDING_FEDERATION_FORMAT_VERSION); pendingFederation = safeGetFromRepository(PENDING_FEDERATION_KEY,... |
@Test public void getPendingFederation_multiKeyVersion() throws IOException { List<Integer> storageCalls = new ArrayList<>(); List<Integer> deserializeCalls = new ArrayList<>(); PendingFederation pendingFederation = buildMockPendingFederation(100, 200, 300); PowerMockito.mockStatic(BridgeSerializationUtils.class); Repo... | public PendingFederation getPendingFederation() { if (pendingFederation != null || shouldSavePendingFederation) { return pendingFederation; } Optional<Integer> storageVersion = getStorageVersion(PENDING_FEDERATION_FORMAT_VERSION); pendingFederation = safeGetFromRepository(PENDING_FEDERATION_KEY, data -> data == null ? ... | BridgeStorageProvider { public PendingFederation getPendingFederation() { if (pendingFederation != null || shouldSavePendingFederation) { return pendingFederation; } Optional<Integer> storageVersion = getStorageVersion(PENDING_FEDERATION_FORMAT_VERSION); pendingFederation = safeGetFromRepository(PENDING_FEDERATION_KEY,... | BridgeStorageProvider { public PendingFederation getPendingFederation() { if (pendingFederation != null || shouldSavePendingFederation) { return pendingFederation; } Optional<Integer> storageVersion = getStorageVersion(PENDING_FEDERATION_FORMAT_VERSION); pendingFederation = safeGetFromRepository(PENDING_FEDERATION_KEY,... | BridgeStorageProvider { public PendingFederation getPendingFederation() { if (pendingFederation != null || shouldSavePendingFederation) { return pendingFederation; } Optional<Integer> storageVersion = getStorageVersion(PENDING_FEDERATION_FORMAT_VERSION); pendingFederation = safeGetFromRepository(PENDING_FEDERATION_KEY,... | BridgeStorageProvider { public PendingFederation getPendingFederation() { if (pendingFederation != null || shouldSavePendingFederation) { return pendingFederation; } Optional<Integer> storageVersion = getStorageVersion(PENDING_FEDERATION_FORMAT_VERSION); pendingFederation = safeGetFromRepository(PENDING_FEDERATION_KEY,... |
@Test public void getPendingFederation_multiKeyVersion_nullBytes() throws IOException { List<Integer> storageCalls = new ArrayList<>(); PowerMockito.mockStatic(BridgeSerializationUtils.class); Repository repositoryMock = mock(Repository.class); BridgeStorageProvider storageProvider = new BridgeStorageProvider(repositor... | public PendingFederation getPendingFederation() { if (pendingFederation != null || shouldSavePendingFederation) { return pendingFederation; } Optional<Integer> storageVersion = getStorageVersion(PENDING_FEDERATION_FORMAT_VERSION); pendingFederation = safeGetFromRepository(PENDING_FEDERATION_KEY, data -> data == null ? ... | BridgeStorageProvider { public PendingFederation getPendingFederation() { if (pendingFederation != null || shouldSavePendingFederation) { return pendingFederation; } Optional<Integer> storageVersion = getStorageVersion(PENDING_FEDERATION_FORMAT_VERSION); pendingFederation = safeGetFromRepository(PENDING_FEDERATION_KEY,... | BridgeStorageProvider { public PendingFederation getPendingFederation() { if (pendingFederation != null || shouldSavePendingFederation) { return pendingFederation; } Optional<Integer> storageVersion = getStorageVersion(PENDING_FEDERATION_FORMAT_VERSION); pendingFederation = safeGetFromRepository(PENDING_FEDERATION_KEY,... | BridgeStorageProvider { public PendingFederation getPendingFederation() { if (pendingFederation != null || shouldSavePendingFederation) { return pendingFederation; } Optional<Integer> storageVersion = getStorageVersion(PENDING_FEDERATION_FORMAT_VERSION); pendingFederation = safeGetFromRepository(PENDING_FEDERATION_KEY,... | BridgeStorageProvider { public PendingFederation getPendingFederation() { if (pendingFederation != null || shouldSavePendingFederation) { return pendingFederation; } Optional<Integer> storageVersion = getStorageVersion(PENDING_FEDERATION_FORMAT_VERSION); pendingFederation = safeGetFromRepository(PENDING_FEDERATION_KEY,... |
@Test public void getFederationElection_nonNullBytes() throws IOException { List<Integer> calls = new ArrayList<>(); AddressBasedAuthorizer authorizerMock = mock(AddressBasedAuthorizer.class); ABICallElection electionMock = mock(ABICallElection.class); PowerMockito.mockStatic(BridgeSerializationUtils.class); Repository... | public ABICallElection getFederationElection(AddressBasedAuthorizer authorizer) { if (federationElection != null) { return federationElection; } federationElection = safeGetFromRepository(FEDERATION_ELECTION_KEY, data -> (data == null)? new ABICallElection(authorizer) : BridgeSerializationUtils.deserializeElection(data... | BridgeStorageProvider { public ABICallElection getFederationElection(AddressBasedAuthorizer authorizer) { if (federationElection != null) { return federationElection; } federationElection = safeGetFromRepository(FEDERATION_ELECTION_KEY, data -> (data == null)? new ABICallElection(authorizer) : BridgeSerializationUtils.... | BridgeStorageProvider { public ABICallElection getFederationElection(AddressBasedAuthorizer authorizer) { if (federationElection != null) { return federationElection; } federationElection = safeGetFromRepository(FEDERATION_ELECTION_KEY, data -> (data == null)? new ABICallElection(authorizer) : BridgeSerializationUtils.... | BridgeStorageProvider { public ABICallElection getFederationElection(AddressBasedAuthorizer authorizer) { if (federationElection != null) { return federationElection; } federationElection = safeGetFromRepository(FEDERATION_ELECTION_KEY, data -> (data == null)? new ABICallElection(authorizer) : BridgeSerializationUtils.... | BridgeStorageProvider { public ABICallElection getFederationElection(AddressBasedAuthorizer authorizer) { if (federationElection != null) { return federationElection; } federationElection = safeGetFromRepository(FEDERATION_ELECTION_KEY, data -> (data == null)? new ABICallElection(authorizer) : BridgeSerializationUtils.... |
@Test public void getFederationElection_nullBytes() throws IOException { List<Integer> calls = new ArrayList<>(); AddressBasedAuthorizer authorizerMock = mock(AddressBasedAuthorizer.class); ABICallElection electionMock = mock(ABICallElection.class); PowerMockito.mockStatic(BridgeSerializationUtils.class); Repository re... | public ABICallElection getFederationElection(AddressBasedAuthorizer authorizer) { if (federationElection != null) { return federationElection; } federationElection = safeGetFromRepository(FEDERATION_ELECTION_KEY, data -> (data == null)? new ABICallElection(authorizer) : BridgeSerializationUtils.deserializeElection(data... | BridgeStorageProvider { public ABICallElection getFederationElection(AddressBasedAuthorizer authorizer) { if (federationElection != null) { return federationElection; } federationElection = safeGetFromRepository(FEDERATION_ELECTION_KEY, data -> (data == null)? new ABICallElection(authorizer) : BridgeSerializationUtils.... | BridgeStorageProvider { public ABICallElection getFederationElection(AddressBasedAuthorizer authorizer) { if (federationElection != null) { return federationElection; } federationElection = safeGetFromRepository(FEDERATION_ELECTION_KEY, data -> (data == null)? new ABICallElection(authorizer) : BridgeSerializationUtils.... | BridgeStorageProvider { public ABICallElection getFederationElection(AddressBasedAuthorizer authorizer) { if (federationElection != null) { return federationElection; } federationElection = safeGetFromRepository(FEDERATION_ELECTION_KEY, data -> (data == null)? new ABICallElection(authorizer) : BridgeSerializationUtils.... | BridgeStorageProvider { public ABICallElection getFederationElection(AddressBasedAuthorizer authorizer) { if (federationElection != null) { return federationElection; } federationElection = safeGetFromRepository(FEDERATION_ELECTION_KEY, data -> (data == null)? new ABICallElection(authorizer) : BridgeSerializationUtils.... |
@Test public void saveFederationElection() throws IOException { ABICallElection electionMock = mock(ABICallElection.class); List<Integer> storageBytesCalls = new ArrayList<>(); List<Integer> serializeCalls = new ArrayList<>(); PowerMockito.mockStatic(BridgeSerializationUtils.class); Repository repositoryMock = mock(Rep... | public void saveFederationElection() { if (federationElection == null) { return; } safeSaveToRepository(FEDERATION_ELECTION_KEY, federationElection, BridgeSerializationUtils::serializeElection); } | BridgeStorageProvider { public void saveFederationElection() { if (federationElection == null) { return; } safeSaveToRepository(FEDERATION_ELECTION_KEY, federationElection, BridgeSerializationUtils::serializeElection); } } | BridgeStorageProvider { public void saveFederationElection() { if (federationElection == null) { return; } safeSaveToRepository(FEDERATION_ELECTION_KEY, federationElection, BridgeSerializationUtils::serializeElection); } BridgeStorageProvider(Repository repository, RskAddress contractAddress, BridgeConstants bridgeCons... | BridgeStorageProvider { public void saveFederationElection() { if (federationElection == null) { return; } safeSaveToRepository(FEDERATION_ELECTION_KEY, federationElection, BridgeSerializationUtils::serializeElection); } BridgeStorageProvider(Repository repository, RskAddress contractAddress, BridgeConstants bridgeCons... | BridgeStorageProvider { public void saveFederationElection() { if (federationElection == null) { return; } safeSaveToRepository(FEDERATION_ELECTION_KEY, federationElection, BridgeSerializationUtils::serializeElection); } BridgeStorageProvider(Repository repository, RskAddress contractAddress, BridgeConstants bridgeCons... |
@Test public void test4() { byte[] expected = {(byte) 0x80}; byte[] data = encodeByte((byte) 0); assertArrayEquals(expected, data); byte[] expected2 = {(byte) 0x78}; data = encodeByte((byte) 120); assertArrayEquals(expected2, data); byte[] expected3 = {(byte) 0x7F}; data = encodeByte((byte) 127); assertArrayEquals(expe... | public static byte[] encodeByte(byte singleByte) { if ((singleByte & 0xFF) == 0) { return new byte[]{(byte) OFFSET_SHORT_ITEM}; } else if ((singleByte & 0xFF) <= 0x7F) { return new byte[]{singleByte}; } else { return new byte[]{(byte) (OFFSET_SHORT_ITEM + 1), singleByte}; } } | RLP { public static byte[] encodeByte(byte singleByte) { if ((singleByte & 0xFF) == 0) { return new byte[]{(byte) OFFSET_SHORT_ITEM}; } else if ((singleByte & 0xFF) <= 0x7F) { return new byte[]{singleByte}; } else { return new byte[]{(byte) (OFFSET_SHORT_ITEM + 1), singleByte}; } } } | RLP { public static byte[] encodeByte(byte singleByte) { if ((singleByte & 0xFF) == 0) { return new byte[]{(byte) OFFSET_SHORT_ITEM}; } else if ((singleByte & 0xFF) <= 0x7F) { return new byte[]{singleByte}; } else { return new byte[]{(byte) (OFFSET_SHORT_ITEM + 1), singleByte}; } } } | RLP { public static byte[] encodeByte(byte singleByte) { if ((singleByte & 0xFF) == 0) { return new byte[]{(byte) OFFSET_SHORT_ITEM}; } else if ((singleByte & 0xFF) <= 0x7F) { return new byte[]{singleByte}; } else { return new byte[]{(byte) (OFFSET_SHORT_ITEM + 1), singleByte}; } } static int decodeInt(byte[] data, in... | RLP { public static byte[] encodeByte(byte singleByte) { if ((singleByte & 0xFF) == 0) { return new byte[]{(byte) OFFSET_SHORT_ITEM}; } else if ((singleByte & 0xFF) <= 0x7F) { return new byte[]{singleByte}; } else { return new byte[]{(byte) (OFFSET_SHORT_ITEM + 1), singleByte}; } } static int decodeInt(byte[] data, in... |
@Test public void getLockWhitelist_nonNullBytes() { List<Integer> calls = new ArrayList<>(); LockWhitelist whitelistMock = new LockWhitelist(new HashMap<>()); LockWhitelistEntry oneOffEntry = new OneOffWhiteListEntry(getBtcAddress("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"), Coin.COIN); LockWhitelistEntry unlimitedEntr... | public LockWhitelist getLockWhitelist() { if (lockWhitelist != null) { return lockWhitelist; } Pair<HashMap<Address, OneOffWhiteListEntry>, Integer> oneOffWhitelistAndDisableBlockHeightData = safeGetFromRepository(LOCK_ONE_OFF_WHITELIST_KEY, data -> BridgeSerializationUtils.deserializeOneOffLockWhitelistAndDisableBlock... | BridgeStorageProvider { public LockWhitelist getLockWhitelist() { if (lockWhitelist != null) { return lockWhitelist; } Pair<HashMap<Address, OneOffWhiteListEntry>, Integer> oneOffWhitelistAndDisableBlockHeightData = safeGetFromRepository(LOCK_ONE_OFF_WHITELIST_KEY, data -> BridgeSerializationUtils.deserializeOneOffLock... | BridgeStorageProvider { public LockWhitelist getLockWhitelist() { if (lockWhitelist != null) { return lockWhitelist; } Pair<HashMap<Address, OneOffWhiteListEntry>, Integer> oneOffWhitelistAndDisableBlockHeightData = safeGetFromRepository(LOCK_ONE_OFF_WHITELIST_KEY, data -> BridgeSerializationUtils.deserializeOneOffLock... | BridgeStorageProvider { public LockWhitelist getLockWhitelist() { if (lockWhitelist != null) { return lockWhitelist; } Pair<HashMap<Address, OneOffWhiteListEntry>, Integer> oneOffWhitelistAndDisableBlockHeightData = safeGetFromRepository(LOCK_ONE_OFF_WHITELIST_KEY, data -> BridgeSerializationUtils.deserializeOneOffLock... | BridgeStorageProvider { public LockWhitelist getLockWhitelist() { if (lockWhitelist != null) { return lockWhitelist; } Pair<HashMap<Address, OneOffWhiteListEntry>, Integer> oneOffWhitelistAndDisableBlockHeightData = safeGetFromRepository(LOCK_ONE_OFF_WHITELIST_KEY, data -> BridgeSerializationUtils.deserializeOneOffLock... |
@Test public void getLockWhitelist_nullBytes() { List<Integer> calls = new ArrayList<>(); PowerMockito.mockStatic(BridgeSerializationUtils.class); Repository repositoryMock = mock(Repository.class); BridgeStorageProvider storageProvider = new BridgeStorageProvider(repositoryMock, mockAddress("aabbccdd"), config.getNetw... | public LockWhitelist getLockWhitelist() { if (lockWhitelist != null) { return lockWhitelist; } Pair<HashMap<Address, OneOffWhiteListEntry>, Integer> oneOffWhitelistAndDisableBlockHeightData = safeGetFromRepository(LOCK_ONE_OFF_WHITELIST_KEY, data -> BridgeSerializationUtils.deserializeOneOffLockWhitelistAndDisableBlock... | BridgeStorageProvider { public LockWhitelist getLockWhitelist() { if (lockWhitelist != null) { return lockWhitelist; } Pair<HashMap<Address, OneOffWhiteListEntry>, Integer> oneOffWhitelistAndDisableBlockHeightData = safeGetFromRepository(LOCK_ONE_OFF_WHITELIST_KEY, data -> BridgeSerializationUtils.deserializeOneOffLock... | BridgeStorageProvider { public LockWhitelist getLockWhitelist() { if (lockWhitelist != null) { return lockWhitelist; } Pair<HashMap<Address, OneOffWhiteListEntry>, Integer> oneOffWhitelistAndDisableBlockHeightData = safeGetFromRepository(LOCK_ONE_OFF_WHITELIST_KEY, data -> BridgeSerializationUtils.deserializeOneOffLock... | BridgeStorageProvider { public LockWhitelist getLockWhitelist() { if (lockWhitelist != null) { return lockWhitelist; } Pair<HashMap<Address, OneOffWhiteListEntry>, Integer> oneOffWhitelistAndDisableBlockHeightData = safeGetFromRepository(LOCK_ONE_OFF_WHITELIST_KEY, data -> BridgeSerializationUtils.deserializeOneOffLock... | BridgeStorageProvider { public LockWhitelist getLockWhitelist() { if (lockWhitelist != null) { return lockWhitelist; } Pair<HashMap<Address, OneOffWhiteListEntry>, Integer> oneOffWhitelistAndDisableBlockHeightData = safeGetFromRepository(LOCK_ONE_OFF_WHITELIST_KEY, data -> BridgeSerializationUtils.deserializeOneOffLock... |
@Test public void saveLockWhitelist() { LockWhitelist whitelistMock = mock(LockWhitelist.class); List<Integer> storageBytesCalls = new ArrayList<>(); List<Integer> serializeCalls = new ArrayList<>(); PowerMockito.mockStatic(BridgeSerializationUtils.class); Repository repositoryMock = mock(Repository.class); BridgeStora... | public void saveLockWhitelist() { if (lockWhitelist == null) { return; } List<OneOffWhiteListEntry> oneOffEntries = lockWhitelist.getAll(OneOffWhiteListEntry.class); safeSaveToRepository(LOCK_ONE_OFF_WHITELIST_KEY, Pair.of(oneOffEntries, lockWhitelist.getDisableBlockHeight()), BridgeSerializationUtils::serializeOneOffL... | BridgeStorageProvider { public void saveLockWhitelist() { if (lockWhitelist == null) { return; } List<OneOffWhiteListEntry> oneOffEntries = lockWhitelist.getAll(OneOffWhiteListEntry.class); safeSaveToRepository(LOCK_ONE_OFF_WHITELIST_KEY, Pair.of(oneOffEntries, lockWhitelist.getDisableBlockHeight()), BridgeSerializatio... | BridgeStorageProvider { public void saveLockWhitelist() { if (lockWhitelist == null) { return; } List<OneOffWhiteListEntry> oneOffEntries = lockWhitelist.getAll(OneOffWhiteListEntry.class); safeSaveToRepository(LOCK_ONE_OFF_WHITELIST_KEY, Pair.of(oneOffEntries, lockWhitelist.getDisableBlockHeight()), BridgeSerializatio... | BridgeStorageProvider { public void saveLockWhitelist() { if (lockWhitelist == null) { return; } List<OneOffWhiteListEntry> oneOffEntries = lockWhitelist.getAll(OneOffWhiteListEntry.class); safeSaveToRepository(LOCK_ONE_OFF_WHITELIST_KEY, Pair.of(oneOffEntries, lockWhitelist.getDisableBlockHeight()), BridgeSerializatio... | BridgeStorageProvider { public void saveLockWhitelist() { if (lockWhitelist == null) { return; } List<OneOffWhiteListEntry> oneOffEntries = lockWhitelist.getAll(OneOffWhiteListEntry.class); safeSaveToRepository(LOCK_ONE_OFF_WHITELIST_KEY, Pair.of(oneOffEntries, lockWhitelist.getDisableBlockHeight()), BridgeSerializatio... |
@Test public void getReleaseRequestQueue_before_rskip_146_activation() throws IOException { Repository repositoryMock = mock(Repository.class); BridgeStorageProvider storageProvider = new BridgeStorageProvider(repositoryMock, mockAddress("aabbccdd"), config.getNetworkConstants().getBridgeConstants(), activationsBeforeF... | public ReleaseRequestQueue getReleaseRequestQueue() throws IOException { if (releaseRequestQueue != null) { return releaseRequestQueue; } List<ReleaseRequestQueue.Entry> entries = new ArrayList<>(); entries.addAll(getFromRepository( RELEASE_REQUEST_QUEUE, data -> BridgeSerializationUtils.deserializeReleaseRequestQueue(... | BridgeStorageProvider { public ReleaseRequestQueue getReleaseRequestQueue() throws IOException { if (releaseRequestQueue != null) { return releaseRequestQueue; } List<ReleaseRequestQueue.Entry> entries = new ArrayList<>(); entries.addAll(getFromRepository( RELEASE_REQUEST_QUEUE, data -> BridgeSerializationUtils.deseria... | BridgeStorageProvider { public ReleaseRequestQueue getReleaseRequestQueue() throws IOException { if (releaseRequestQueue != null) { return releaseRequestQueue; } List<ReleaseRequestQueue.Entry> entries = new ArrayList<>(); entries.addAll(getFromRepository( RELEASE_REQUEST_QUEUE, data -> BridgeSerializationUtils.deseria... | BridgeStorageProvider { public ReleaseRequestQueue getReleaseRequestQueue() throws IOException { if (releaseRequestQueue != null) { return releaseRequestQueue; } List<ReleaseRequestQueue.Entry> entries = new ArrayList<>(); entries.addAll(getFromRepository( RELEASE_REQUEST_QUEUE, data -> BridgeSerializationUtils.deseria... | BridgeStorageProvider { public ReleaseRequestQueue getReleaseRequestQueue() throws IOException { if (releaseRequestQueue != null) { return releaseRequestQueue; } List<ReleaseRequestQueue.Entry> entries = new ArrayList<>(); entries.addAll(getFromRepository( RELEASE_REQUEST_QUEUE, data -> BridgeSerializationUtils.deseria... |
@Test public void getReleaseRequestQueue_after_rskip_146_activation() throws IOException { ActivationConfig.ForBlock activations = mock(ActivationConfig.ForBlock.class); when(activations.isActive(ConsensusRule.RSKIP146)).thenReturn(true); ReleaseRequestQueue.Entry oldEntry = new ReleaseRequestQueue.Entry( Address.fromB... | public ReleaseRequestQueue getReleaseRequestQueue() throws IOException { if (releaseRequestQueue != null) { return releaseRequestQueue; } List<ReleaseRequestQueue.Entry> entries = new ArrayList<>(); entries.addAll(getFromRepository( RELEASE_REQUEST_QUEUE, data -> BridgeSerializationUtils.deserializeReleaseRequestQueue(... | BridgeStorageProvider { public ReleaseRequestQueue getReleaseRequestQueue() throws IOException { if (releaseRequestQueue != null) { return releaseRequestQueue; } List<ReleaseRequestQueue.Entry> entries = new ArrayList<>(); entries.addAll(getFromRepository( RELEASE_REQUEST_QUEUE, data -> BridgeSerializationUtils.deseria... | BridgeStorageProvider { public ReleaseRequestQueue getReleaseRequestQueue() throws IOException { if (releaseRequestQueue != null) { return releaseRequestQueue; } List<ReleaseRequestQueue.Entry> entries = new ArrayList<>(); entries.addAll(getFromRepository( RELEASE_REQUEST_QUEUE, data -> BridgeSerializationUtils.deseria... | BridgeStorageProvider { public ReleaseRequestQueue getReleaseRequestQueue() throws IOException { if (releaseRequestQueue != null) { return releaseRequestQueue; } List<ReleaseRequestQueue.Entry> entries = new ArrayList<>(); entries.addAll(getFromRepository( RELEASE_REQUEST_QUEUE, data -> BridgeSerializationUtils.deseria... | BridgeStorageProvider { public ReleaseRequestQueue getReleaseRequestQueue() throws IOException { if (releaseRequestQueue != null) { return releaseRequestQueue; } List<ReleaseRequestQueue.Entry> entries = new ArrayList<>(); entries.addAll(getFromRepository( RELEASE_REQUEST_QUEUE, data -> BridgeSerializationUtils.deseria... |
@Test public void getReleaseTransactionSet_before_rskip_146_activation() throws IOException { Repository repositoryMock = mock(Repository.class); BridgeStorageProvider storageProvider = new BridgeStorageProvider(repositoryMock, mockAddress("aabbccdd"), config.getNetworkConstants().getBridgeConstants(), activationsBefor... | public ReleaseTransactionSet getReleaseTransactionSet() throws IOException { if (releaseTransactionSet != null) { return releaseTransactionSet; } Set<ReleaseTransactionSet.Entry> entries = new HashSet<>(getFromRepository(RELEASE_TX_SET, data -> BridgeSerializationUtils.deserializeReleaseTransactionSet(data, networkPara... | BridgeStorageProvider { public ReleaseTransactionSet getReleaseTransactionSet() throws IOException { if (releaseTransactionSet != null) { return releaseTransactionSet; } Set<ReleaseTransactionSet.Entry> entries = new HashSet<>(getFromRepository(RELEASE_TX_SET, data -> BridgeSerializationUtils.deserializeReleaseTransact... | BridgeStorageProvider { public ReleaseTransactionSet getReleaseTransactionSet() throws IOException { if (releaseTransactionSet != null) { return releaseTransactionSet; } Set<ReleaseTransactionSet.Entry> entries = new HashSet<>(getFromRepository(RELEASE_TX_SET, data -> BridgeSerializationUtils.deserializeReleaseTransact... | BridgeStorageProvider { public ReleaseTransactionSet getReleaseTransactionSet() throws IOException { if (releaseTransactionSet != null) { return releaseTransactionSet; } Set<ReleaseTransactionSet.Entry> entries = new HashSet<>(getFromRepository(RELEASE_TX_SET, data -> BridgeSerializationUtils.deserializeReleaseTransact... | BridgeStorageProvider { public ReleaseTransactionSet getReleaseTransactionSet() throws IOException { if (releaseTransactionSet != null) { return releaseTransactionSet; } Set<ReleaseTransactionSet.Entry> entries = new HashSet<>(getFromRepository(RELEASE_TX_SET, data -> BridgeSerializationUtils.deserializeReleaseTransact... |
@Test public void getReleaseTransactionSet_after_rskip_146_activation() throws IOException { ActivationConfig.ForBlock activations = mock(ActivationConfig.ForBlock.class); when(activations.isActive(ConsensusRule.RSKIP146)).thenReturn(true); Set<ReleaseTransactionSet.Entry> oldEntriesSet = new HashSet<>(Collections.sing... | public ReleaseTransactionSet getReleaseTransactionSet() throws IOException { if (releaseTransactionSet != null) { return releaseTransactionSet; } Set<ReleaseTransactionSet.Entry> entries = new HashSet<>(getFromRepository(RELEASE_TX_SET, data -> BridgeSerializationUtils.deserializeReleaseTransactionSet(data, networkPara... | BridgeStorageProvider { public ReleaseTransactionSet getReleaseTransactionSet() throws IOException { if (releaseTransactionSet != null) { return releaseTransactionSet; } Set<ReleaseTransactionSet.Entry> entries = new HashSet<>(getFromRepository(RELEASE_TX_SET, data -> BridgeSerializationUtils.deserializeReleaseTransact... | BridgeStorageProvider { public ReleaseTransactionSet getReleaseTransactionSet() throws IOException { if (releaseTransactionSet != null) { return releaseTransactionSet; } Set<ReleaseTransactionSet.Entry> entries = new HashSet<>(getFromRepository(RELEASE_TX_SET, data -> BridgeSerializationUtils.deserializeReleaseTransact... | BridgeStorageProvider { public ReleaseTransactionSet getReleaseTransactionSet() throws IOException { if (releaseTransactionSet != null) { return releaseTransactionSet; } Set<ReleaseTransactionSet.Entry> entries = new HashSet<>(getFromRepository(RELEASE_TX_SET, data -> BridgeSerializationUtils.deserializeReleaseTransact... | BridgeStorageProvider { public ReleaseTransactionSet getReleaseTransactionSet() throws IOException { if (releaseTransactionSet != null) { return releaseTransactionSet; } Set<ReleaseTransactionSet.Entry> entries = new HashSet<>(getFromRepository(RELEASE_TX_SET, data -> BridgeSerializationUtils.deserializeReleaseTransact... |
@Test public void getFeePerKbElection_emptyVotes() { AddressBasedAuthorizer authorizerMock = mock(AddressBasedAuthorizer.class); Repository repositoryMock = mock(Repository.class); BridgeStorageProvider storageProvider = new BridgeStorageProvider(repositoryMock, mockAddress("aabbccdd"), config.getNetworkConstants().get... | public ABICallElection getFeePerKbElection(AddressBasedAuthorizer authorizer) { if (feePerKbElection != null) { return feePerKbElection; } feePerKbElection = safeGetFromRepository(FEE_PER_KB_ELECTION_KEY, data -> BridgeSerializationUtils.deserializeElection(data, authorizer)); return feePerKbElection; } | BridgeStorageProvider { public ABICallElection getFeePerKbElection(AddressBasedAuthorizer authorizer) { if (feePerKbElection != null) { return feePerKbElection; } feePerKbElection = safeGetFromRepository(FEE_PER_KB_ELECTION_KEY, data -> BridgeSerializationUtils.deserializeElection(data, authorizer)); return feePerKbEle... | BridgeStorageProvider { public ABICallElection getFeePerKbElection(AddressBasedAuthorizer authorizer) { if (feePerKbElection != null) { return feePerKbElection; } feePerKbElection = safeGetFromRepository(FEE_PER_KB_ELECTION_KEY, data -> BridgeSerializationUtils.deserializeElection(data, authorizer)); return feePerKbEle... | BridgeStorageProvider { public ABICallElection getFeePerKbElection(AddressBasedAuthorizer authorizer) { if (feePerKbElection != null) { return feePerKbElection; } feePerKbElection = safeGetFromRepository(FEE_PER_KB_ELECTION_KEY, data -> BridgeSerializationUtils.deserializeElection(data, authorizer)); return feePerKbEle... | BridgeStorageProvider { public ABICallElection getFeePerKbElection(AddressBasedAuthorizer authorizer) { if (feePerKbElection != null) { return feePerKbElection; } feePerKbElection = safeGetFromRepository(FEE_PER_KB_ELECTION_KEY, data -> BridgeSerializationUtils.deserializeElection(data, authorizer)); return feePerKbEle... |
@Test public void getFeePerKbElection_withVotes() { AddressBasedAuthorizer authorizerMock = mock(AddressBasedAuthorizer.class); Repository repositoryMock = mock(Repository.class); when(authorizerMock.getRequiredAuthorizedKeys()) .thenReturn(1); when(authorizerMock.isAuthorized(any(RskAddress.class))) .thenReturn(true);... | public ABICallElection getFeePerKbElection(AddressBasedAuthorizer authorizer) { if (feePerKbElection != null) { return feePerKbElection; } feePerKbElection = safeGetFromRepository(FEE_PER_KB_ELECTION_KEY, data -> BridgeSerializationUtils.deserializeElection(data, authorizer)); return feePerKbElection; } | BridgeStorageProvider { public ABICallElection getFeePerKbElection(AddressBasedAuthorizer authorizer) { if (feePerKbElection != null) { return feePerKbElection; } feePerKbElection = safeGetFromRepository(FEE_PER_KB_ELECTION_KEY, data -> BridgeSerializationUtils.deserializeElection(data, authorizer)); return feePerKbEle... | BridgeStorageProvider { public ABICallElection getFeePerKbElection(AddressBasedAuthorizer authorizer) { if (feePerKbElection != null) { return feePerKbElection; } feePerKbElection = safeGetFromRepository(FEE_PER_KB_ELECTION_KEY, data -> BridgeSerializationUtils.deserializeElection(data, authorizer)); return feePerKbEle... | BridgeStorageProvider { public ABICallElection getFeePerKbElection(AddressBasedAuthorizer authorizer) { if (feePerKbElection != null) { return feePerKbElection; } feePerKbElection = safeGetFromRepository(FEE_PER_KB_ELECTION_KEY, data -> BridgeSerializationUtils.deserializeElection(data, authorizer)); return feePerKbEle... | BridgeStorageProvider { public ABICallElection getFeePerKbElection(AddressBasedAuthorizer authorizer) { if (feePerKbElection != null) { return feePerKbElection; } feePerKbElection = safeGetFromRepository(FEE_PER_KB_ELECTION_KEY, data -> BridgeSerializationUtils.deserializeElection(data, authorizer)); return feePerKbEle... |
@Test public void getLockingCap_before_fork() { Repository repository = mock(Repository.class); when(repository.getStorageBytes(PrecompiledContracts.BRIDGE_ADDR, DataWord.fromString("lockingCap"))).thenReturn(new byte[] { 1 }); BridgeStorageProvider provider0 = new BridgeStorageProvider( repository, PrecompiledContract... | public Coin getLockingCap() { if (activations.isActive(RSKIP134)) { if (this.lockingCap == null) { this.lockingCap = safeGetFromRepository(LOCKING_CAP_KEY, BridgeSerializationUtils::deserializeCoin); } return this.lockingCap; } return null; } | BridgeStorageProvider { public Coin getLockingCap() { if (activations.isActive(RSKIP134)) { if (this.lockingCap == null) { this.lockingCap = safeGetFromRepository(LOCKING_CAP_KEY, BridgeSerializationUtils::deserializeCoin); } return this.lockingCap; } return null; } } | BridgeStorageProvider { public Coin getLockingCap() { if (activations.isActive(RSKIP134)) { if (this.lockingCap == null) { this.lockingCap = safeGetFromRepository(LOCKING_CAP_KEY, BridgeSerializationUtils::deserializeCoin); } return this.lockingCap; } return null; } BridgeStorageProvider(Repository repository, RskAddre... | BridgeStorageProvider { public Coin getLockingCap() { if (activations.isActive(RSKIP134)) { if (this.lockingCap == null) { this.lockingCap = safeGetFromRepository(LOCKING_CAP_KEY, BridgeSerializationUtils::deserializeCoin); } return this.lockingCap; } return null; } BridgeStorageProvider(Repository repository, RskAddre... | BridgeStorageProvider { public Coin getLockingCap() { if (activations.isActive(RSKIP134)) { if (this.lockingCap == null) { this.lockingCap = safeGetFromRepository(LOCKING_CAP_KEY, BridgeSerializationUtils::deserializeCoin); } return this.lockingCap; } return null; } BridgeStorageProvider(Repository repository, RskAddre... |
@Test public void test5() { byte[] expected = {(byte) 0x80}; byte[] data = encodeShort((byte) 0); assertArrayEquals(expected, data); byte[] expected2 = {(byte) 0x78}; data = encodeShort((byte) 120); assertArrayEquals(expected2, data); byte[] expected3 = { (byte) 0x7F}; data = encodeShort((byte) 127); assertArrayEquals(... | public static byte[] encodeShort(short singleShort) { if ((singleShort & 0xFF) == singleShort) { return encodeByte((byte) singleShort); } else { return new byte[]{(byte) (OFFSET_SHORT_ITEM + 2), (byte) (singleShort >> 8 & 0xFF), (byte) (singleShort >> 0 & 0xFF)}; } } | RLP { public static byte[] encodeShort(short singleShort) { if ((singleShort & 0xFF) == singleShort) { return encodeByte((byte) singleShort); } else { return new byte[]{(byte) (OFFSET_SHORT_ITEM + 2), (byte) (singleShort >> 8 & 0xFF), (byte) (singleShort >> 0 & 0xFF)}; } } } | RLP { public static byte[] encodeShort(short singleShort) { if ((singleShort & 0xFF) == singleShort) { return encodeByte((byte) singleShort); } else { return new byte[]{(byte) (OFFSET_SHORT_ITEM + 2), (byte) (singleShort >> 8 & 0xFF), (byte) (singleShort >> 0 & 0xFF)}; } } } | RLP { public static byte[] encodeShort(short singleShort) { if ((singleShort & 0xFF) == singleShort) { return encodeByte((byte) singleShort); } else { return new byte[]{(byte) (OFFSET_SHORT_ITEM + 2), (byte) (singleShort >> 8 & 0xFF), (byte) (singleShort >> 0 & 0xFF)}; } } static int decodeInt(byte[] data, int index);... | RLP { public static byte[] encodeShort(short singleShort) { if ((singleShort & 0xFF) == singleShort) { return encodeByte((byte) singleShort); } else { return new byte[]{(byte) (OFFSET_SHORT_ITEM + 2), (byte) (singleShort >> 8 & 0xFF), (byte) (singleShort >> 0 & 0xFF)}; } } static int decodeInt(byte[] data, int index);... |
@Test public void getLockingCap_after_fork() { Repository repository = mock(Repository.class); when(repository.getStorageBytes(PrecompiledContracts.BRIDGE_ADDR, DataWord.fromString("lockingCap"))).thenReturn(new byte[] { 1 }); BridgeStorageProvider provider0 = new BridgeStorageProvider( repository, PrecompiledContracts... | public Coin getLockingCap() { if (activations.isActive(RSKIP134)) { if (this.lockingCap == null) { this.lockingCap = safeGetFromRepository(LOCKING_CAP_KEY, BridgeSerializationUtils::deserializeCoin); } return this.lockingCap; } return null; } | BridgeStorageProvider { public Coin getLockingCap() { if (activations.isActive(RSKIP134)) { if (this.lockingCap == null) { this.lockingCap = safeGetFromRepository(LOCKING_CAP_KEY, BridgeSerializationUtils::deserializeCoin); } return this.lockingCap; } return null; } } | BridgeStorageProvider { public Coin getLockingCap() { if (activations.isActive(RSKIP134)) { if (this.lockingCap == null) { this.lockingCap = safeGetFromRepository(LOCKING_CAP_KEY, BridgeSerializationUtils::deserializeCoin); } return this.lockingCap; } return null; } BridgeStorageProvider(Repository repository, RskAddre... | BridgeStorageProvider { public Coin getLockingCap() { if (activations.isActive(RSKIP134)) { if (this.lockingCap == null) { this.lockingCap = safeGetFromRepository(LOCKING_CAP_KEY, BridgeSerializationUtils::deserializeCoin); } return this.lockingCap; } return null; } BridgeStorageProvider(Repository repository, RskAddre... | BridgeStorageProvider { public Coin getLockingCap() { if (activations.isActive(RSKIP134)) { if (this.lockingCap == null) { this.lockingCap = safeGetFromRepository(LOCKING_CAP_KEY, BridgeSerializationUtils::deserializeCoin); } return this.lockingCap; } return null; } BridgeStorageProvider(Repository repository, RskAddre... |
@Test public void getHeightIfBtcTxhashIsAlreadyProcessed_before_RSKIP134_does_not_use_new_storage() throws IOException { Repository repository = mock(Repository.class); Sha256Hash hash = Sha256Hash.ZERO_HASH; HashMap<Sha256Hash, Long> hashes = new HashMap<>(); hashes.put(hash, 1L); when(repository.getStorageBytes(Preco... | public Optional<Long> getHeightIfBtcTxhashIsAlreadyProcessed(Sha256Hash btcTxHash) throws IOException { Map<Sha256Hash, Long> processed = getBtcTxHashesAlreadyProcessed(); if (processed.containsKey(btcTxHash)) { return Optional.of(processed.get(btcTxHash)); } if (!activations.isActive(RSKIP134)) { return Optional.empty... | BridgeStorageProvider { public Optional<Long> getHeightIfBtcTxhashIsAlreadyProcessed(Sha256Hash btcTxHash) throws IOException { Map<Sha256Hash, Long> processed = getBtcTxHashesAlreadyProcessed(); if (processed.containsKey(btcTxHash)) { return Optional.of(processed.get(btcTxHash)); } if (!activations.isActive(RSKIP134))... | BridgeStorageProvider { public Optional<Long> getHeightIfBtcTxhashIsAlreadyProcessed(Sha256Hash btcTxHash) throws IOException { Map<Sha256Hash, Long> processed = getBtcTxHashesAlreadyProcessed(); if (processed.containsKey(btcTxHash)) { return Optional.of(processed.get(btcTxHash)); } if (!activations.isActive(RSKIP134))... | BridgeStorageProvider { public Optional<Long> getHeightIfBtcTxhashIsAlreadyProcessed(Sha256Hash btcTxHash) throws IOException { Map<Sha256Hash, Long> processed = getBtcTxHashesAlreadyProcessed(); if (processed.containsKey(btcTxHash)) { return Optional.of(processed.get(btcTxHash)); } if (!activations.isActive(RSKIP134))... | BridgeStorageProvider { public Optional<Long> getHeightIfBtcTxhashIsAlreadyProcessed(Sha256Hash btcTxHash) throws IOException { Map<Sha256Hash, Long> processed = getBtcTxHashesAlreadyProcessed(); if (processed.containsKey(btcTxHash)) { return Optional.of(processed.get(btcTxHash)); } if (!activations.isActive(RSKIP134))... |
@Test public void getHeightIfBtcTxhashIsAlreadyProcessed_after_RSKIP134_uses_new_storage() throws IOException { Repository repository = mock(Repository.class); Sha256Hash hash1 = Sha256Hash.ZERO_HASH; Sha256Hash hash2 = Sha256Hash.wrap("0000000000000000000000000000000000000000000000000000000000000001"); HashMap<Sha256H... | public Optional<Long> getHeightIfBtcTxhashIsAlreadyProcessed(Sha256Hash btcTxHash) throws IOException { Map<Sha256Hash, Long> processed = getBtcTxHashesAlreadyProcessed(); if (processed.containsKey(btcTxHash)) { return Optional.of(processed.get(btcTxHash)); } if (!activations.isActive(RSKIP134)) { return Optional.empty... | BridgeStorageProvider { public Optional<Long> getHeightIfBtcTxhashIsAlreadyProcessed(Sha256Hash btcTxHash) throws IOException { Map<Sha256Hash, Long> processed = getBtcTxHashesAlreadyProcessed(); if (processed.containsKey(btcTxHash)) { return Optional.of(processed.get(btcTxHash)); } if (!activations.isActive(RSKIP134))... | BridgeStorageProvider { public Optional<Long> getHeightIfBtcTxhashIsAlreadyProcessed(Sha256Hash btcTxHash) throws IOException { Map<Sha256Hash, Long> processed = getBtcTxHashesAlreadyProcessed(); if (processed.containsKey(btcTxHash)) { return Optional.of(processed.get(btcTxHash)); } if (!activations.isActive(RSKIP134))... | BridgeStorageProvider { public Optional<Long> getHeightIfBtcTxhashIsAlreadyProcessed(Sha256Hash btcTxHash) throws IOException { Map<Sha256Hash, Long> processed = getBtcTxHashesAlreadyProcessed(); if (processed.containsKey(btcTxHash)) { return Optional.of(processed.get(btcTxHash)); } if (!activations.isActive(RSKIP134))... | BridgeStorageProvider { public Optional<Long> getHeightIfBtcTxhashIsAlreadyProcessed(Sha256Hash btcTxHash) throws IOException { Map<Sha256Hash, Long> processed = getBtcTxHashesAlreadyProcessed(); if (processed.containsKey(btcTxHash)) { return Optional.of(processed.get(btcTxHash)); } if (!activations.isActive(RSKIP134))... |
@Test public void saveHeightBtcTxHashAlreadyProcessed() throws IOException { Repository repository = mock(Repository.class); Sha256Hash hash = Sha256Hash.ZERO_HASH; BridgeStorageProvider provider0 = new BridgeStorageProvider( repository, PrecompiledContracts.BRIDGE_ADDR, config.getNetworkConstants().getBridgeConstants(... | public void saveHeightBtcTxHashAlreadyProcessed() { if (btcTxHashesToSave == null) { return; } btcTxHashesToSave.forEach((btcTxHash, height) -> safeSaveToRepository(getStorageKeyForBtcTxHashAlreadyProcessed(btcTxHash), height, BridgeSerializationUtils::serializeLong) ); } | BridgeStorageProvider { public void saveHeightBtcTxHashAlreadyProcessed() { if (btcTxHashesToSave == null) { return; } btcTxHashesToSave.forEach((btcTxHash, height) -> safeSaveToRepository(getStorageKeyForBtcTxHashAlreadyProcessed(btcTxHash), height, BridgeSerializationUtils::serializeLong) ); } } | BridgeStorageProvider { public void saveHeightBtcTxHashAlreadyProcessed() { if (btcTxHashesToSave == null) { return; } btcTxHashesToSave.forEach((btcTxHash, height) -> safeSaveToRepository(getStorageKeyForBtcTxHashAlreadyProcessed(btcTxHash), height, BridgeSerializationUtils::serializeLong) ); } BridgeStorageProvider(R... | BridgeStorageProvider { public void saveHeightBtcTxHashAlreadyProcessed() { if (btcTxHashesToSave == null) { return; } btcTxHashesToSave.forEach((btcTxHash, height) -> safeSaveToRepository(getStorageKeyForBtcTxHashAlreadyProcessed(btcTxHash), height, BridgeSerializationUtils::serializeLong) ); } BridgeStorageProvider(R... | BridgeStorageProvider { public void saveHeightBtcTxHashAlreadyProcessed() { if (btcTxHashesToSave == null) { return; } btcTxHashesToSave.forEach((btcTxHash, height) -> safeSaveToRepository(getStorageKeyForBtcTxHashAlreadyProcessed(btcTxHash), height, BridgeSerializationUtils::serializeLong) ); } BridgeStorageProvider(R... |
@Test public void getCoinBaseInformation_before_RSKIP143() { Repository repository = mock(Repository.class); Sha256Hash hash = Sha256Hash.ZERO_HASH; BridgeStorageProvider provider = new BridgeStorageProvider( repository, PrecompiledContracts.BRIDGE_ADDR, config.getNetworkConstants().getBridgeConstants(), activationsBef... | public CoinbaseInformation getCoinbaseInformation(Sha256Hash blockHash) { if (!activations.isActive(RSKIP143)) { return null; } if (coinbaseInformationMap == null) { coinbaseInformationMap = new HashMap<>(); } if (coinbaseInformationMap.containsKey(blockHash)) { return coinbaseInformationMap.get(blockHash); } CoinbaseI... | BridgeStorageProvider { public CoinbaseInformation getCoinbaseInformation(Sha256Hash blockHash) { if (!activations.isActive(RSKIP143)) { return null; } if (coinbaseInformationMap == null) { coinbaseInformationMap = new HashMap<>(); } if (coinbaseInformationMap.containsKey(blockHash)) { return coinbaseInformationMap.get... | BridgeStorageProvider { public CoinbaseInformation getCoinbaseInformation(Sha256Hash blockHash) { if (!activations.isActive(RSKIP143)) { return null; } if (coinbaseInformationMap == null) { coinbaseInformationMap = new HashMap<>(); } if (coinbaseInformationMap.containsKey(blockHash)) { return coinbaseInformationMap.get... | BridgeStorageProvider { public CoinbaseInformation getCoinbaseInformation(Sha256Hash blockHash) { if (!activations.isActive(RSKIP143)) { return null; } if (coinbaseInformationMap == null) { coinbaseInformationMap = new HashMap<>(); } if (coinbaseInformationMap.containsKey(blockHash)) { return coinbaseInformationMap.get... | BridgeStorageProvider { public CoinbaseInformation getCoinbaseInformation(Sha256Hash blockHash) { if (!activations.isActive(RSKIP143)) { return null; } if (coinbaseInformationMap == null) { coinbaseInformationMap = new HashMap<>(); } if (coinbaseInformationMap.containsKey(blockHash)) { return coinbaseInformationMap.get... |
@Test public void getCoinBaseInformation_after_RSKIP143() { Repository repository = mock(Repository.class); Sha256Hash hash = Sha256Hash.ZERO_HASH; CoinbaseInformation coinbaseInformation = new CoinbaseInformation(Sha256Hash.ZERO_HASH); when(repository.getStorageBytes(PrecompiledContracts.BRIDGE_ADDR, DataWord.fromLong... | public CoinbaseInformation getCoinbaseInformation(Sha256Hash blockHash) { if (!activations.isActive(RSKIP143)) { return null; } if (coinbaseInformationMap == null) { coinbaseInformationMap = new HashMap<>(); } if (coinbaseInformationMap.containsKey(blockHash)) { return coinbaseInformationMap.get(blockHash); } CoinbaseI... | BridgeStorageProvider { public CoinbaseInformation getCoinbaseInformation(Sha256Hash blockHash) { if (!activations.isActive(RSKIP143)) { return null; } if (coinbaseInformationMap == null) { coinbaseInformationMap = new HashMap<>(); } if (coinbaseInformationMap.containsKey(blockHash)) { return coinbaseInformationMap.get... | BridgeStorageProvider { public CoinbaseInformation getCoinbaseInformation(Sha256Hash blockHash) { if (!activations.isActive(RSKIP143)) { return null; } if (coinbaseInformationMap == null) { coinbaseInformationMap = new HashMap<>(); } if (coinbaseInformationMap.containsKey(blockHash)) { return coinbaseInformationMap.get... | BridgeStorageProvider { public CoinbaseInformation getCoinbaseInformation(Sha256Hash blockHash) { if (!activations.isActive(RSKIP143)) { return null; } if (coinbaseInformationMap == null) { coinbaseInformationMap = new HashMap<>(); } if (coinbaseInformationMap.containsKey(blockHash)) { return coinbaseInformationMap.get... | BridgeStorageProvider { public CoinbaseInformation getCoinbaseInformation(Sha256Hash blockHash) { if (!activations.isActive(RSKIP143)) { return null; } if (coinbaseInformationMap == null) { coinbaseInformationMap = new HashMap<>(); } if (coinbaseInformationMap.containsKey(blockHash)) { return coinbaseInformationMap.get... |
@Test public void membersImmutable() { boolean exception = false; try { federation.getMembers().add(new FederationMember(new BtcECKey(), new ECKey(), new ECKey())); } catch (Exception e) { exception = true; } Assert.assertTrue(exception); exception = false; try { federation.getMembers().remove(0); } catch (Exception e)... | public List<FederationMember> getMembers() { return members; } | Federation { public List<FederationMember> getMembers() { return members; } } | Federation { public List<FederationMember> getMembers() { return members; } Federation(List<FederationMember> members, Instant creationTime, long creationBlockNumber, NetworkParameters btcParams); } | Federation { public List<FederationMember> getMembers() { return members; } Federation(List<FederationMember> members, Instant creationTime, long creationBlockNumber, NetworkParameters btcParams); List<FederationMember> getMembers(); List<BtcECKey> getBtcPublicKeys(); int getNumberOfSignaturesRequired(); Instant getCr... | Federation { public List<FederationMember> getMembers() { return members; } Federation(List<FederationMember> members, Instant creationTime, long creationBlockNumber, NetworkParameters btcParams); List<FederationMember> getMembers(); List<BtcECKey> getBtcPublicKeys(); int getNumberOfSignaturesRequired(); Instant getCr... |
@Test public void testEquals_basic() { Assert.assertTrue(federation.equals(federation)); Assert.assertFalse(federation.equals(null)); Assert.assertFalse(federation.equals(new Object())); Assert.assertFalse(federation.equals("something else")); } | @Override public boolean equals(Object other) { if (this == other) { return true; } if (other == null || this.getClass() != other.getClass()) { return false; } Federation otherFederation = (Federation) other; return this.getNumberOfSignaturesRequired() == otherFederation.getNumberOfSignaturesRequired() && this.getSize(... | Federation { @Override public boolean equals(Object other) { if (this == other) { return true; } if (other == null || this.getClass() != other.getClass()) { return false; } Federation otherFederation = (Federation) other; return this.getNumberOfSignaturesRequired() == otherFederation.getNumberOfSignaturesRequired() && ... | Federation { @Override public boolean equals(Object other) { if (this == other) { return true; } if (other == null || this.getClass() != other.getClass()) { return false; } Federation otherFederation = (Federation) other; return this.getNumberOfSignaturesRequired() == otherFederation.getNumberOfSignaturesRequired() && ... | Federation { @Override public boolean equals(Object other) { if (this == other) { return true; } if (other == null || this.getClass() != other.getClass()) { return false; } Federation otherFederation = (Federation) other; return this.getNumberOfSignaturesRequired() == otherFederation.getNumberOfSignaturesRequired() && ... | Federation { @Override public boolean equals(Object other) { if (this == other) { return true; } if (other == null || this.getClass() != other.getClass()) { return false; } Federation otherFederation = (Federation) other; return this.getNumberOfSignaturesRequired() == otherFederation.getNumberOfSignaturesRequired() && ... |
@Test public void testEquals_differentNumberOfMembers() { Federation otherFederation = new Federation( FederationTestUtils.getFederationMembersFromPks(100, 200, 300, 400, 500, 600, 700), ZonedDateTime.parse("2017-06-10T02:30:00Z").toInstant(), 0L, NetworkParameters.fromID(NetworkParameters.ID_REGTEST) ); Assert.assertF... | @Override public boolean equals(Object other) { if (this == other) { return true; } if (other == null || this.getClass() != other.getClass()) { return false; } Federation otherFederation = (Federation) other; return this.getNumberOfSignaturesRequired() == otherFederation.getNumberOfSignaturesRequired() && this.getSize(... | Federation { @Override public boolean equals(Object other) { if (this == other) { return true; } if (other == null || this.getClass() != other.getClass()) { return false; } Federation otherFederation = (Federation) other; return this.getNumberOfSignaturesRequired() == otherFederation.getNumberOfSignaturesRequired() && ... | Federation { @Override public boolean equals(Object other) { if (this == other) { return true; } if (other == null || this.getClass() != other.getClass()) { return false; } Federation otherFederation = (Federation) other; return this.getNumberOfSignaturesRequired() == otherFederation.getNumberOfSignaturesRequired() && ... | Federation { @Override public boolean equals(Object other) { if (this == other) { return true; } if (other == null || this.getClass() != other.getClass()) { return false; } Federation otherFederation = (Federation) other; return this.getNumberOfSignaturesRequired() == otherFederation.getNumberOfSignaturesRequired() && ... | Federation { @Override public boolean equals(Object other) { if (this == other) { return true; } if (other == null || this.getClass() != other.getClass()) { return false; } Federation otherFederation = (Federation) other; return this.getNumberOfSignaturesRequired() == otherFederation.getNumberOfSignaturesRequired() && ... |
@Test public void testEquals_differentCreationTime() { Federation otherFederation = new Federation( FederationTestUtils.getFederationMembersFromPks(100, 200, 300, 400, 500, 600), ZonedDateTime.parse("2017-06-10T02:30:01Z").toInstant(), 0L, NetworkParameters.fromID(NetworkParameters.ID_REGTEST) ); Assert.assertFalse(fed... | @Override public boolean equals(Object other) { if (this == other) { return true; } if (other == null || this.getClass() != other.getClass()) { return false; } Federation otherFederation = (Federation) other; return this.getNumberOfSignaturesRequired() == otherFederation.getNumberOfSignaturesRequired() && this.getSize(... | Federation { @Override public boolean equals(Object other) { if (this == other) { return true; } if (other == null || this.getClass() != other.getClass()) { return false; } Federation otherFederation = (Federation) other; return this.getNumberOfSignaturesRequired() == otherFederation.getNumberOfSignaturesRequired() && ... | Federation { @Override public boolean equals(Object other) { if (this == other) { return true; } if (other == null || this.getClass() != other.getClass()) { return false; } Federation otherFederation = (Federation) other; return this.getNumberOfSignaturesRequired() == otherFederation.getNumberOfSignaturesRequired() && ... | Federation { @Override public boolean equals(Object other) { if (this == other) { return true; } if (other == null || this.getClass() != other.getClass()) { return false; } Federation otherFederation = (Federation) other; return this.getNumberOfSignaturesRequired() == otherFederation.getNumberOfSignaturesRequired() && ... | Federation { @Override public boolean equals(Object other) { if (this == other) { return true; } if (other == null || this.getClass() != other.getClass()) { return false; } Federation otherFederation = (Federation) other; return this.getNumberOfSignaturesRequired() == otherFederation.getNumberOfSignaturesRequired() && ... |
@Test public void testEncodeInt() { byte[] expected = {(byte) 0x80}; byte[] data = encodeInt(0); assertArrayEquals(expected, data); assertEquals(0, RLP.decodeInt(data, 0)); byte[] expected2 = {(byte) 0x78}; data = encodeInt(120); assertArrayEquals(expected2, data); assertEquals(120, RLP.decodeInt(data, 0)); byte[] expe... | 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 testEquals_differentNetworkParameters() { Federation otherFederation = new Federation( FederationTestUtils.getFederationMembersFromPks(100, 200, 300, 400, 500, 600), ZonedDateTime.parse("2017-06-10T02:30:00Z").toInstant(), 0L, NetworkParameters.fromID(NetworkParameters.ID_TESTNET) ); Assert.assertFals... | @Override public boolean equals(Object other) { if (this == other) { return true; } if (other == null || this.getClass() != other.getClass()) { return false; } Federation otherFederation = (Federation) other; return this.getNumberOfSignaturesRequired() == otherFederation.getNumberOfSignaturesRequired() && this.getSize(... | Federation { @Override public boolean equals(Object other) { if (this == other) { return true; } if (other == null || this.getClass() != other.getClass()) { return false; } Federation otherFederation = (Federation) other; return this.getNumberOfSignaturesRequired() == otherFederation.getNumberOfSignaturesRequired() && ... | Federation { @Override public boolean equals(Object other) { if (this == other) { return true; } if (other == null || this.getClass() != other.getClass()) { return false; } Federation otherFederation = (Federation) other; return this.getNumberOfSignaturesRequired() == otherFederation.getNumberOfSignaturesRequired() && ... | Federation { @Override public boolean equals(Object other) { if (this == other) { return true; } if (other == null || this.getClass() != other.getClass()) { return false; } Federation otherFederation = (Federation) other; return this.getNumberOfSignaturesRequired() == otherFederation.getNumberOfSignaturesRequired() && ... | Federation { @Override public boolean equals(Object other) { if (this == other) { return true; } if (other == null || this.getClass() != other.getClass()) { return false; } Federation otherFederation = (Federation) other; return this.getNumberOfSignaturesRequired() == otherFederation.getNumberOfSignaturesRequired() && ... |
@Test public void testEquals_differentMembers() { List<FederationMember> members = FederationTestUtils.getFederationMembersFromPks(100, 200, 300, 400, 500); members.add(new FederationMember(BtcECKey.fromPrivate(BigInteger.valueOf(610)), ECKey.fromPrivate(BigInteger.valueOf(600)), ECKey.fromPrivate(BigInteger.valueOf(62... | @Override public boolean equals(Object other) { if (this == other) { return true; } if (other == null || this.getClass() != other.getClass()) { return false; } Federation otherFederation = (Federation) other; return this.getNumberOfSignaturesRequired() == otherFederation.getNumberOfSignaturesRequired() && this.getSize(... | Federation { @Override public boolean equals(Object other) { if (this == other) { return true; } if (other == null || this.getClass() != other.getClass()) { return false; } Federation otherFederation = (Federation) other; return this.getNumberOfSignaturesRequired() == otherFederation.getNumberOfSignaturesRequired() && ... | Federation { @Override public boolean equals(Object other) { if (this == other) { return true; } if (other == null || this.getClass() != other.getClass()) { return false; } Federation otherFederation = (Federation) other; return this.getNumberOfSignaturesRequired() == otherFederation.getNumberOfSignaturesRequired() && ... | Federation { @Override public boolean equals(Object other) { if (this == other) { return true; } if (other == null || this.getClass() != other.getClass()) { return false; } Federation otherFederation = (Federation) other; return this.getNumberOfSignaturesRequired() == otherFederation.getNumberOfSignaturesRequired() && ... | Federation { @Override public boolean equals(Object other) { if (this == other) { return true; } if (other == null || this.getClass() != other.getClass()) { return false; } Federation otherFederation = (Federation) other; return this.getNumberOfSignaturesRequired() == otherFederation.getNumberOfSignaturesRequired() && ... |
@Test public void testEquals_same() { Federation otherFederation = new Federation( FederationTestUtils.getFederationMembersFromPks(100, 200, 300, 400, 500, 600), ZonedDateTime.parse("2017-06-10T02:30:00Z").toInstant(), 0L, NetworkParameters.fromID(NetworkParameters.ID_REGTEST) ); Assert.assertTrue(federation.equals(oth... | @Override public boolean equals(Object other) { if (this == other) { return true; } if (other == null || this.getClass() != other.getClass()) { return false; } Federation otherFederation = (Federation) other; return this.getNumberOfSignaturesRequired() == otherFederation.getNumberOfSignaturesRequired() && this.getSize(... | Federation { @Override public boolean equals(Object other) { if (this == other) { return true; } if (other == null || this.getClass() != other.getClass()) { return false; } Federation otherFederation = (Federation) other; return this.getNumberOfSignaturesRequired() == otherFederation.getNumberOfSignaturesRequired() && ... | Federation { @Override public boolean equals(Object other) { if (this == other) { return true; } if (other == null || this.getClass() != other.getClass()) { return false; } Federation otherFederation = (Federation) other; return this.getNumberOfSignaturesRequired() == otherFederation.getNumberOfSignaturesRequired() && ... | Federation { @Override public boolean equals(Object other) { if (this == other) { return true; } if (other == null || this.getClass() != other.getClass()) { return false; } Federation otherFederation = (Federation) other; return this.getNumberOfSignaturesRequired() == otherFederation.getNumberOfSignaturesRequired() && ... | Federation { @Override public boolean equals(Object other) { if (this == other) { return true; } if (other == null || this.getClass() != other.getClass()) { return false; } Federation otherFederation = (Federation) other; return this.getNumberOfSignaturesRequired() == otherFederation.getNumberOfSignaturesRequired() && ... |
@Test public void getBtcPublicKeyIndex() { for (int i = 0; i < federation.getBtcPublicKeys().size(); i++) { Assert.assertEquals(i, federation.getBtcPublicKeyIndex(sortedPublicKeys.get(i)).intValue()); } Assert.assertNull(federation.getBtcPublicKeyIndex(BtcECKey.fromPrivate(BigInteger.valueOf(1234)))); } | public Integer getBtcPublicKeyIndex(BtcECKey key) { for (int i = 0; i < members.size(); i++) { if (Arrays.equals(key.getPubKey(), members.get(i).getBtcPublicKey().getPubKey())) { return i; } } return null; } | Federation { public Integer getBtcPublicKeyIndex(BtcECKey key) { for (int i = 0; i < members.size(); i++) { if (Arrays.equals(key.getPubKey(), members.get(i).getBtcPublicKey().getPubKey())) { return i; } } return null; } } | Federation { public Integer getBtcPublicKeyIndex(BtcECKey key) { for (int i = 0; i < members.size(); i++) { if (Arrays.equals(key.getPubKey(), members.get(i).getBtcPublicKey().getPubKey())) { return i; } } return null; } Federation(List<FederationMember> members, Instant creationTime, long creationBlockNumber, Network... | Federation { public Integer getBtcPublicKeyIndex(BtcECKey key) { for (int i = 0; i < members.size(); i++) { if (Arrays.equals(key.getPubKey(), members.get(i).getBtcPublicKey().getPubKey())) { return i; } } return null; } Federation(List<FederationMember> members, Instant creationTime, long creationBlockNumber, Network... | Federation { public Integer getBtcPublicKeyIndex(BtcECKey key) { for (int i = 0; i < members.size(); i++) { if (Arrays.equals(key.getPubKey(), members.get(i).getBtcPublicKey().getPubKey())) { return i; } } return null; } Federation(List<FederationMember> members, Instant creationTime, long creationBlockNumber, Network... |
@Test public void hasBtcPublicKey() { for (int i = 0; i < federation.getBtcPublicKeys().size(); i++) { Assert.assertTrue(federation.hasBtcPublicKey(sortedPublicKeys.get(i))); } Assert.assertFalse(federation.hasBtcPublicKey(BtcECKey.fromPrivate(BigInteger.valueOf(1234)))); } | public boolean hasBtcPublicKey(BtcECKey key) { return getBtcPublicKeyIndex(key) != null; } | Federation { public boolean hasBtcPublicKey(BtcECKey key) { return getBtcPublicKeyIndex(key) != null; } } | Federation { public boolean hasBtcPublicKey(BtcECKey key) { return getBtcPublicKeyIndex(key) != null; } Federation(List<FederationMember> members, Instant creationTime, long creationBlockNumber, NetworkParameters btcParams); } | Federation { public boolean hasBtcPublicKey(BtcECKey key) { return getBtcPublicKeyIndex(key) != null; } Federation(List<FederationMember> members, Instant creationTime, long creationBlockNumber, NetworkParameters btcParams); List<FederationMember> getMembers(); List<BtcECKey> getBtcPublicKeys(); int getNumberOfSignatu... | Federation { public boolean hasBtcPublicKey(BtcECKey key) { return getBtcPublicKeyIndex(key) != null; } Federation(List<FederationMember> members, Instant creationTime, long creationBlockNumber, NetworkParameters btcParams); List<FederationMember> getMembers(); List<BtcECKey> getBtcPublicKeys(); int getNumberOfSignatu... |
@Test public void hasMemberWithRskAddress() { for (int i = 0; i < federation.getBtcPublicKeys().size(); i++) { Assert.assertTrue(federation.hasMemberWithRskAddress(rskAddresses.get(i))); } byte[] nonFederateRskAddress = ECKey.fromPrivate(BigInteger.valueOf(1234)).getAddress(); Assert.assertFalse(federation.hasMemberWit... | public boolean hasMemberWithRskAddress(byte[] address) { return members.stream() .anyMatch(m -> Arrays.equals(m.getRskPublicKey().getAddress(), address)); } | Federation { public boolean hasMemberWithRskAddress(byte[] address) { return members.stream() .anyMatch(m -> Arrays.equals(m.getRskPublicKey().getAddress(), address)); } } | Federation { public boolean hasMemberWithRskAddress(byte[] address) { return members.stream() .anyMatch(m -> Arrays.equals(m.getRskPublicKey().getAddress(), address)); } Federation(List<FederationMember> members, Instant creationTime, long creationBlockNumber, NetworkParameters btcParams); } | Federation { public boolean hasMemberWithRskAddress(byte[] address) { return members.stream() .anyMatch(m -> Arrays.equals(m.getRskPublicKey().getAddress(), address)); } Federation(List<FederationMember> members, Instant creationTime, long creationBlockNumber, NetworkParameters btcParams); List<FederationMember> getMe... | Federation { public boolean hasMemberWithRskAddress(byte[] address) { return members.stream() .anyMatch(m -> Arrays.equals(m.getRskPublicKey().getAddress(), address)); } Federation(List<FederationMember> members, Instant creationTime, long creationBlockNumber, NetworkParameters btcParams); List<FederationMember> getMe... |
@Test public void testToString() { Assert.assertEquals("4 of 6 signatures federation", federation.toString()); } | @Override public String toString() { return String.format("%d of %d signatures federation", getNumberOfSignaturesRequired(), members.size()); } | Federation { @Override public String toString() { return String.format("%d of %d signatures federation", getNumberOfSignaturesRequired(), members.size()); } } | Federation { @Override public String toString() { return String.format("%d of %d signatures federation", getNumberOfSignaturesRequired(), members.size()); } Federation(List<FederationMember> members, Instant creationTime, long creationBlockNumber, NetworkParameters btcParams); } | Federation { @Override public String toString() { return String.format("%d of %d signatures federation", getNumberOfSignaturesRequired(), members.size()); } Federation(List<FederationMember> members, Instant creationTime, long creationBlockNumber, NetworkParameters btcParams); List<FederationMember> getMembers(); List... | Federation { @Override public String toString() { return String.format("%d of %d signatures federation", getNumberOfSignaturesRequired(), members.size()); } Federation(List<FederationMember> members, Instant creationTime, long creationBlockNumber, NetworkParameters btcParams); List<FederationMember> getMembers(); List... |
@Test public void isMember(){ FederationMember federationMember = federation.getMembers().get(0); Assert.assertTrue(federation.isMember(federationMember)); byte[] b = new byte[20]; new Random().nextBytes(b); ECKey invalidRskKey = ECKey.fromPrivate(b); BtcECKey invalidBtcKey = BtcECKey.fromPrivate(b); FederationMember i... | public boolean isMember(FederationMember federationMember){ return this.members.contains(federationMember); } | Federation { public boolean isMember(FederationMember federationMember){ return this.members.contains(federationMember); } } | Federation { public boolean isMember(FederationMember federationMember){ return this.members.contains(federationMember); } Federation(List<FederationMember> members, Instant creationTime, long creationBlockNumber, NetworkParameters btcParams); } | Federation { public boolean isMember(FederationMember federationMember){ return this.members.contains(federationMember); } Federation(List<FederationMember> members, Instant creationTime, long creationBlockNumber, NetworkParameters btcParams); List<FederationMember> getMembers(); List<BtcECKey> getBtcPublicKeys(); int... | Federation { public boolean isMember(FederationMember federationMember){ return this.members.contains(federationMember); } Federation(List<FederationMember> members, Instant creationTime, long creationBlockNumber, NetworkParameters btcParams); List<FederationMember> getMembers(); List<BtcECKey> getBtcPublicKeys(); int... |
@Test public void buildAmountTo_ok() throws InsufficientMoneyException, UTXOProviderException { Context btcContext = new Context(NetworkParameters.fromID(NetworkParameters.ID_REGTEST)); Address to = mockAddress(123); Coin amount = Coin.CENT.multiply(3); List<UTXO> availableUTXOs = Arrays.asList( mockUTXO("one", 0, Coin... | public Optional<BuildResult> buildAmountTo(Address to, Coin amount) { return buildWithConfiguration((SendRequest sr) -> { sr.tx.addOutput(amount, to); sr.changeAddress = changeAddress; }, String.format("sending %s to %s", amount, to)); } | ReleaseTransactionBuilder { public Optional<BuildResult> buildAmountTo(Address to, Coin amount) { return buildWithConfiguration((SendRequest sr) -> { sr.tx.addOutput(amount, to); sr.changeAddress = changeAddress; }, String.format("sending %s to %s", amount, to)); } } | ReleaseTransactionBuilder { public Optional<BuildResult> buildAmountTo(Address to, Coin amount) { return buildWithConfiguration((SendRequest sr) -> { sr.tx.addOutput(amount, to); sr.changeAddress = changeAddress; }, String.format("sending %s to %s", amount, to)); } ReleaseTransactionBuilder(NetworkParameters params, Wa... | ReleaseTransactionBuilder { public Optional<BuildResult> buildAmountTo(Address to, Coin amount) { return buildWithConfiguration((SendRequest sr) -> { sr.tx.addOutput(amount, to); sr.changeAddress = changeAddress; }, String.format("sending %s to %s", amount, to)); } ReleaseTransactionBuilder(NetworkParameters params, Wa... | ReleaseTransactionBuilder { public Optional<BuildResult> buildAmountTo(Address to, Coin amount) { return buildWithConfiguration((SendRequest sr) -> { sr.tx.addOutput(amount, to); sr.changeAddress = changeAddress; }, String.format("sending %s to %s", amount, to)); } ReleaseTransactionBuilder(NetworkParameters params, Wa... |
@Test public void buildAmountTo_insufficientMoneyException() throws InsufficientMoneyException, UTXOProviderException { Context btcContext = new Context(NetworkParameters.fromID(NetworkParameters.ID_REGTEST)); Address to = mockAddress(123); Coin amount = Coin.CENT.multiply(3); mockCompleteTxWithThrowForBuildToAmount(wa... | public Optional<BuildResult> buildAmountTo(Address to, Coin amount) { return buildWithConfiguration((SendRequest sr) -> { sr.tx.addOutput(amount, to); sr.changeAddress = changeAddress; }, String.format("sending %s to %s", amount, to)); } | ReleaseTransactionBuilder { public Optional<BuildResult> buildAmountTo(Address to, Coin amount) { return buildWithConfiguration((SendRequest sr) -> { sr.tx.addOutput(amount, to); sr.changeAddress = changeAddress; }, String.format("sending %s to %s", amount, to)); } } | ReleaseTransactionBuilder { public Optional<BuildResult> buildAmountTo(Address to, Coin amount) { return buildWithConfiguration((SendRequest sr) -> { sr.tx.addOutput(amount, to); sr.changeAddress = changeAddress; }, String.format("sending %s to %s", amount, to)); } ReleaseTransactionBuilder(NetworkParameters params, Wa... | ReleaseTransactionBuilder { public Optional<BuildResult> buildAmountTo(Address to, Coin amount) { return buildWithConfiguration((SendRequest sr) -> { sr.tx.addOutput(amount, to); sr.changeAddress = changeAddress; }, String.format("sending %s to %s", amount, to)); } ReleaseTransactionBuilder(NetworkParameters params, Wa... | ReleaseTransactionBuilder { public Optional<BuildResult> buildAmountTo(Address to, Coin amount) { return buildWithConfiguration((SendRequest sr) -> { sr.tx.addOutput(amount, to); sr.changeAddress = changeAddress; }, String.format("sending %s to %s", amount, to)); } ReleaseTransactionBuilder(NetworkParameters params, Wa... |
@Test public void test6() { byte[] expected = new byte[]{(byte) 0x80}; byte[] data = encodeBigInteger(BigInteger.ZERO); assertArrayEquals(expected, data); } | public static byte[] encodeBigInteger(BigInteger srcBigInteger) { if (srcBigInteger.equals(BigInteger.ZERO)) { return encodeByte((byte) 0); } else { return encodeElement(asUnsignedByteArray(srcBigInteger)); } } | RLP { public static byte[] encodeBigInteger(BigInteger srcBigInteger) { if (srcBigInteger.equals(BigInteger.ZERO)) { return encodeByte((byte) 0); } else { return encodeElement(asUnsignedByteArray(srcBigInteger)); } } } | RLP { public static byte[] encodeBigInteger(BigInteger srcBigInteger) { if (srcBigInteger.equals(BigInteger.ZERO)) { return encodeByte((byte) 0); } else { return encodeElement(asUnsignedByteArray(srcBigInteger)); } } } | RLP { public static byte[] encodeBigInteger(BigInteger srcBigInteger) { if (srcBigInteger.equals(BigInteger.ZERO)) { return encodeByte((byte) 0); } else { return encodeElement(asUnsignedByteArray(srcBigInteger)); } } static int decodeInt(byte[] data, int index); static BigInteger decodeBigInteger(byte[] data, int inde... | RLP { public static byte[] encodeBigInteger(BigInteger srcBigInteger) { if (srcBigInteger.equals(BigInteger.ZERO)) { return encodeByte((byte) 0); } else { return encodeElement(asUnsignedByteArray(srcBigInteger)); } } static int decodeInt(byte[] data, int index); static BigInteger decodeBigInteger(byte[] data, int inde... |
@Test public void buildAmountTo_walletCouldNotAdjustDownwards() throws InsufficientMoneyException, UTXOProviderException { Context btcContext = new Context(NetworkParameters.fromID(NetworkParameters.ID_REGTEST)); Address to = mockAddress(123); Coin amount = Coin.CENT.multiply(3); mockCompleteTxWithThrowForBuildToAmount... | public Optional<BuildResult> buildAmountTo(Address to, Coin amount) { return buildWithConfiguration((SendRequest sr) -> { sr.tx.addOutput(amount, to); sr.changeAddress = changeAddress; }, String.format("sending %s to %s", amount, to)); } | ReleaseTransactionBuilder { public Optional<BuildResult> buildAmountTo(Address to, Coin amount) { return buildWithConfiguration((SendRequest sr) -> { sr.tx.addOutput(amount, to); sr.changeAddress = changeAddress; }, String.format("sending %s to %s", amount, to)); } } | ReleaseTransactionBuilder { public Optional<BuildResult> buildAmountTo(Address to, Coin amount) { return buildWithConfiguration((SendRequest sr) -> { sr.tx.addOutput(amount, to); sr.changeAddress = changeAddress; }, String.format("sending %s to %s", amount, to)); } ReleaseTransactionBuilder(NetworkParameters params, Wa... | ReleaseTransactionBuilder { public Optional<BuildResult> buildAmountTo(Address to, Coin amount) { return buildWithConfiguration((SendRequest sr) -> { sr.tx.addOutput(amount, to); sr.changeAddress = changeAddress; }, String.format("sending %s to %s", amount, to)); } ReleaseTransactionBuilder(NetworkParameters params, Wa... | ReleaseTransactionBuilder { public Optional<BuildResult> buildAmountTo(Address to, Coin amount) { return buildWithConfiguration((SendRequest sr) -> { sr.tx.addOutput(amount, to); sr.changeAddress = changeAddress; }, String.format("sending %s to %s", amount, to)); } ReleaseTransactionBuilder(NetworkParameters params, Wa... |
@Test public void buildAmountTo_walletExceededMaxTransactionSize() throws InsufficientMoneyException, UTXOProviderException { Context btcContext = new Context(NetworkParameters.fromID(NetworkParameters.ID_REGTEST)); Address to = mockAddress(123); Coin amount = Coin.CENT.multiply(3); mockCompleteTxWithThrowForBuildToAmo... | public Optional<BuildResult> buildAmountTo(Address to, Coin amount) { return buildWithConfiguration((SendRequest sr) -> { sr.tx.addOutput(amount, to); sr.changeAddress = changeAddress; }, String.format("sending %s to %s", amount, to)); } | ReleaseTransactionBuilder { public Optional<BuildResult> buildAmountTo(Address to, Coin amount) { return buildWithConfiguration((SendRequest sr) -> { sr.tx.addOutput(amount, to); sr.changeAddress = changeAddress; }, String.format("sending %s to %s", amount, to)); } } | ReleaseTransactionBuilder { public Optional<BuildResult> buildAmountTo(Address to, Coin amount) { return buildWithConfiguration((SendRequest sr) -> { sr.tx.addOutput(amount, to); sr.changeAddress = changeAddress; }, String.format("sending %s to %s", amount, to)); } ReleaseTransactionBuilder(NetworkParameters params, Wa... | ReleaseTransactionBuilder { public Optional<BuildResult> buildAmountTo(Address to, Coin amount) { return buildWithConfiguration((SendRequest sr) -> { sr.tx.addOutput(amount, to); sr.changeAddress = changeAddress; }, String.format("sending %s to %s", amount, to)); } ReleaseTransactionBuilder(NetworkParameters params, Wa... | ReleaseTransactionBuilder { public Optional<BuildResult> buildAmountTo(Address to, Coin amount) { return buildWithConfiguration((SendRequest sr) -> { sr.tx.addOutput(amount, to); sr.changeAddress = changeAddress; }, String.format("sending %s to %s", amount, to)); } ReleaseTransactionBuilder(NetworkParameters params, Wa... |
@Test public void buildAmountTo_utxoProviderException() throws InsufficientMoneyException, UTXOProviderException { Context btcContext = new Context(NetworkParameters.fromID(NetworkParameters.ID_REGTEST)); Address to = mockAddress(123); Coin amount = Coin.CENT.multiply(3); List<UTXO> availableUTXOs = Arrays.asList( mock... | public Optional<BuildResult> buildAmountTo(Address to, Coin amount) { return buildWithConfiguration((SendRequest sr) -> { sr.tx.addOutput(amount, to); sr.changeAddress = changeAddress; }, String.format("sending %s to %s", amount, to)); } | ReleaseTransactionBuilder { public Optional<BuildResult> buildAmountTo(Address to, Coin amount) { return buildWithConfiguration((SendRequest sr) -> { sr.tx.addOutput(amount, to); sr.changeAddress = changeAddress; }, String.format("sending %s to %s", amount, to)); } } | ReleaseTransactionBuilder { public Optional<BuildResult> buildAmountTo(Address to, Coin amount) { return buildWithConfiguration((SendRequest sr) -> { sr.tx.addOutput(amount, to); sr.changeAddress = changeAddress; }, String.format("sending %s to %s", amount, to)); } ReleaseTransactionBuilder(NetworkParameters params, Wa... | ReleaseTransactionBuilder { public Optional<BuildResult> buildAmountTo(Address to, Coin amount) { return buildWithConfiguration((SendRequest sr) -> { sr.tx.addOutput(amount, to); sr.changeAddress = changeAddress; }, String.format("sending %s to %s", amount, to)); } ReleaseTransactionBuilder(NetworkParameters params, Wa... | ReleaseTransactionBuilder { public Optional<BuildResult> buildAmountTo(Address to, Coin amount) { return buildWithConfiguration((SendRequest sr) -> { sr.tx.addOutput(amount, to); sr.changeAddress = changeAddress; }, String.format("sending %s to %s", amount, to)); } ReleaseTransactionBuilder(NetworkParameters params, Wa... |
@Test public void buildEmptyWalletTo_ok() throws InsufficientMoneyException, UTXOProviderException { Context btcContext = new Context(NetworkParameters.fromID(NetworkParameters.ID_REGTEST)); Address to = mockAddress(123); List<UTXO> availableUTXOs = Arrays.asList( mockUTXO("one", 0, Coin.COIN), mockUTXO("two", 2, Coin.... | public Optional<BuildResult> buildEmptyWalletTo(Address to) { return buildWithConfiguration((SendRequest sr) -> { sr.tx.addOutput(Coin.ZERO, to); sr.changeAddress = to; sr.emptyWallet = true; }, String.format("emptying wallet to %s", to)); } | ReleaseTransactionBuilder { public Optional<BuildResult> buildEmptyWalletTo(Address to) { return buildWithConfiguration((SendRequest sr) -> { sr.tx.addOutput(Coin.ZERO, to); sr.changeAddress = to; sr.emptyWallet = true; }, String.format("emptying wallet to %s", to)); } } | ReleaseTransactionBuilder { public Optional<BuildResult> buildEmptyWalletTo(Address to) { return buildWithConfiguration((SendRequest sr) -> { sr.tx.addOutput(Coin.ZERO, to); sr.changeAddress = to; sr.emptyWallet = true; }, String.format("emptying wallet to %s", to)); } ReleaseTransactionBuilder(NetworkParameters params... | ReleaseTransactionBuilder { public Optional<BuildResult> buildEmptyWalletTo(Address to) { return buildWithConfiguration((SendRequest sr) -> { sr.tx.addOutput(Coin.ZERO, to); sr.changeAddress = to; sr.emptyWallet = true; }, String.format("emptying wallet to %s", to)); } ReleaseTransactionBuilder(NetworkParameters params... | ReleaseTransactionBuilder { public Optional<BuildResult> buildEmptyWalletTo(Address to) { return buildWithConfiguration((SendRequest sr) -> { sr.tx.addOutput(Coin.ZERO, to); sr.changeAddress = to; sr.emptyWallet = true; }, String.format("emptying wallet to %s", to)); } ReleaseTransactionBuilder(NetworkParameters params... |
@Test public void buildEmptyWalletTo_insufficientMoneyException() throws InsufficientMoneyException, UTXOProviderException { Context btcContext = new Context(NetworkParameters.fromID(NetworkParameters.ID_REGTEST)); Address to = mockAddress(123); mockCompleteTxWithThrowForEmptying(wallet, to, new InsufficientMoneyExcept... | public Optional<BuildResult> buildEmptyWalletTo(Address to) { return buildWithConfiguration((SendRequest sr) -> { sr.tx.addOutput(Coin.ZERO, to); sr.changeAddress = to; sr.emptyWallet = true; }, String.format("emptying wallet to %s", to)); } | ReleaseTransactionBuilder { public Optional<BuildResult> buildEmptyWalletTo(Address to) { return buildWithConfiguration((SendRequest sr) -> { sr.tx.addOutput(Coin.ZERO, to); sr.changeAddress = to; sr.emptyWallet = true; }, String.format("emptying wallet to %s", to)); } } | ReleaseTransactionBuilder { public Optional<BuildResult> buildEmptyWalletTo(Address to) { return buildWithConfiguration((SendRequest sr) -> { sr.tx.addOutput(Coin.ZERO, to); sr.changeAddress = to; sr.emptyWallet = true; }, String.format("emptying wallet to %s", to)); } ReleaseTransactionBuilder(NetworkParameters params... | ReleaseTransactionBuilder { public Optional<BuildResult> buildEmptyWalletTo(Address to) { return buildWithConfiguration((SendRequest sr) -> { sr.tx.addOutput(Coin.ZERO, to); sr.changeAddress = to; sr.emptyWallet = true; }, String.format("emptying wallet to %s", to)); } ReleaseTransactionBuilder(NetworkParameters params... | ReleaseTransactionBuilder { public Optional<BuildResult> buildEmptyWalletTo(Address to) { return buildWithConfiguration((SendRequest sr) -> { sr.tx.addOutput(Coin.ZERO, to); sr.changeAddress = to; sr.emptyWallet = true; }, String.format("emptying wallet to %s", to)); } ReleaseTransactionBuilder(NetworkParameters params... |
@Test public void buildEmptyWalletTo_walletCouldNotAdjustDownwards() throws InsufficientMoneyException, UTXOProviderException { Context btcContext = new Context(NetworkParameters.fromID(NetworkParameters.ID_REGTEST)); Address to = mockAddress(123); mockCompleteTxWithThrowForEmptying(wallet, to, new Wallet.CouldNotAdjus... | public Optional<BuildResult> buildEmptyWalletTo(Address to) { return buildWithConfiguration((SendRequest sr) -> { sr.tx.addOutput(Coin.ZERO, to); sr.changeAddress = to; sr.emptyWallet = true; }, String.format("emptying wallet to %s", to)); } | ReleaseTransactionBuilder { public Optional<BuildResult> buildEmptyWalletTo(Address to) { return buildWithConfiguration((SendRequest sr) -> { sr.tx.addOutput(Coin.ZERO, to); sr.changeAddress = to; sr.emptyWallet = true; }, String.format("emptying wallet to %s", to)); } } | ReleaseTransactionBuilder { public Optional<BuildResult> buildEmptyWalletTo(Address to) { return buildWithConfiguration((SendRequest sr) -> { sr.tx.addOutput(Coin.ZERO, to); sr.changeAddress = to; sr.emptyWallet = true; }, String.format("emptying wallet to %s", to)); } ReleaseTransactionBuilder(NetworkParameters params... | ReleaseTransactionBuilder { public Optional<BuildResult> buildEmptyWalletTo(Address to) { return buildWithConfiguration((SendRequest sr) -> { sr.tx.addOutput(Coin.ZERO, to); sr.changeAddress = to; sr.emptyWallet = true; }, String.format("emptying wallet to %s", to)); } ReleaseTransactionBuilder(NetworkParameters params... | ReleaseTransactionBuilder { public Optional<BuildResult> buildEmptyWalletTo(Address to) { return buildWithConfiguration((SendRequest sr) -> { sr.tx.addOutput(Coin.ZERO, to); sr.changeAddress = to; sr.emptyWallet = true; }, String.format("emptying wallet to %s", to)); } ReleaseTransactionBuilder(NetworkParameters params... |
@Test public void buildEmptyWalletTo_walletExceededMaxTransactionSize() throws InsufficientMoneyException, UTXOProviderException { Context btcContext = new Context(NetworkParameters.fromID(NetworkParameters.ID_REGTEST)); Address to = mockAddress(123); mockCompleteTxWithThrowForEmptying(wallet, to, new Wallet.ExceededMa... | public Optional<BuildResult> buildEmptyWalletTo(Address to) { return buildWithConfiguration((SendRequest sr) -> { sr.tx.addOutput(Coin.ZERO, to); sr.changeAddress = to; sr.emptyWallet = true; }, String.format("emptying wallet to %s", to)); } | ReleaseTransactionBuilder { public Optional<BuildResult> buildEmptyWalletTo(Address to) { return buildWithConfiguration((SendRequest sr) -> { sr.tx.addOutput(Coin.ZERO, to); sr.changeAddress = to; sr.emptyWallet = true; }, String.format("emptying wallet to %s", to)); } } | ReleaseTransactionBuilder { public Optional<BuildResult> buildEmptyWalletTo(Address to) { return buildWithConfiguration((SendRequest sr) -> { sr.tx.addOutput(Coin.ZERO, to); sr.changeAddress = to; sr.emptyWallet = true; }, String.format("emptying wallet to %s", to)); } ReleaseTransactionBuilder(NetworkParameters params... | ReleaseTransactionBuilder { public Optional<BuildResult> buildEmptyWalletTo(Address to) { return buildWithConfiguration((SendRequest sr) -> { sr.tx.addOutput(Coin.ZERO, to); sr.changeAddress = to; sr.emptyWallet = true; }, String.format("emptying wallet to %s", to)); } ReleaseTransactionBuilder(NetworkParameters params... | ReleaseTransactionBuilder { public Optional<BuildResult> buildEmptyWalletTo(Address to) { return buildWithConfiguration((SendRequest sr) -> { sr.tx.addOutput(Coin.ZERO, to); sr.changeAddress = to; sr.emptyWallet = true; }, String.format("emptying wallet to %s", to)); } ReleaseTransactionBuilder(NetworkParameters params... |
@Test public void buildEmptyWalletTo_utxoProviderException() throws InsufficientMoneyException, UTXOProviderException { Context btcContext = new Context(NetworkParameters.fromID(NetworkParameters.ID_REGTEST)); Address to = mockAddress(123); List<UTXO> availableUTXOs = Arrays.asList( mockUTXO("two", 2, Coin.FIFTY_COINS)... | public Optional<BuildResult> buildEmptyWalletTo(Address to) { return buildWithConfiguration((SendRequest sr) -> { sr.tx.addOutput(Coin.ZERO, to); sr.changeAddress = to; sr.emptyWallet = true; }, String.format("emptying wallet to %s", to)); } | ReleaseTransactionBuilder { public Optional<BuildResult> buildEmptyWalletTo(Address to) { return buildWithConfiguration((SendRequest sr) -> { sr.tx.addOutput(Coin.ZERO, to); sr.changeAddress = to; sr.emptyWallet = true; }, String.format("emptying wallet to %s", to)); } } | ReleaseTransactionBuilder { public Optional<BuildResult> buildEmptyWalletTo(Address to) { return buildWithConfiguration((SendRequest sr) -> { sr.tx.addOutput(Coin.ZERO, to); sr.changeAddress = to; sr.emptyWallet = true; }, String.format("emptying wallet to %s", to)); } ReleaseTransactionBuilder(NetworkParameters params... | ReleaseTransactionBuilder { public Optional<BuildResult> buildEmptyWalletTo(Address to) { return buildWithConfiguration((SendRequest sr) -> { sr.tx.addOutput(Coin.ZERO, to); sr.changeAddress = to; sr.emptyWallet = true; }, String.format("emptying wallet to %s", to)); } ReleaseTransactionBuilder(NetworkParameters params... | ReleaseTransactionBuilder { public Optional<BuildResult> buildEmptyWalletTo(Address to) { return buildWithConfiguration((SendRequest sr) -> { sr.tx.addOutput(Coin.ZERO, to); sr.changeAddress = to; sr.emptyWallet = true; }, String.format("emptying wallet to %s", to)); } ReleaseTransactionBuilder(NetworkParameters params... |
@Test public void testIsLock() { NetworkParameters params = RegTestParams.get(); Context btcContext = new Context(params); BridgeRegTestConstants bridgeConstants = BridgeRegTestConstants.getInstance(); Federation federation = bridgeConstants.getGenesisFederation(); Wallet wallet = new BridgeBtcWallet(btcContext, Collec... | public static boolean isLockTx(BtcTransaction tx, List<Federation> federations, Context btcContext, BridgeConstants bridgeConstants) { for (int i = 0; i < tx.getInputs().size(); i++) { final int index = i; if (federations.stream().anyMatch(federation -> scriptCorrectlySpendsTx(tx, index, federation.getP2SHScript()))) {... | BridgeUtils { public static boolean isLockTx(BtcTransaction tx, List<Federation> federations, Context btcContext, BridgeConstants bridgeConstants) { for (int i = 0; i < tx.getInputs().size(); i++) { final int index = i; if (federations.stream().anyMatch(federation -> scriptCorrectlySpendsTx(tx, index, federation.getP2S... | BridgeUtils { public static boolean isLockTx(BtcTransaction tx, List<Federation> federations, Context btcContext, BridgeConstants bridgeConstants) { for (int i = 0; i < tx.getInputs().size(); i++) { final int index = i; if (federations.stream().anyMatch(federation -> scriptCorrectlySpendsTx(tx, index, federation.getP2S... | BridgeUtils { public static boolean isLockTx(BtcTransaction tx, List<Federation> federations, Context btcContext, BridgeConstants bridgeConstants) { for (int i = 0; i < tx.getInputs().size(); i++) { final int index = i; if (federations.stream().anyMatch(federation -> scriptCorrectlySpendsTx(tx, index, federation.getP2S... | BridgeUtils { public static boolean isLockTx(BtcTransaction tx, List<Federation> federations, Context btcContext, BridgeConstants bridgeConstants) { for (int i = 0; i < tx.getInputs().size(); i++) { final int index = i; if (federations.stream().anyMatch(federation -> scriptCorrectlySpendsTx(tx, index, federation.getP2S... |
@Test public void testIsLockForTwoFederations() { BridgeRegTestConstants bridgeConstants = BridgeRegTestConstants.getInstance(); NetworkParameters parameters = bridgeConstants.getBtcParams(); Context btcContext = new Context(parameters); List<BtcECKey> federation1Keys = Arrays.asList( BtcECKey.fromPrivate(Hex.decode("f... | public static boolean isLockTx(BtcTransaction tx, List<Federation> federations, Context btcContext, BridgeConstants bridgeConstants) { for (int i = 0; i < tx.getInputs().size(); i++) { final int index = i; if (federations.stream().anyMatch(federation -> scriptCorrectlySpendsTx(tx, index, federation.getP2SHScript()))) {... | BridgeUtils { public static boolean isLockTx(BtcTransaction tx, List<Federation> federations, Context btcContext, BridgeConstants bridgeConstants) { for (int i = 0; i < tx.getInputs().size(); i++) { final int index = i; if (federations.stream().anyMatch(federation -> scriptCorrectlySpendsTx(tx, index, federation.getP2S... | BridgeUtils { public static boolean isLockTx(BtcTransaction tx, List<Federation> federations, Context btcContext, BridgeConstants bridgeConstants) { for (int i = 0; i < tx.getInputs().size(); i++) { final int index = i; if (federations.stream().anyMatch(federation -> scriptCorrectlySpendsTx(tx, index, federation.getP2S... | BridgeUtils { public static boolean isLockTx(BtcTransaction tx, List<Federation> federations, Context btcContext, BridgeConstants bridgeConstants) { for (int i = 0; i < tx.getInputs().size(); i++) { final int index = i; if (federations.stream().anyMatch(federation -> scriptCorrectlySpendsTx(tx, index, federation.getP2S... | BridgeUtils { public static boolean isLockTx(BtcTransaction tx, List<Federation> federations, Context btcContext, BridgeConstants bridgeConstants) { for (int i = 0; i < tx.getInputs().size(); i++) { final int index = i; if (federations.stream().anyMatch(federation -> scriptCorrectlySpendsTx(tx, index, federation.getP2S... |
@Test public void test7() { byte[] data = encodeString(""); assertArrayEquals(new byte[]{(byte) 0x80}, data); byte[] expected = {(byte) 0x90, (byte) 0x45, (byte) 0x74, (byte) 0x68, (byte) 0x65, (byte) 0x72, (byte) 0x65, (byte) 0x75, (byte) 0x6D, (byte) 0x4A, (byte) 0x20, (byte) 0x43, (byte) 0x6C, (byte) 0x69, (byte) 0x... | public static byte[] encodeString(String srcString) { return encodeElement(srcString.getBytes(StandardCharsets.UTF_8)); } | RLP { public static byte[] encodeString(String srcString) { return encodeElement(srcString.getBytes(StandardCharsets.UTF_8)); } } | RLP { public static byte[] encodeString(String srcString) { return encodeElement(srcString.getBytes(StandardCharsets.UTF_8)); } } | RLP { public static byte[] encodeString(String srcString) { return encodeElement(srcString.getBytes(StandardCharsets.UTF_8)); } static int decodeInt(byte[] data, int index); static BigInteger decodeBigInteger(byte[] data, int index); static byte[] decodeIP4Bytes(byte[] data, int index); static int getFirstListElement(... | RLP { public static byte[] encodeString(String srcString) { return encodeElement(srcString.getBytes(StandardCharsets.UTF_8)); } static int decodeInt(byte[] data, int index); static BigInteger decodeBigInteger(byte[] data, int index); static byte[] decodeIP4Bytes(byte[] data, int index); static int getFirstListElement(... |
@Test public void testTxIsProcessable() { ActivationConfig.ForBlock actForBlock = mock(ActivationConfig.ForBlock.class); when(actForBlock.isActive(ConsensusRule.RSKIP143)).thenReturn(false); assertTrue(BridgeUtils.txIsProcessable(BtcLockSender.TxType.P2PKH, actForBlock)); assertFalse(BridgeUtils.txIsProcessable(BtcLock... | public static boolean txIsProcessable(BtcLockSender.TxType txType, ActivationConfig.ForBlock activations) { return txType == BtcLockSender.TxType.P2PKH || activations.isActive(ConsensusRule.RSKIP143); } | BridgeUtils { public static boolean txIsProcessable(BtcLockSender.TxType txType, ActivationConfig.ForBlock activations) { return txType == BtcLockSender.TxType.P2PKH || activations.isActive(ConsensusRule.RSKIP143); } } | BridgeUtils { public static boolean txIsProcessable(BtcLockSender.TxType txType, ActivationConfig.ForBlock activations) { return txType == BtcLockSender.TxType.P2PKH || activations.isActive(ConsensusRule.RSKIP143); } } | BridgeUtils { public static boolean txIsProcessable(BtcLockSender.TxType txType, ActivationConfig.ForBlock activations) { return txType == BtcLockSender.TxType.P2PKH || activations.isActive(ConsensusRule.RSKIP143); } static Wallet getFederationNoSpendWallet(Context btcContext, Federation federation); static Wallet get... | BridgeUtils { public static boolean txIsProcessable(BtcLockSender.TxType txType, ActivationConfig.ForBlock activations) { return txType == BtcLockSender.TxType.P2PKH || activations.isActive(ConsensusRule.RSKIP143); } static Wallet getFederationNoSpendWallet(Context btcContext, Federation federation); static Wallet get... |
@Test public void testIsMigrationTx() { BridgeRegTestConstants bridgeConstants = BridgeRegTestConstants.getInstance(); NetworkParameters parameters = bridgeConstants.getBtcParams(); Context btcContext = new Context(parameters); List<BtcECKey> activeFederationKeys = Stream.of( BtcECKey.fromPrivate(Hex.decode("fa01")), B... | public static boolean isMigrationTx(BtcTransaction btcTx, Federation activeFederation, Federation retiringFederation, Context btcContext, BridgeConstants bridgeConstants) { if (retiringFederation == null) { return false; } boolean moveFromRetiring = isReleaseTx(btcTx, retiringFederation); boolean moveToActive = isLockT... | BridgeUtils { public static boolean isMigrationTx(BtcTransaction btcTx, Federation activeFederation, Federation retiringFederation, Context btcContext, BridgeConstants bridgeConstants) { if (retiringFederation == null) { return false; } boolean moveFromRetiring = isReleaseTx(btcTx, retiringFederation); boolean moveToAc... | BridgeUtils { public static boolean isMigrationTx(BtcTransaction btcTx, Federation activeFederation, Federation retiringFederation, Context btcContext, BridgeConstants bridgeConstants) { if (retiringFederation == null) { return false; } boolean moveFromRetiring = isReleaseTx(btcTx, retiringFederation); boolean moveToAc... | BridgeUtils { public static boolean isMigrationTx(BtcTransaction btcTx, Federation activeFederation, Federation retiringFederation, Context btcContext, BridgeConstants bridgeConstants) { if (retiringFederation == null) { return false; } boolean moveFromRetiring = isReleaseTx(btcTx, retiringFederation); boolean moveToAc... | BridgeUtils { public static boolean isMigrationTx(BtcTransaction btcTx, Federation activeFederation, Federation retiringFederation, Context btcContext, BridgeConstants bridgeConstants) { if (retiringFederation == null) { return false; } boolean moveFromRetiring = isReleaseTx(btcTx, retiringFederation); boolean moveToAc... |
@Test public void getAddressFromEthTransaction() { org.ethereum.core.Transaction tx = new org.ethereum.core.Transaction(TO_ADDRESS, AMOUNT, NONCE, GAS_PRICE, GAS_LIMIT, DATA, constants.getChainId()); byte[] privKey = generatePrivKey(); tx.sign(privKey); Address expectedAddress = BtcECKey.fromPrivate(privKey).toAddress(... | public static Address recoverBtcAddressFromEthTransaction(org.ethereum.core.Transaction tx, NetworkParameters networkParameters) { org.ethereum.crypto.ECKey key = tx.getKey(); byte[] pubKey = key.getPubKey(true); return BtcECKey.fromPublicOnly(pubKey).toAddress(networkParameters); } | BridgeUtils { public static Address recoverBtcAddressFromEthTransaction(org.ethereum.core.Transaction tx, NetworkParameters networkParameters) { org.ethereum.crypto.ECKey key = tx.getKey(); byte[] pubKey = key.getPubKey(true); return BtcECKey.fromPublicOnly(pubKey).toAddress(networkParameters); } } | BridgeUtils { public static Address recoverBtcAddressFromEthTransaction(org.ethereum.core.Transaction tx, NetworkParameters networkParameters) { org.ethereum.crypto.ECKey key = tx.getKey(); byte[] pubKey = key.getPubKey(true); return BtcECKey.fromPublicOnly(pubKey).toAddress(networkParameters); } } | BridgeUtils { public static Address recoverBtcAddressFromEthTransaction(org.ethereum.core.Transaction tx, NetworkParameters networkParameters) { org.ethereum.crypto.ECKey key = tx.getKey(); byte[] pubKey = key.getPubKey(true); return BtcECKey.fromPublicOnly(pubKey).toAddress(networkParameters); } static Wallet getFede... | BridgeUtils { public static Address recoverBtcAddressFromEthTransaction(org.ethereum.core.Transaction tx, NetworkParameters networkParameters) { org.ethereum.crypto.ECKey key = tx.getKey(); byte[] pubKey = key.getPubKey(true); return BtcECKey.fromPublicOnly(pubKey).toAddress(networkParameters); } static Wallet getFede... |
@Test(expected = Exception.class) public void getAddressFromEthNotSignTransaction() { org.ethereum.core.Transaction tx = new org.ethereum.core.Transaction(TO_ADDRESS, AMOUNT, NONCE, GAS_PRICE, GAS_LIMIT, DATA, constants.getChainId()); BridgeUtils.recoverBtcAddressFromEthTransaction(tx, RegTestParams.get()); } | public static Address recoverBtcAddressFromEthTransaction(org.ethereum.core.Transaction tx, NetworkParameters networkParameters) { org.ethereum.crypto.ECKey key = tx.getKey(); byte[] pubKey = key.getPubKey(true); return BtcECKey.fromPublicOnly(pubKey).toAddress(networkParameters); } | BridgeUtils { public static Address recoverBtcAddressFromEthTransaction(org.ethereum.core.Transaction tx, NetworkParameters networkParameters) { org.ethereum.crypto.ECKey key = tx.getKey(); byte[] pubKey = key.getPubKey(true); return BtcECKey.fromPublicOnly(pubKey).toAddress(networkParameters); } } | BridgeUtils { public static Address recoverBtcAddressFromEthTransaction(org.ethereum.core.Transaction tx, NetworkParameters networkParameters) { org.ethereum.crypto.ECKey key = tx.getKey(); byte[] pubKey = key.getPubKey(true); return BtcECKey.fromPublicOnly(pubKey).toAddress(networkParameters); } } | BridgeUtils { public static Address recoverBtcAddressFromEthTransaction(org.ethereum.core.Transaction tx, NetworkParameters networkParameters) { org.ethereum.crypto.ECKey key = tx.getKey(); byte[] pubKey = key.getPubKey(true); return BtcECKey.fromPublicOnly(pubKey).toAddress(networkParameters); } static Wallet getFede... | BridgeUtils { public static Address recoverBtcAddressFromEthTransaction(org.ethereum.core.Transaction tx, NetworkParameters networkParameters) { org.ethereum.crypto.ECKey key = tx.getKey(); byte[] pubKey = key.getPubKey(true); return BtcECKey.fromPublicOnly(pubKey).toAddress(networkParameters); } static Wallet getFede... |
@Test public void hasEnoughSignatures_two_signatures() { byte[] sign1 = new byte[]{0x79}; byte[] sign2 = new byte[]{0x78}; BtcTransaction btcTx = createReleaseTx(Arrays.asList(sign1, sign2), 1); Assert.assertTrue(BridgeUtils.hasEnoughSignatures(mock(Context.class), btcTx)); } | public static boolean hasEnoughSignatures(Context btcContext, BtcTransaction btcTx) { Context.propagate(btcContext); for (TransactionInput input : btcTx.getInputs()) { Script scriptSig = input.getScriptSig(); List<ScriptChunk> chunks = scriptSig.getChunks(); for (int i = 1; i < chunks.size(); i++) { ScriptChunk chunk =... | BridgeUtils { public static boolean hasEnoughSignatures(Context btcContext, BtcTransaction btcTx) { Context.propagate(btcContext); for (TransactionInput input : btcTx.getInputs()) { Script scriptSig = input.getScriptSig(); List<ScriptChunk> chunks = scriptSig.getChunks(); for (int i = 1; i < chunks.size(); i++) { Scrip... | BridgeUtils { public static boolean hasEnoughSignatures(Context btcContext, BtcTransaction btcTx) { Context.propagate(btcContext); for (TransactionInput input : btcTx.getInputs()) { Script scriptSig = input.getScriptSig(); List<ScriptChunk> chunks = scriptSig.getChunks(); for (int i = 1; i < chunks.size(); i++) { Scrip... | BridgeUtils { public static boolean hasEnoughSignatures(Context btcContext, BtcTransaction btcTx) { Context.propagate(btcContext); for (TransactionInput input : btcTx.getInputs()) { Script scriptSig = input.getScriptSig(); List<ScriptChunk> chunks = scriptSig.getChunks(); for (int i = 1; i < chunks.size(); i++) { Scrip... | BridgeUtils { public static boolean hasEnoughSignatures(Context btcContext, BtcTransaction btcTx) { Context.propagate(btcContext); for (TransactionInput input : btcTx.getInputs()) { Script scriptSig = input.getScriptSig(); List<ScriptChunk> chunks = scriptSig.getChunks(); for (int i = 1; i < chunks.size(); i++) { Scrip... |
@Test public void hasEnoughSignatures_one_signature() { byte[] sign1 = new byte[]{0x79}; byte[] MISSING_SIGNATURE = new byte[0]; BtcTransaction btcTx = createReleaseTx(Arrays.asList(sign1, MISSING_SIGNATURE), 1); Assert.assertFalse(BridgeUtils.hasEnoughSignatures(mock(Context.class), btcTx)); } | public static boolean hasEnoughSignatures(Context btcContext, BtcTransaction btcTx) { Context.propagate(btcContext); for (TransactionInput input : btcTx.getInputs()) { Script scriptSig = input.getScriptSig(); List<ScriptChunk> chunks = scriptSig.getChunks(); for (int i = 1; i < chunks.size(); i++) { ScriptChunk chunk =... | BridgeUtils { public static boolean hasEnoughSignatures(Context btcContext, BtcTransaction btcTx) { Context.propagate(btcContext); for (TransactionInput input : btcTx.getInputs()) { Script scriptSig = input.getScriptSig(); List<ScriptChunk> chunks = scriptSig.getChunks(); for (int i = 1; i < chunks.size(); i++) { Scrip... | BridgeUtils { public static boolean hasEnoughSignatures(Context btcContext, BtcTransaction btcTx) { Context.propagate(btcContext); for (TransactionInput input : btcTx.getInputs()) { Script scriptSig = input.getScriptSig(); List<ScriptChunk> chunks = scriptSig.getChunks(); for (int i = 1; i < chunks.size(); i++) { Scrip... | BridgeUtils { public static boolean hasEnoughSignatures(Context btcContext, BtcTransaction btcTx) { Context.propagate(btcContext); for (TransactionInput input : btcTx.getInputs()) { Script scriptSig = input.getScriptSig(); List<ScriptChunk> chunks = scriptSig.getChunks(); for (int i = 1; i < chunks.size(); i++) { Scrip... | BridgeUtils { public static boolean hasEnoughSignatures(Context btcContext, BtcTransaction btcTx) { Context.propagate(btcContext); for (TransactionInput input : btcTx.getInputs()) { Script scriptSig = input.getScriptSig(); List<ScriptChunk> chunks = scriptSig.getChunks(); for (int i = 1; i < chunks.size(); i++) { Scrip... |
@Test public void hasEnoughSignatures_no_signatures() { BtcTransaction btcTx = createReleaseTx(Collections.emptyList(), 1); Assert.assertFalse(BridgeUtils.hasEnoughSignatures(mock(Context.class), btcTx)); } | public static boolean hasEnoughSignatures(Context btcContext, BtcTransaction btcTx) { Context.propagate(btcContext); for (TransactionInput input : btcTx.getInputs()) { Script scriptSig = input.getScriptSig(); List<ScriptChunk> chunks = scriptSig.getChunks(); for (int i = 1; i < chunks.size(); i++) { ScriptChunk chunk =... | BridgeUtils { public static boolean hasEnoughSignatures(Context btcContext, BtcTransaction btcTx) { Context.propagate(btcContext); for (TransactionInput input : btcTx.getInputs()) { Script scriptSig = input.getScriptSig(); List<ScriptChunk> chunks = scriptSig.getChunks(); for (int i = 1; i < chunks.size(); i++) { Scrip... | BridgeUtils { public static boolean hasEnoughSignatures(Context btcContext, BtcTransaction btcTx) { Context.propagate(btcContext); for (TransactionInput input : btcTx.getInputs()) { Script scriptSig = input.getScriptSig(); List<ScriptChunk> chunks = scriptSig.getChunks(); for (int i = 1; i < chunks.size(); i++) { Scrip... | BridgeUtils { public static boolean hasEnoughSignatures(Context btcContext, BtcTransaction btcTx) { Context.propagate(btcContext); for (TransactionInput input : btcTx.getInputs()) { Script scriptSig = input.getScriptSig(); List<ScriptChunk> chunks = scriptSig.getChunks(); for (int i = 1; i < chunks.size(); i++) { Scrip... | BridgeUtils { public static boolean hasEnoughSignatures(Context btcContext, BtcTransaction btcTx) { Context.propagate(btcContext); for (TransactionInput input : btcTx.getInputs()) { Script scriptSig = input.getScriptSig(); List<ScriptChunk> chunks = scriptSig.getChunks(); for (int i = 1; i < chunks.size(); i++) { Scrip... |
@Test public void hasEnoughSignatures_several_inputs_all_signed() { byte[] sign1 = new byte[]{0x79}; byte[] sign2 = new byte[]{0x78}; BtcTransaction btcTx = createReleaseTx(Arrays.asList(sign1, sign2), 3); Assert.assertTrue(BridgeUtils.hasEnoughSignatures(mock(Context.class), btcTx)); } | public static boolean hasEnoughSignatures(Context btcContext, BtcTransaction btcTx) { Context.propagate(btcContext); for (TransactionInput input : btcTx.getInputs()) { Script scriptSig = input.getScriptSig(); List<ScriptChunk> chunks = scriptSig.getChunks(); for (int i = 1; i < chunks.size(); i++) { ScriptChunk chunk =... | BridgeUtils { public static boolean hasEnoughSignatures(Context btcContext, BtcTransaction btcTx) { Context.propagate(btcContext); for (TransactionInput input : btcTx.getInputs()) { Script scriptSig = input.getScriptSig(); List<ScriptChunk> chunks = scriptSig.getChunks(); for (int i = 1; i < chunks.size(); i++) { Scrip... | BridgeUtils { public static boolean hasEnoughSignatures(Context btcContext, BtcTransaction btcTx) { Context.propagate(btcContext); for (TransactionInput input : btcTx.getInputs()) { Script scriptSig = input.getScriptSig(); List<ScriptChunk> chunks = scriptSig.getChunks(); for (int i = 1; i < chunks.size(); i++) { Scrip... | BridgeUtils { public static boolean hasEnoughSignatures(Context btcContext, BtcTransaction btcTx) { Context.propagate(btcContext); for (TransactionInput input : btcTx.getInputs()) { Script scriptSig = input.getScriptSig(); List<ScriptChunk> chunks = scriptSig.getChunks(); for (int i = 1; i < chunks.size(); i++) { Scrip... | BridgeUtils { public static boolean hasEnoughSignatures(Context btcContext, BtcTransaction btcTx) { Context.propagate(btcContext); for (TransactionInput input : btcTx.getInputs()) { Script scriptSig = input.getScriptSig(); List<ScriptChunk> chunks = scriptSig.getChunks(); for (int i = 1; i < chunks.size(); i++) { Scrip... |
@Test public void hasEnoughSignatures_several_inputs_one_missing_signature() { byte[] sign1 = new byte[]{0x79}; byte[] MISSING_SIGNATURE = new byte[0]; BtcTransaction btcTx = createReleaseTx(Arrays.asList(sign1, MISSING_SIGNATURE), 3); Assert.assertFalse(BridgeUtils.hasEnoughSignatures(mock(Context.class), btcTx)); } | public static boolean hasEnoughSignatures(Context btcContext, BtcTransaction btcTx) { Context.propagate(btcContext); for (TransactionInput input : btcTx.getInputs()) { Script scriptSig = input.getScriptSig(); List<ScriptChunk> chunks = scriptSig.getChunks(); for (int i = 1; i < chunks.size(); i++) { ScriptChunk chunk =... | BridgeUtils { public static boolean hasEnoughSignatures(Context btcContext, BtcTransaction btcTx) { Context.propagate(btcContext); for (TransactionInput input : btcTx.getInputs()) { Script scriptSig = input.getScriptSig(); List<ScriptChunk> chunks = scriptSig.getChunks(); for (int i = 1; i < chunks.size(); i++) { Scrip... | BridgeUtils { public static boolean hasEnoughSignatures(Context btcContext, BtcTransaction btcTx) { Context.propagate(btcContext); for (TransactionInput input : btcTx.getInputs()) { Script scriptSig = input.getScriptSig(); List<ScriptChunk> chunks = scriptSig.getChunks(); for (int i = 1; i < chunks.size(); i++) { Scrip... | BridgeUtils { public static boolean hasEnoughSignatures(Context btcContext, BtcTransaction btcTx) { Context.propagate(btcContext); for (TransactionInput input : btcTx.getInputs()) { Script scriptSig = input.getScriptSig(); List<ScriptChunk> chunks = scriptSig.getChunks(); for (int i = 1; i < chunks.size(); i++) { Scrip... | BridgeUtils { public static boolean hasEnoughSignatures(Context btcContext, BtcTransaction btcTx) { Context.propagate(btcContext); for (TransactionInput input : btcTx.getInputs()) { Script scriptSig = input.getScriptSig(); List<ScriptChunk> chunks = scriptSig.getChunks(); for (int i = 1; i < chunks.size(); i++) { Scrip... |
@Test public void countMissingSignatures_two_signatures() { byte[] sign1 = new byte[]{0x79}; byte[] sign2 = new byte[]{0x78}; BtcTransaction btcTx = createReleaseTx(Arrays.asList(sign1, sign2), 1); Assert.assertEquals(0, BridgeUtils.countMissingSignatures(mock(Context.class), btcTx)); } | public static int countMissingSignatures(Context btcContext, BtcTransaction btcTx) { Context.propagate(btcContext); int unsigned = 0; TransactionInput input = btcTx.getInput(0); Script scriptSig = input.getScriptSig(); List<ScriptChunk> chunks = scriptSig.getChunks(); for (int i = 1; i < chunks.size() - 1; i++) { Scrip... | BridgeUtils { public static int countMissingSignatures(Context btcContext, BtcTransaction btcTx) { Context.propagate(btcContext); int unsigned = 0; TransactionInput input = btcTx.getInput(0); Script scriptSig = input.getScriptSig(); List<ScriptChunk> chunks = scriptSig.getChunks(); for (int i = 1; i < chunks.size() - 1... | BridgeUtils { public static int countMissingSignatures(Context btcContext, BtcTransaction btcTx) { Context.propagate(btcContext); int unsigned = 0; TransactionInput input = btcTx.getInput(0); Script scriptSig = input.getScriptSig(); List<ScriptChunk> chunks = scriptSig.getChunks(); for (int i = 1; i < chunks.size() - 1... | BridgeUtils { public static int countMissingSignatures(Context btcContext, BtcTransaction btcTx) { Context.propagate(btcContext); int unsigned = 0; TransactionInput input = btcTx.getInput(0); Script scriptSig = input.getScriptSig(); List<ScriptChunk> chunks = scriptSig.getChunks(); for (int i = 1; i < chunks.size() - 1... | BridgeUtils { public static int countMissingSignatures(Context btcContext, BtcTransaction btcTx) { Context.propagate(btcContext); int unsigned = 0; TransactionInput input = btcTx.getInput(0); Script scriptSig = input.getScriptSig(); List<ScriptChunk> chunks = scriptSig.getChunks(); for (int i = 1; i < chunks.size() - 1... |
@Test public void test8() { String byteArr = "ce73660a06626c1b3fda7b18ef7ba3ce17b6bf604f9541d3c6c654b7ae88b239" + "407f659c78f419025d785727ed017b6add21952d7e12007373e321dbc31824ba"; byte[] byteArray = Hex.decode(byteArr); String expected = "b840" + byteArr; assertEquals(expected, ByteUtil.toHexString(encodeElement(byte... | public static byte[] encodeElement(@Nullable byte[] srcData) { if (srcData == null || srcData.length == 0) { return new byte[]{(byte) OFFSET_SHORT_ITEM}; } else if (isSingleZero(srcData)) { return srcData; } else if (srcData.length == 1 && (srcData[0] & 0xFF) < OFFSET_SHORT_ITEM) { return srcData; } else if (srcData.le... | RLP { public static byte[] encodeElement(@Nullable byte[] srcData) { if (srcData == null || srcData.length == 0) { return new byte[]{(byte) OFFSET_SHORT_ITEM}; } else if (isSingleZero(srcData)) { return srcData; } else if (srcData.length == 1 && (srcData[0] & 0xFF) < OFFSET_SHORT_ITEM) { return srcData; } else if (srcD... | RLP { public static byte[] encodeElement(@Nullable byte[] srcData) { if (srcData == null || srcData.length == 0) { return new byte[]{(byte) OFFSET_SHORT_ITEM}; } else if (isSingleZero(srcData)) { return srcData; } else if (srcData.length == 1 && (srcData[0] & 0xFF) < OFFSET_SHORT_ITEM) { return srcData; } else if (srcD... | RLP { public static byte[] encodeElement(@Nullable byte[] srcData) { if (srcData == null || srcData.length == 0) { return new byte[]{(byte) OFFSET_SHORT_ITEM}; } else if (isSingleZero(srcData)) { return srcData; } else if (srcData.length == 1 && (srcData[0] & 0xFF) < OFFSET_SHORT_ITEM) { return srcData; } else if (srcD... | RLP { public static byte[] encodeElement(@Nullable byte[] srcData) { if (srcData == null || srcData.length == 0) { return new byte[]{(byte) OFFSET_SHORT_ITEM}; } else if (isSingleZero(srcData)) { return srcData; } else if (srcData.length == 1 && (srcData[0] & 0xFF) < OFFSET_SHORT_ITEM) { return srcData; } else if (srcD... |
@Test public void countMissingSignatures_one_signature() { byte[] sign1 = new byte[]{0x79}; byte[] MISSING_SIGNATURE = new byte[0]; BtcTransaction btcTx = createReleaseTx(Arrays.asList(sign1, MISSING_SIGNATURE), 1); Assert.assertEquals(1, BridgeUtils.countMissingSignatures(mock(Context.class), btcTx)); } | public static int countMissingSignatures(Context btcContext, BtcTransaction btcTx) { Context.propagate(btcContext); int unsigned = 0; TransactionInput input = btcTx.getInput(0); Script scriptSig = input.getScriptSig(); List<ScriptChunk> chunks = scriptSig.getChunks(); for (int i = 1; i < chunks.size() - 1; i++) { Scrip... | BridgeUtils { public static int countMissingSignatures(Context btcContext, BtcTransaction btcTx) { Context.propagate(btcContext); int unsigned = 0; TransactionInput input = btcTx.getInput(0); Script scriptSig = input.getScriptSig(); List<ScriptChunk> chunks = scriptSig.getChunks(); for (int i = 1; i < chunks.size() - 1... | BridgeUtils { public static int countMissingSignatures(Context btcContext, BtcTransaction btcTx) { Context.propagate(btcContext); int unsigned = 0; TransactionInput input = btcTx.getInput(0); Script scriptSig = input.getScriptSig(); List<ScriptChunk> chunks = scriptSig.getChunks(); for (int i = 1; i < chunks.size() - 1... | BridgeUtils { public static int countMissingSignatures(Context btcContext, BtcTransaction btcTx) { Context.propagate(btcContext); int unsigned = 0; TransactionInput input = btcTx.getInput(0); Script scriptSig = input.getScriptSig(); List<ScriptChunk> chunks = scriptSig.getChunks(); for (int i = 1; i < chunks.size() - 1... | BridgeUtils { public static int countMissingSignatures(Context btcContext, BtcTransaction btcTx) { Context.propagate(btcContext); int unsigned = 0; TransactionInput input = btcTx.getInput(0); Script scriptSig = input.getScriptSig(); List<ScriptChunk> chunks = scriptSig.getChunks(); for (int i = 1; i < chunks.size() - 1... |
@Test public void countMissingSignatures_no_signatures() { BtcTransaction btcTx = createReleaseTx(Collections.emptyList(), 1); Assert.assertEquals(2, BridgeUtils.countMissingSignatures(mock(Context.class), btcTx)); } | public static int countMissingSignatures(Context btcContext, BtcTransaction btcTx) { Context.propagate(btcContext); int unsigned = 0; TransactionInput input = btcTx.getInput(0); Script scriptSig = input.getScriptSig(); List<ScriptChunk> chunks = scriptSig.getChunks(); for (int i = 1; i < chunks.size() - 1; i++) { Scrip... | BridgeUtils { public static int countMissingSignatures(Context btcContext, BtcTransaction btcTx) { Context.propagate(btcContext); int unsigned = 0; TransactionInput input = btcTx.getInput(0); Script scriptSig = input.getScriptSig(); List<ScriptChunk> chunks = scriptSig.getChunks(); for (int i = 1; i < chunks.size() - 1... | BridgeUtils { public static int countMissingSignatures(Context btcContext, BtcTransaction btcTx) { Context.propagate(btcContext); int unsigned = 0; TransactionInput input = btcTx.getInput(0); Script scriptSig = input.getScriptSig(); List<ScriptChunk> chunks = scriptSig.getChunks(); for (int i = 1; i < chunks.size() - 1... | BridgeUtils { public static int countMissingSignatures(Context btcContext, BtcTransaction btcTx) { Context.propagate(btcContext); int unsigned = 0; TransactionInput input = btcTx.getInput(0); Script scriptSig = input.getScriptSig(); List<ScriptChunk> chunks = scriptSig.getChunks(); for (int i = 1; i < chunks.size() - 1... | BridgeUtils { public static int countMissingSignatures(Context btcContext, BtcTransaction btcTx) { Context.propagate(btcContext); int unsigned = 0; TransactionInput input = btcTx.getInput(0); Script scriptSig = input.getScriptSig(); List<ScriptChunk> chunks = scriptSig.getChunks(); for (int i = 1; i < chunks.size() - 1... |
@Test public void countMissingSignatures_several_inputs_all_signed() { byte[] sign1 = new byte[]{0x79}; byte[] sign2 = new byte[]{0x78}; BtcTransaction btcTx = createReleaseTx(Arrays.asList(sign1, sign2), 3); Assert.assertEquals(0, BridgeUtils.countMissingSignatures(mock(Context.class), btcTx)); } | public static int countMissingSignatures(Context btcContext, BtcTransaction btcTx) { Context.propagate(btcContext); int unsigned = 0; TransactionInput input = btcTx.getInput(0); Script scriptSig = input.getScriptSig(); List<ScriptChunk> chunks = scriptSig.getChunks(); for (int i = 1; i < chunks.size() - 1; i++) { Scrip... | BridgeUtils { public static int countMissingSignatures(Context btcContext, BtcTransaction btcTx) { Context.propagate(btcContext); int unsigned = 0; TransactionInput input = btcTx.getInput(0); Script scriptSig = input.getScriptSig(); List<ScriptChunk> chunks = scriptSig.getChunks(); for (int i = 1; i < chunks.size() - 1... | BridgeUtils { public static int countMissingSignatures(Context btcContext, BtcTransaction btcTx) { Context.propagate(btcContext); int unsigned = 0; TransactionInput input = btcTx.getInput(0); Script scriptSig = input.getScriptSig(); List<ScriptChunk> chunks = scriptSig.getChunks(); for (int i = 1; i < chunks.size() - 1... | BridgeUtils { public static int countMissingSignatures(Context btcContext, BtcTransaction btcTx) { Context.propagate(btcContext); int unsigned = 0; TransactionInput input = btcTx.getInput(0); Script scriptSig = input.getScriptSig(); List<ScriptChunk> chunks = scriptSig.getChunks(); for (int i = 1; i < chunks.size() - 1... | BridgeUtils { public static int countMissingSignatures(Context btcContext, BtcTransaction btcTx) { Context.propagate(btcContext); int unsigned = 0; TransactionInput input = btcTx.getInput(0); Script scriptSig = input.getScriptSig(); List<ScriptChunk> chunks = scriptSig.getChunks(); for (int i = 1; i < chunks.size() - 1... |
@Test public void countMissingSignatures_several_inputs_one_missing_signature() { byte[] sign1 = new byte[]{0x79}; byte[] MISSING_SIGNATURE = new byte[0]; BtcTransaction btcTx = createReleaseTx(Arrays.asList(sign1, MISSING_SIGNATURE), 3); Assert.assertEquals(1, BridgeUtils.countMissingSignatures(mock(Context.class), bt... | public static int countMissingSignatures(Context btcContext, BtcTransaction btcTx) { Context.propagate(btcContext); int unsigned = 0; TransactionInput input = btcTx.getInput(0); Script scriptSig = input.getScriptSig(); List<ScriptChunk> chunks = scriptSig.getChunks(); for (int i = 1; i < chunks.size() - 1; i++) { Scrip... | BridgeUtils { public static int countMissingSignatures(Context btcContext, BtcTransaction btcTx) { Context.propagate(btcContext); int unsigned = 0; TransactionInput input = btcTx.getInput(0); Script scriptSig = input.getScriptSig(); List<ScriptChunk> chunks = scriptSig.getChunks(); for (int i = 1; i < chunks.size() - 1... | BridgeUtils { public static int countMissingSignatures(Context btcContext, BtcTransaction btcTx) { Context.propagate(btcContext); int unsigned = 0; TransactionInput input = btcTx.getInput(0); Script scriptSig = input.getScriptSig(); List<ScriptChunk> chunks = scriptSig.getChunks(); for (int i = 1; i < chunks.size() - 1... | BridgeUtils { public static int countMissingSignatures(Context btcContext, BtcTransaction btcTx) { Context.propagate(btcContext); int unsigned = 0; TransactionInput input = btcTx.getInput(0); Script scriptSig = input.getScriptSig(); List<ScriptChunk> chunks = scriptSig.getChunks(); for (int i = 1; i < chunks.size() - 1... | BridgeUtils { public static int countMissingSignatures(Context btcContext, BtcTransaction btcTx) { Context.propagate(btcContext); int unsigned = 0; TransactionInput input = btcTx.getInput(0); Script scriptSig = input.getScriptSig(); List<ScriptChunk> chunks = scriptSig.getChunks(); for (int i = 1; i < chunks.size() - 1... |
@Test public void isFreeBridgeTxTrue() { activationConfig = ActivationConfigsForTest.bridgeUnitTest(); isFreeBridgeTx(true, PrecompiledContracts.BRIDGE_ADDR, BridgeRegTestConstants.REGTEST_FEDERATION_PRIVATE_KEYS.get(0).getPrivKeyBytes()); } | public static boolean isFreeBridgeTx(Transaction rskTx, Constants constants, ActivationConfig.ForBlock activations) { RskAddress receiveAddress = rskTx.getReceiveAddress(); if (receiveAddress.equals(RskAddress.nullAddress())) { return false; } BridgeConstants bridgeConstants = constants.getBridgeConstants(); return Pre... | BridgeUtils { public static boolean isFreeBridgeTx(Transaction rskTx, Constants constants, ActivationConfig.ForBlock activations) { RskAddress receiveAddress = rskTx.getReceiveAddress(); if (receiveAddress.equals(RskAddress.nullAddress())) { return false; } BridgeConstants bridgeConstants = constants.getBridgeConstants... | BridgeUtils { public static boolean isFreeBridgeTx(Transaction rskTx, Constants constants, ActivationConfig.ForBlock activations) { RskAddress receiveAddress = rskTx.getReceiveAddress(); if (receiveAddress.equals(RskAddress.nullAddress())) { return false; } BridgeConstants bridgeConstants = constants.getBridgeConstants... | BridgeUtils { public static boolean isFreeBridgeTx(Transaction rskTx, Constants constants, ActivationConfig.ForBlock activations) { RskAddress receiveAddress = rskTx.getReceiveAddress(); if (receiveAddress.equals(RskAddress.nullAddress())) { return false; } BridgeConstants bridgeConstants = constants.getBridgeConstants... | BridgeUtils { public static boolean isFreeBridgeTx(Transaction rskTx, Constants constants, ActivationConfig.ForBlock activations) { RskAddress receiveAddress = rskTx.getReceiveAddress(); if (receiveAddress.equals(RskAddress.nullAddress())) { return false; } BridgeConstants bridgeConstants = constants.getBridgeConstants... |
@Test public void isFreeBridgeTxOtherContract() { activationConfig = ActivationConfigsForTest.bridgeUnitTest(); isFreeBridgeTx(false, PrecompiledContracts.IDENTITY_ADDR, BridgeRegTestConstants.REGTEST_FEDERATION_PRIVATE_KEYS.get(0).getPrivKeyBytes()); } | public static boolean isFreeBridgeTx(Transaction rskTx, Constants constants, ActivationConfig.ForBlock activations) { RskAddress receiveAddress = rskTx.getReceiveAddress(); if (receiveAddress.equals(RskAddress.nullAddress())) { return false; } BridgeConstants bridgeConstants = constants.getBridgeConstants(); return Pre... | BridgeUtils { public static boolean isFreeBridgeTx(Transaction rskTx, Constants constants, ActivationConfig.ForBlock activations) { RskAddress receiveAddress = rskTx.getReceiveAddress(); if (receiveAddress.equals(RskAddress.nullAddress())) { return false; } BridgeConstants bridgeConstants = constants.getBridgeConstants... | BridgeUtils { public static boolean isFreeBridgeTx(Transaction rskTx, Constants constants, ActivationConfig.ForBlock activations) { RskAddress receiveAddress = rskTx.getReceiveAddress(); if (receiveAddress.equals(RskAddress.nullAddress())) { return false; } BridgeConstants bridgeConstants = constants.getBridgeConstants... | BridgeUtils { public static boolean isFreeBridgeTx(Transaction rskTx, Constants constants, ActivationConfig.ForBlock activations) { RskAddress receiveAddress = rskTx.getReceiveAddress(); if (receiveAddress.equals(RskAddress.nullAddress())) { return false; } BridgeConstants bridgeConstants = constants.getBridgeConstants... | BridgeUtils { public static boolean isFreeBridgeTx(Transaction rskTx, Constants constants, ActivationConfig.ForBlock activations) { RskAddress receiveAddress = rskTx.getReceiveAddress(); if (receiveAddress.equals(RskAddress.nullAddress())) { return false; } BridgeConstants bridgeConstants = constants.getBridgeConstants... |
@Test public void isFreeBridgeTxFreeTxDisabled() { activationConfig = ActivationConfigsForTest.only(ConsensusRule.ARE_BRIDGE_TXS_PAID); isFreeBridgeTx(false, PrecompiledContracts.BRIDGE_ADDR, BridgeRegTestConstants.REGTEST_FEDERATION_PRIVATE_KEYS.get(0).getPrivKeyBytes()); } | public static boolean isFreeBridgeTx(Transaction rskTx, Constants constants, ActivationConfig.ForBlock activations) { RskAddress receiveAddress = rskTx.getReceiveAddress(); if (receiveAddress.equals(RskAddress.nullAddress())) { return false; } BridgeConstants bridgeConstants = constants.getBridgeConstants(); return Pre... | BridgeUtils { public static boolean isFreeBridgeTx(Transaction rskTx, Constants constants, ActivationConfig.ForBlock activations) { RskAddress receiveAddress = rskTx.getReceiveAddress(); if (receiveAddress.equals(RskAddress.nullAddress())) { return false; } BridgeConstants bridgeConstants = constants.getBridgeConstants... | BridgeUtils { public static boolean isFreeBridgeTx(Transaction rskTx, Constants constants, ActivationConfig.ForBlock activations) { RskAddress receiveAddress = rskTx.getReceiveAddress(); if (receiveAddress.equals(RskAddress.nullAddress())) { return false; } BridgeConstants bridgeConstants = constants.getBridgeConstants... | BridgeUtils { public static boolean isFreeBridgeTx(Transaction rskTx, Constants constants, ActivationConfig.ForBlock activations) { RskAddress receiveAddress = rskTx.getReceiveAddress(); if (receiveAddress.equals(RskAddress.nullAddress())) { return false; } BridgeConstants bridgeConstants = constants.getBridgeConstants... | BridgeUtils { public static boolean isFreeBridgeTx(Transaction rskTx, Constants constants, ActivationConfig.ForBlock activations) { RskAddress receiveAddress = rskTx.getReceiveAddress(); if (receiveAddress.equals(RskAddress.nullAddress())) { return false; } BridgeConstants bridgeConstants = constants.getBridgeConstants... |
@Test public void isFreeBridgeTxNonFederatorKey() { activationConfig = ActivationConfigsForTest.bridgeUnitTest(); isFreeBridgeTx(false, PrecompiledContracts.BRIDGE_ADDR, new BtcECKey().getPrivKeyBytes()); } | public static boolean isFreeBridgeTx(Transaction rskTx, Constants constants, ActivationConfig.ForBlock activations) { RskAddress receiveAddress = rskTx.getReceiveAddress(); if (receiveAddress.equals(RskAddress.nullAddress())) { return false; } BridgeConstants bridgeConstants = constants.getBridgeConstants(); return Pre... | BridgeUtils { public static boolean isFreeBridgeTx(Transaction rskTx, Constants constants, ActivationConfig.ForBlock activations) { RskAddress receiveAddress = rskTx.getReceiveAddress(); if (receiveAddress.equals(RskAddress.nullAddress())) { return false; } BridgeConstants bridgeConstants = constants.getBridgeConstants... | BridgeUtils { public static boolean isFreeBridgeTx(Transaction rskTx, Constants constants, ActivationConfig.ForBlock activations) { RskAddress receiveAddress = rskTx.getReceiveAddress(); if (receiveAddress.equals(RskAddress.nullAddress())) { return false; } BridgeConstants bridgeConstants = constants.getBridgeConstants... | BridgeUtils { public static boolean isFreeBridgeTx(Transaction rskTx, Constants constants, ActivationConfig.ForBlock activations) { RskAddress receiveAddress = rskTx.getReceiveAddress(); if (receiveAddress.equals(RskAddress.nullAddress())) { return false; } BridgeConstants bridgeConstants = constants.getBridgeConstants... | BridgeUtils { public static boolean isFreeBridgeTx(Transaction rskTx, Constants constants, ActivationConfig.ForBlock activations) { RskAddress receiveAddress = rskTx.getReceiveAddress(); if (receiveAddress.equals(RskAddress.nullAddress())) { return false; } BridgeConstants bridgeConstants = constants.getBridgeConstants... |
@Test public void getFederationNoSpendWallet() { NetworkParameters regTestParameters = NetworkParameters.fromID(NetworkParameters.ID_REGTEST); Federation federation = new Federation(FederationTestUtils.getFederationMembersWithBtcKeys(Arrays.asList( BtcECKey.fromPublicOnly(Hex.decode("036bb9eab797eadc8b697f0e82a01d01cab... | public static Wallet getFederationNoSpendWallet(Context btcContext, Federation federation) { return getFederationsNoSpendWallet(btcContext, Collections.singletonList(federation)); } | BridgeUtils { public static Wallet getFederationNoSpendWallet(Context btcContext, Federation federation) { return getFederationsNoSpendWallet(btcContext, Collections.singletonList(federation)); } } | BridgeUtils { public static Wallet getFederationNoSpendWallet(Context btcContext, Federation federation) { return getFederationsNoSpendWallet(btcContext, Collections.singletonList(federation)); } } | BridgeUtils { public static Wallet getFederationNoSpendWallet(Context btcContext, Federation federation) { return getFederationsNoSpendWallet(btcContext, Collections.singletonList(federation)); } static Wallet getFederationNoSpendWallet(Context btcContext, Federation federation); static Wallet getFederationsNoSpendWal... | BridgeUtils { public static Wallet getFederationNoSpendWallet(Context btcContext, Federation federation) { return getFederationsNoSpendWallet(btcContext, Collections.singletonList(federation)); } static Wallet getFederationNoSpendWallet(Context btcContext, Federation federation); static Wallet getFederationsNoSpendWal... |
@Test public void getFederationSpendWallet() throws UTXOProviderException { NetworkParameters regTestParameters = NetworkParameters.fromID(NetworkParameters.ID_REGTEST); Federation federation = new Federation(FederationTestUtils.getFederationMembersWithBtcKeys(Arrays.asList( BtcECKey.fromPublicOnly(Hex.decode("036bb9ea... | public static Wallet getFederationSpendWallet(Context btcContext, Federation federation, List<UTXO> utxos) { return getFederationsSpendWallet(btcContext, Collections.singletonList(federation), utxos); } | BridgeUtils { public static Wallet getFederationSpendWallet(Context btcContext, Federation federation, List<UTXO> utxos) { return getFederationsSpendWallet(btcContext, Collections.singletonList(federation), utxos); } } | BridgeUtils { public static Wallet getFederationSpendWallet(Context btcContext, Federation federation, List<UTXO> utxos) { return getFederationsSpendWallet(btcContext, Collections.singletonList(federation), utxos); } } | BridgeUtils { public static Wallet getFederationSpendWallet(Context btcContext, Federation federation, List<UTXO> utxos) { return getFederationsSpendWallet(btcContext, Collections.singletonList(federation), utxos); } static Wallet getFederationNoSpendWallet(Context btcContext, Federation federation); static Wallet get... | BridgeUtils { public static Wallet getFederationSpendWallet(Context btcContext, Federation federation, List<UTXO> utxos) { return getFederationsSpendWallet(btcContext, Collections.singletonList(federation), utxos); } static Wallet getFederationNoSpendWallet(Context btcContext, Federation federation); static Wallet get... |
@Test public void test9() { byte[] actuals = encodeList(); assertArrayEquals(new byte[]{(byte) 0xc0}, actuals); } | public static byte[] encodeList(byte[]... elements) { if (elements == null) { return new byte[]{(byte) OFFSET_SHORT_LIST}; } int totalLength = 0; for (byte[] element1 : elements) { totalLength += element1.length; } byte[] data; int copyPos; if (totalLength < SIZE_THRESHOLD) { data = new byte[1 + totalLength]; data[0] =... | RLP { public static byte[] encodeList(byte[]... elements) { if (elements == null) { return new byte[]{(byte) OFFSET_SHORT_LIST}; } int totalLength = 0; for (byte[] element1 : elements) { totalLength += element1.length; } byte[] data; int copyPos; if (totalLength < SIZE_THRESHOLD) { data = new byte[1 + totalLength]; dat... | RLP { public static byte[] encodeList(byte[]... elements) { if (elements == null) { return new byte[]{(byte) OFFSET_SHORT_LIST}; } int totalLength = 0; for (byte[] element1 : elements) { totalLength += element1.length; } byte[] data; int copyPos; if (totalLength < SIZE_THRESHOLD) { data = new byte[1 + totalLength]; dat... | RLP { public static byte[] encodeList(byte[]... elements) { if (elements == null) { return new byte[]{(byte) OFFSET_SHORT_LIST}; } int totalLength = 0; for (byte[] element1 : elements) { totalLength += element1.length; } byte[] data; int copyPos; if (totalLength < SIZE_THRESHOLD) { data = new byte[1 + totalLength]; dat... | RLP { public static byte[] encodeList(byte[]... elements) { if (elements == null) { return new byte[]{(byte) OFFSET_SHORT_LIST}; } int totalLength = 0; for (byte[] element1 : elements) { totalLength += element1.length; } byte[] data; int copyPos; if (totalLength < SIZE_THRESHOLD) { data = new byte[1 + totalLength]; dat... |
@Test public void net_version() throws Exception { Web3Impl web3 = createWeb3(); String netVersion = web3.net_version(); assertTrue("RSK net version different than expected", netVersion.compareTo(Byte.toString(config.getNetworkConstants().getChainId())) == 0); } | @Override public String net_version() { String s = null; try { byte netVersion = config.getNetworkConstants().getChainId(); return s = Byte.toString(netVersion); } finally { if (logger.isDebugEnabled()) { logger.debug("net_version(): {}", s); } } } | Web3Impl implements Web3 { @Override public String net_version() { String s = null; try { byte netVersion = config.getNetworkConstants().getChainId(); return s = Byte.toString(netVersion); } finally { if (logger.isDebugEnabled()) { logger.debug("net_version(): {}", s); } } } } | Web3Impl implements Web3 { @Override public String net_version() { String s = null; try { byte netVersion = config.getNetworkConstants().getChainId(); return s = Byte.toString(netVersion); } finally { if (logger.isDebugEnabled()) { logger.debug("net_version(): {}", s); } } } protected Web3Impl(
Ethereum et... | Web3Impl implements Web3 { @Override public String net_version() { String s = null; try { byte netVersion = config.getNetworkConstants().getChainId(); return s = Byte.toString(netVersion); } finally { if (logger.isDebugEnabled()) { logger.debug("net_version(): {}", s); } } } protected Web3Impl(
Ethereum et... | Web3Impl implements Web3 { @Override public String net_version() { String s = null; try { byte netVersion = config.getNetworkConstants().getChainId(); return s = Byte.toString(netVersion); } finally { if (logger.isDebugEnabled()) { logger.debug("net_version(): {}", s); } } } protected Web3Impl(
Ethereum et... |
@Test public void testIsRelease() { NetworkParameters params = RegTestParams.get(); BridgeRegTestConstants bridgeConstants = BridgeRegTestConstants.getInstance(); Federation federation = bridgeConstants.getGenesisFederation(); List<BtcECKey> federationPrivateKeys = BridgeRegTestConstants.REGTEST_FEDERATION_PRIVATE_KEYS... | private static boolean isReleaseTx(BtcTransaction tx, Federation federation) { return isReleaseTx(tx, Collections.singletonList(federation)); } | BridgeUtils { private static boolean isReleaseTx(BtcTransaction tx, Federation federation) { return isReleaseTx(tx, Collections.singletonList(federation)); } } | BridgeUtils { private static boolean isReleaseTx(BtcTransaction tx, Federation federation) { return isReleaseTx(tx, Collections.singletonList(federation)); } } | BridgeUtils { private static boolean isReleaseTx(BtcTransaction tx, Federation federation) { return isReleaseTx(tx, Collections.singletonList(federation)); } static Wallet getFederationNoSpendWallet(Context btcContext, Federation federation); static Wallet getFederationsNoSpendWallet(Context btcContext, List<Federatio... | BridgeUtils { private static boolean isReleaseTx(BtcTransaction tx, Federation federation) { return isReleaseTx(tx, Collections.singletonList(federation)); } static Wallet getFederationNoSpendWallet(Context btcContext, Federation federation); static Wallet getFederationsNoSpendWallet(Context btcContext, List<Federatio... |
@Test public void testIsContractTx() { Assert.assertFalse(BridgeUtils.isContractTx(new Transaction((byte[]) null, null, null, null, null, null))); Assert.assertTrue(BridgeUtils.isContractTx(new org.ethereum.vm.program.InternalTransaction(null, 0, 0, null, null, null, null, null, null, null, null))); } | public static boolean isContractTx(Transaction rskTx) { return rskTx.getClass() == org.ethereum.vm.program.InternalTransaction.class; } | BridgeUtils { public static boolean isContractTx(Transaction rskTx) { return rskTx.getClass() == org.ethereum.vm.program.InternalTransaction.class; } } | BridgeUtils { public static boolean isContractTx(Transaction rskTx) { return rskTx.getClass() == org.ethereum.vm.program.InternalTransaction.class; } } | BridgeUtils { public static boolean isContractTx(Transaction rskTx) { return rskTx.getClass() == org.ethereum.vm.program.InternalTransaction.class; } static Wallet getFederationNoSpendWallet(Context btcContext, Federation federation); static Wallet getFederationsNoSpendWallet(Context btcContext, List<Federation> feder... | BridgeUtils { public static boolean isContractTx(Transaction rskTx) { return rskTx.getClass() == org.ethereum.vm.program.InternalTransaction.class; } static Wallet getFederationNoSpendWallet(Context btcContext, Federation federation); static Wallet getFederationsNoSpendWallet(Context btcContext, List<Federation> feder... |
@Test(expected = BridgeIllegalArgumentException.class) public void getCoinFromBigInteger_bigger_than_long_value() { BridgeUtils.getCoinFromBigInteger(new BigInteger("9223372036854775808")); } | public static Coin getCoinFromBigInteger(BigInteger value) { if (value == null) { throw new BridgeIllegalArgumentException("value cannot be null"); } try { return Coin.valueOf(value.longValueExact()); } catch(ArithmeticException e) { throw new BridgeIllegalArgumentException(e.getMessage(), e); } } | BridgeUtils { public static Coin getCoinFromBigInteger(BigInteger value) { if (value == null) { throw new BridgeIllegalArgumentException("value cannot be null"); } try { return Coin.valueOf(value.longValueExact()); } catch(ArithmeticException e) { throw new BridgeIllegalArgumentException(e.getMessage(), e); } } } | BridgeUtils { public static Coin getCoinFromBigInteger(BigInteger value) { if (value == null) { throw new BridgeIllegalArgumentException("value cannot be null"); } try { return Coin.valueOf(value.longValueExact()); } catch(ArithmeticException e) { throw new BridgeIllegalArgumentException(e.getMessage(), e); } } } | BridgeUtils { public static Coin getCoinFromBigInteger(BigInteger value) { if (value == null) { throw new BridgeIllegalArgumentException("value cannot be null"); } try { return Coin.valueOf(value.longValueExact()); } catch(ArithmeticException e) { throw new BridgeIllegalArgumentException(e.getMessage(), e); } } static... | BridgeUtils { public static Coin getCoinFromBigInteger(BigInteger value) { if (value == null) { throw new BridgeIllegalArgumentException("value cannot be null"); } try { return Coin.valueOf(value.longValueExact()); } catch(ArithmeticException e) { throw new BridgeIllegalArgumentException(e.getMessage(), e); } } static... |
@Test(expected = BridgeIllegalArgumentException.class) public void getCoinFromBigInteger_null_value() { BridgeUtils.getCoinFromBigInteger(null); } | public static Coin getCoinFromBigInteger(BigInteger value) { if (value == null) { throw new BridgeIllegalArgumentException("value cannot be null"); } try { return Coin.valueOf(value.longValueExact()); } catch(ArithmeticException e) { throw new BridgeIllegalArgumentException(e.getMessage(), e); } } | BridgeUtils { public static Coin getCoinFromBigInteger(BigInteger value) { if (value == null) { throw new BridgeIllegalArgumentException("value cannot be null"); } try { return Coin.valueOf(value.longValueExact()); } catch(ArithmeticException e) { throw new BridgeIllegalArgumentException(e.getMessage(), e); } } } | BridgeUtils { public static Coin getCoinFromBigInteger(BigInteger value) { if (value == null) { throw new BridgeIllegalArgumentException("value cannot be null"); } try { return Coin.valueOf(value.longValueExact()); } catch(ArithmeticException e) { throw new BridgeIllegalArgumentException(e.getMessage(), e); } } } | BridgeUtils { public static Coin getCoinFromBigInteger(BigInteger value) { if (value == null) { throw new BridgeIllegalArgumentException("value cannot be null"); } try { return Coin.valueOf(value.longValueExact()); } catch(ArithmeticException e) { throw new BridgeIllegalArgumentException(e.getMessage(), e); } } static... | BridgeUtils { public static Coin getCoinFromBigInteger(BigInteger value) { if (value == null) { throw new BridgeIllegalArgumentException("value cannot be null"); } try { return Coin.valueOf(value.longValueExact()); } catch(ArithmeticException e) { throw new BridgeIllegalArgumentException(e.getMessage(), e); } } static... |
@Test public void getCoinFromBigInteger() { Assert.assertEquals(Coin.COIN, BridgeUtils.getCoinFromBigInteger(BigInteger.valueOf(Coin.COIN.getValue()))); } | public static Coin getCoinFromBigInteger(BigInteger value) { if (value == null) { throw new BridgeIllegalArgumentException("value cannot be null"); } try { return Coin.valueOf(value.longValueExact()); } catch(ArithmeticException e) { throw new BridgeIllegalArgumentException(e.getMessage(), e); } } | BridgeUtils { public static Coin getCoinFromBigInteger(BigInteger value) { if (value == null) { throw new BridgeIllegalArgumentException("value cannot be null"); } try { return Coin.valueOf(value.longValueExact()); } catch(ArithmeticException e) { throw new BridgeIllegalArgumentException(e.getMessage(), e); } } } | BridgeUtils { public static Coin getCoinFromBigInteger(BigInteger value) { if (value == null) { throw new BridgeIllegalArgumentException("value cannot be null"); } try { return Coin.valueOf(value.longValueExact()); } catch(ArithmeticException e) { throw new BridgeIllegalArgumentException(e.getMessage(), e); } } } | BridgeUtils { public static Coin getCoinFromBigInteger(BigInteger value) { if (value == null) { throw new BridgeIllegalArgumentException("value cannot be null"); } try { return Coin.valueOf(value.longValueExact()); } catch(ArithmeticException e) { throw new BridgeIllegalArgumentException(e.getMessage(), e); } } static... | BridgeUtils { public static Coin getCoinFromBigInteger(BigInteger value) { if (value == null) { throw new BridgeIllegalArgumentException("value cannot be null"); } try { return Coin.valueOf(value.longValueExact()); } catch(ArithmeticException e) { throw new BridgeIllegalArgumentException(e.getMessage(), e); } } static... |
@Test(expected = Exception.class) public void validateHeightAndConfirmations_invalid_height() throws Exception { Assert.assertFalse(BridgeUtils.validateHeightAndConfirmations(-1, 0, 0, null)); } | public static boolean validateHeightAndConfirmations(int height, int btcBestChainHeight, int acceptableConfirmationsAmount, Sha256Hash btcTxHash) throws Exception { if (height < 0) { throw new Exception("Height can't be lower than 0"); } int confirmations = btcBestChainHeight - height + 1; if (confirmations < acceptabl... | BridgeUtils { public static boolean validateHeightAndConfirmations(int height, int btcBestChainHeight, int acceptableConfirmationsAmount, Sha256Hash btcTxHash) throws Exception { if (height < 0) { throw new Exception("Height can't be lower than 0"); } int confirmations = btcBestChainHeight - height + 1; if (confirmatio... | BridgeUtils { public static boolean validateHeightAndConfirmations(int height, int btcBestChainHeight, int acceptableConfirmationsAmount, Sha256Hash btcTxHash) throws Exception { if (height < 0) { throw new Exception("Height can't be lower than 0"); } int confirmations = btcBestChainHeight - height + 1; if (confirmatio... | BridgeUtils { public static boolean validateHeightAndConfirmations(int height, int btcBestChainHeight, int acceptableConfirmationsAmount, Sha256Hash btcTxHash) throws Exception { if (height < 0) { throw new Exception("Height can't be lower than 0"); } int confirmations = btcBestChainHeight - height + 1; if (confirmatio... | BridgeUtils { public static boolean validateHeightAndConfirmations(int height, int btcBestChainHeight, int acceptableConfirmationsAmount, Sha256Hash btcTxHash) throws Exception { if (height < 0) { throw new Exception("Height can't be lower than 0"); } int confirmations = btcBestChainHeight - height + 1; if (confirmatio... |
@Test public void validateHeightAndConfirmation_insufficient_confirmations() throws Exception { Assert.assertFalse(BridgeUtils.validateHeightAndConfirmations(2, 5, 10, Sha256Hash.of(Hex.decode("ab")))); } | public static boolean validateHeightAndConfirmations(int height, int btcBestChainHeight, int acceptableConfirmationsAmount, Sha256Hash btcTxHash) throws Exception { if (height < 0) { throw new Exception("Height can't be lower than 0"); } int confirmations = btcBestChainHeight - height + 1; if (confirmations < acceptabl... | BridgeUtils { public static boolean validateHeightAndConfirmations(int height, int btcBestChainHeight, int acceptableConfirmationsAmount, Sha256Hash btcTxHash) throws Exception { if (height < 0) { throw new Exception("Height can't be lower than 0"); } int confirmations = btcBestChainHeight - height + 1; if (confirmatio... | BridgeUtils { public static boolean validateHeightAndConfirmations(int height, int btcBestChainHeight, int acceptableConfirmationsAmount, Sha256Hash btcTxHash) throws Exception { if (height < 0) { throw new Exception("Height can't be lower than 0"); } int confirmations = btcBestChainHeight - height + 1; if (confirmatio... | BridgeUtils { public static boolean validateHeightAndConfirmations(int height, int btcBestChainHeight, int acceptableConfirmationsAmount, Sha256Hash btcTxHash) throws Exception { if (height < 0) { throw new Exception("Height can't be lower than 0"); } int confirmations = btcBestChainHeight - height + 1; if (confirmatio... | BridgeUtils { public static boolean validateHeightAndConfirmations(int height, int btcBestChainHeight, int acceptableConfirmationsAmount, Sha256Hash btcTxHash) throws Exception { if (height < 0) { throw new Exception("Height can't be lower than 0"); } int confirmations = btcBestChainHeight - height + 1; if (confirmatio... |
@Test public void validateHeightAndConfirmation_enough_confirmations() throws Exception { Assert.assertTrue(BridgeUtils.validateHeightAndConfirmations(2, 5, 3, Sha256Hash.of(Hex.decode("ab")))); } | public static boolean validateHeightAndConfirmations(int height, int btcBestChainHeight, int acceptableConfirmationsAmount, Sha256Hash btcTxHash) throws Exception { if (height < 0) { throw new Exception("Height can't be lower than 0"); } int confirmations = btcBestChainHeight - height + 1; if (confirmations < acceptabl... | BridgeUtils { public static boolean validateHeightAndConfirmations(int height, int btcBestChainHeight, int acceptableConfirmationsAmount, Sha256Hash btcTxHash) throws Exception { if (height < 0) { throw new Exception("Height can't be lower than 0"); } int confirmations = btcBestChainHeight - height + 1; if (confirmatio... | BridgeUtils { public static boolean validateHeightAndConfirmations(int height, int btcBestChainHeight, int acceptableConfirmationsAmount, Sha256Hash btcTxHash) throws Exception { if (height < 0) { throw new Exception("Height can't be lower than 0"); } int confirmations = btcBestChainHeight - height + 1; if (confirmatio... | BridgeUtils { public static boolean validateHeightAndConfirmations(int height, int btcBestChainHeight, int acceptableConfirmationsAmount, Sha256Hash btcTxHash) throws Exception { if (height < 0) { throw new Exception("Height can't be lower than 0"); } int confirmations = btcBestChainHeight - height + 1; if (confirmatio... | BridgeUtils { public static boolean validateHeightAndConfirmations(int height, int btcBestChainHeight, int acceptableConfirmationsAmount, Sha256Hash btcTxHash) throws Exception { if (height < 0) { throw new Exception("Height can't be lower than 0"); } int confirmations = btcBestChainHeight - height + 1; if (confirmatio... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.