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(expected = IllegalArgumentException.class) public void hexadecimalStringToLongFailBis() { Utils.hexadecimalStringToLong("zzz"); } | public static long hexadecimalStringToLong(String s) { if (!s.startsWith("0x")) { throw new IllegalArgumentException(String.format("Invalid hexadecimal number: %s", s)); } try { return Long.parseLong(s.substring(2), 16); } catch (NumberFormatException e) { throw new IllegalArgumentException(String.format("Invalid hexad... | Utils { public static long hexadecimalStringToLong(String s) { if (!s.startsWith("0x")) { throw new IllegalArgumentException(String.format("Invalid hexadecimal number: %s", s)); } try { return Long.parseLong(s.substring(2), 16); } catch (NumberFormatException e) { throw new IllegalArgumentException(String.format("Inval... | Utils { public static long hexadecimalStringToLong(String s) { if (!s.startsWith("0x")) { throw new IllegalArgumentException(String.format("Invalid hexadecimal number: %s", s)); } try { return Long.parseLong(s.substring(2), 16); } catch (NumberFormatException e) { throw new IllegalArgumentException(String.format("Inval... | Utils { public static long hexadecimalStringToLong(String s) { if (!s.startsWith("0x")) { throw new IllegalArgumentException(String.format("Invalid hexadecimal number: %s", s)); } try { return Long.parseLong(s.substring(2), 16); } catch (NumberFormatException e) { throw new IllegalArgumentException(String.format("Inval... | Utils { public static long hexadecimalStringToLong(String s) { if (!s.startsWith("0x")) { throw new IllegalArgumentException(String.format("Invalid hexadecimal number: %s", s)); } try { return Long.parseLong(s.substring(2), 16); } catch (NumberFormatException e) { throw new IllegalArgumentException(String.format("Inval... |
@Test public void significantBitCount() { Assert.assertEquals(0, Utils.significantBitCount(0b0)); Assert.assertEquals(1, Utils.significantBitCount(0b1)); Assert.assertEquals(2, Utils.significantBitCount(0b10)); Assert.assertEquals(2, Utils.significantBitCount(0b11)); Assert.assertEquals(3, Utils.significantBitCount(0b1... | public static int significantBitCount(int number) { int result = 0; while (number > 0) { result++; number >>= 1; } return result; } | Utils { public static int significantBitCount(int number) { int result = 0; while (number > 0) { result++; number >>= 1; } return result; } } | Utils { public static int significantBitCount(int number) { int result = 0; while (number > 0) { result++; number >>= 1; } return result; } } | Utils { public static int significantBitCount(int number) { int result = 0; while (number > 0) { result++; number >>= 1; } return result; } static BigInteger unifiedNumericToBigInteger(String number); static String longToDateTime(long timestamp); static String getValueShortString(BigInteger number); static byte[] addr... | Utils { public static int significantBitCount(int number) { int result = 0; while (number > 0) { result++; number >>= 1; } return result; } static BigInteger unifiedNumericToBigInteger(String number); static String longToDateTime(long timestamp); static String getValueShortString(BigInteger number); static byte[] addr... |
@Test public void testEqualsObject() { assertTrue(wrapper1.equals(wrapper2)); assertFalse(wrapper1.equals(wrapper3)); assertFalse(wrapper1.equals(wrapper4)); assertFalse(wrapper1.equals(null)); assertFalse(wrapper2.equals(wrapper3)); } | public boolean equals(Object other) { if (!(other instanceof ByteArrayWrapper)) { return false; } byte[] otherData = ((ByteArrayWrapper) other).data; return ByteUtil.fastEquals(data, otherData); } | ByteArrayWrapper implements Comparable<ByteArrayWrapper>, Serializable { public boolean equals(Object other) { if (!(other instanceof ByteArrayWrapper)) { return false; } byte[] otherData = ((ByteArrayWrapper) other).data; return ByteUtil.fastEquals(data, otherData); } } | ByteArrayWrapper implements Comparable<ByteArrayWrapper>, Serializable { public boolean equals(Object other) { if (!(other instanceof ByteArrayWrapper)) { return false; } byte[] otherData = ((ByteArrayWrapper) other).data; return ByteUtil.fastEquals(data, otherData); } ByteArrayWrapper(byte[] data); } | ByteArrayWrapper implements Comparable<ByteArrayWrapper>, Serializable { public boolean equals(Object other) { if (!(other instanceof ByteArrayWrapper)) { return false; } byte[] otherData = ((ByteArrayWrapper) other).data; return ByteUtil.fastEquals(data, otherData); } ByteArrayWrapper(byte[] data); boolean equals(Obje... | ByteArrayWrapper implements Comparable<ByteArrayWrapper>, Serializable { public boolean equals(Object other) { if (!(other instanceof ByteArrayWrapper)) { return false; } byte[] otherData = ((ByteArrayWrapper) other).data; return ByteUtil.fastEquals(data, otherData); } ByteArrayWrapper(byte[] data); boolean equals(Obje... |
@Test public void getBalanceWithAccountAndGenesisBlock() throws Exception { World world = new World(); Account acc1 = new AccountBuilder(world).name("acc1").balance(Coin.valueOf(10000)).build(); Web3Impl web3 = createWeb3(world); String accountAddress = ByteUtil.toHexString(acc1.getAddress().getBytes()); String balance... | @Override public String eth_getBalance(String address, String block) { AccountInformationProvider accountInformationProvider = web3InformationRetriever.getInformationProvider(block); RskAddress addr = new RskAddress(address); Coin balance = accountInformationProvider.getBalance(addr); return toQuantityJsonHex(balance.a... | Web3Impl implements Web3 { @Override public String eth_getBalance(String address, String block) { AccountInformationProvider accountInformationProvider = web3InformationRetriever.getInformationProvider(block); RskAddress addr = new RskAddress(address); Coin balance = accountInformationProvider.getBalance(addr); return ... | Web3Impl implements Web3 { @Override public String eth_getBalance(String address, String block) { AccountInformationProvider accountInformationProvider = web3InformationRetriever.getInformationProvider(block); RskAddress addr = new RskAddress(address); Coin balance = accountInformationProvider.getBalance(addr); return ... | Web3Impl implements Web3 { @Override public String eth_getBalance(String address, String block) { AccountInformationProvider accountInformationProvider = web3InformationRetriever.getInformationProvider(block); RskAddress addr = new RskAddress(address); Coin balance = accountInformationProvider.getBalance(addr); return ... | Web3Impl implements Web3 { @Override public String eth_getBalance(String address, String block) { AccountInformationProvider accountInformationProvider = web3InformationRetriever.getInformationProvider(block); RskAddress addr = new RskAddress(address); Coin balance = accountInformationProvider.getBalance(addr); return ... |
@Test public void testCompareTo() { assertTrue(wrapper1.compareTo(wrapper2) == 0); assertTrue(wrapper1.compareTo(wrapper3) > 1); assertTrue(wrapper1.compareTo(wrapper4) > 1); assertTrue(wrapper2.compareTo(wrapper3) > 1); } | @Override public int compareTo(ByteArrayWrapper o) { return FastByteComparisons.compareTo( data, 0, data.length, o.data, 0, o.data.length); } | ByteArrayWrapper implements Comparable<ByteArrayWrapper>, Serializable { @Override public int compareTo(ByteArrayWrapper o) { return FastByteComparisons.compareTo( data, 0, data.length, o.data, 0, o.data.length); } } | ByteArrayWrapper implements Comparable<ByteArrayWrapper>, Serializable { @Override public int compareTo(ByteArrayWrapper o) { return FastByteComparisons.compareTo( data, 0, data.length, o.data, 0, o.data.length); } ByteArrayWrapper(byte[] data); } | ByteArrayWrapper implements Comparable<ByteArrayWrapper>, Serializable { @Override public int compareTo(ByteArrayWrapper o) { return FastByteComparisons.compareTo( data, 0, data.length, o.data, 0, o.data.length); } ByteArrayWrapper(byte[] data); boolean equals(Object other); @Override int hashCode(); @Override int comp... | ByteArrayWrapper implements Comparable<ByteArrayWrapper>, Serializable { @Override public int compareTo(ByteArrayWrapper o) { return FastByteComparisons.compareTo( data, 0, data.length, o.data, 0, o.data.length); } ByteArrayWrapper(byte[] data); boolean equals(Object other); @Override int hashCode(); @Override int comp... |
@Test public void getUnknownKey() { ReceiptStore store = new ReceiptStoreImpl(new HashMapDB()); byte[] key = new byte[] { 0x01, 0x02 }; TransactionInfo result = store.get(key); Assert.assertNull(result); } | @Override public TransactionInfo get(byte[] transactionHash){ List<TransactionInfo> txs = getAll(transactionHash); if (txs.isEmpty()) { return null; } return txs.get(txs.size() - 1); } | ReceiptStoreImpl implements ReceiptStore { @Override public TransactionInfo get(byte[] transactionHash){ List<TransactionInfo> txs = getAll(transactionHash); if (txs.isEmpty()) { return null; } return txs.get(txs.size() - 1); } } | ReceiptStoreImpl implements ReceiptStore { @Override public TransactionInfo get(byte[] transactionHash){ List<TransactionInfo> txs = getAll(transactionHash); if (txs.isEmpty()) { return null; } return txs.get(txs.size() - 1); } ReceiptStoreImpl(KeyValueDataSource receiptsDS); } | ReceiptStoreImpl implements ReceiptStore { @Override public TransactionInfo get(byte[] transactionHash){ List<TransactionInfo> txs = getAll(transactionHash); if (txs.isEmpty()) { return null; } return txs.get(txs.size() - 1); } ReceiptStoreImpl(KeyValueDataSource receiptsDS); @Override void add(byte[] blockHash, int tr... | ReceiptStoreImpl implements ReceiptStore { @Override public TransactionInfo get(byte[] transactionHash){ List<TransactionInfo> txs = getAll(transactionHash); if (txs.isEmpty()) { return null; } return txs.get(txs.size() - 1); } ReceiptStoreImpl(KeyValueDataSource receiptsDS); @Override void add(byte[] blockHash, int tr... |
@Test public void getUnknownTransactionByBlock() { ReceiptStore store = new ReceiptStoreImpl(new HashMapDB()); TransactionReceipt receipt = createReceipt(); Keccak256 blockHash = TestUtils.randomHash(); Optional<TransactionInfo> resultOpt = store.get(receipt.getTransaction().getHash(), blockHash); Assert.assertFalse(re... | @Override public TransactionInfo get(byte[] transactionHash){ List<TransactionInfo> txs = getAll(transactionHash); if (txs.isEmpty()) { return null; } return txs.get(txs.size() - 1); } | ReceiptStoreImpl implements ReceiptStore { @Override public TransactionInfo get(byte[] transactionHash){ List<TransactionInfo> txs = getAll(transactionHash); if (txs.isEmpty()) { return null; } return txs.get(txs.size() - 1); } } | ReceiptStoreImpl implements ReceiptStore { @Override public TransactionInfo get(byte[] transactionHash){ List<TransactionInfo> txs = getAll(transactionHash); if (txs.isEmpty()) { return null; } return txs.get(txs.size() - 1); } ReceiptStoreImpl(KeyValueDataSource receiptsDS); } | ReceiptStoreImpl implements ReceiptStore { @Override public TransactionInfo get(byte[] transactionHash){ List<TransactionInfo> txs = getAll(transactionHash); if (txs.isEmpty()) { return null; } return txs.get(txs.size() - 1); } ReceiptStoreImpl(KeyValueDataSource receiptsDS); @Override void add(byte[] blockHash, int tr... | ReceiptStoreImpl implements ReceiptStore { @Override public TransactionInfo get(byte[] transactionHash){ List<TransactionInfo> txs = getAll(transactionHash); if (txs.isEmpty()) { return null; } return txs.get(txs.size() - 1); } ReceiptStoreImpl(KeyValueDataSource receiptsDS); @Override void add(byte[] blockHash, int tr... |
@Test public void rewind() { IndexedBlockStore indexedBlockStore = new IndexedBlockStore( mock(BlockFactory.class), mock(KeyValueDataSource.class), new HashMapBlocksIndex()); long blocksToGenerate = 14; for (long i = 0; i < blocksToGenerate; i++) { Block block = mock(Block.class); Keccak256 blockHash = randomHash(); wh... | public void rewind(long blockNumber) { if (index.isEmpty()) { return; } long maxNumber = getMaxNumber(); for (long i = maxNumber; i > blockNumber; i--) { List<BlockInfo> blockInfos = index.removeLast(); for (BlockInfo blockInfo : blockInfos) { this.blocks.delete(blockInfo.getHash().getBytes()); } } flush(); } | IndexedBlockStore implements BlockStore { public void rewind(long blockNumber) { if (index.isEmpty()) { return; } long maxNumber = getMaxNumber(); for (long i = maxNumber; i > blockNumber; i--) { List<BlockInfo> blockInfos = index.removeLast(); for (BlockInfo blockInfo : blockInfos) { this.blocks.delete(blockInfo.getHa... | IndexedBlockStore implements BlockStore { public void rewind(long blockNumber) { if (index.isEmpty()) { return; } long maxNumber = getMaxNumber(); for (long i = maxNumber; i > blockNumber; i--) { List<BlockInfo> blockInfos = index.removeLast(); for (BlockInfo blockInfo : blockInfos) { this.blocks.delete(blockInfo.getHa... | IndexedBlockStore implements BlockStore { public void rewind(long blockNumber) { if (index.isEmpty()) { return; } long maxNumber = getMaxNumber(); for (long i = maxNumber; i > blockNumber; i--) { List<BlockInfo> blockInfos = index.removeLast(); for (BlockInfo blockInfo : blockInfos) { this.blocks.delete(blockInfo.getHa... | IndexedBlockStore implements BlockStore { public void rewind(long blockNumber) { if (index.isEmpty()) { return; } long maxNumber = getMaxNumber(); for (long i = maxNumber; i > blockNumber; i--) { List<BlockInfo> blockInfos = index.removeLast(); for (BlockInfo blockInfo : blockInfos) { this.blocks.delete(blockInfo.getHa... |
@Test public void devnetWithFederationTest() { Constants constants = Constants.devnetWithFederation(TEST_FED_KEYS.subList(0, 3)); assertThat(constants.getBridgeConstants().getGenesisFederation().hasBtcPublicKey(TEST_FED_KEYS.get(0)), is(true)); assertThat(constants.getBridgeConstants().getGenesisFederation().hasBtcPubl... | public static Constants devnetWithFederation(List<BtcECKey> federationPublicKeys) { return new Constants( DEVNET_CHAIN_ID, false, 14, new BlockDifficulty(BigInteger.valueOf(131072)), new BlockDifficulty(BigInteger.valueOf((long) 14E15)), BigInteger.valueOf(50), 540, new BridgeDevNetConstants(federationPublicKeys) ); } | Constants { public static Constants devnetWithFederation(List<BtcECKey> federationPublicKeys) { return new Constants( DEVNET_CHAIN_ID, false, 14, new BlockDifficulty(BigInteger.valueOf(131072)), new BlockDifficulty(BigInteger.valueOf((long) 14E15)), BigInteger.valueOf(50), 540, new BridgeDevNetConstants(federationPubli... | Constants { public static Constants devnetWithFederation(List<BtcECKey> federationPublicKeys) { return new Constants( DEVNET_CHAIN_ID, false, 14, new BlockDifficulty(BigInteger.valueOf(131072)), new BlockDifficulty(BigInteger.valueOf((long) 14E15)), BigInteger.valueOf(50), 540, new BridgeDevNetConstants(federationPubli... | Constants { public static Constants devnetWithFederation(List<BtcECKey> federationPublicKeys) { return new Constants( DEVNET_CHAIN_ID, false, 14, new BlockDifficulty(BigInteger.valueOf(131072)), new BlockDifficulty(BigInteger.valueOf((long) 14E15)), BigInteger.valueOf(50), 540, new BridgeDevNetConstants(federationPubli... | Constants { public static Constants devnetWithFederation(List<BtcECKey> federationPublicKeys) { return new Constants( DEVNET_CHAIN_ID, false, 14, new BlockDifficulty(BigInteger.valueOf(131072)), new BlockDifficulty(BigInteger.valueOf((long) 14E15)), BigInteger.valueOf(50), 540, new BridgeDevNetConstants(federationPubli... |
@Test(expected = IllegalArgumentException.class) public void failsReadingWithMissingNetworkUpgrade() { ActivationConfig.read(BASE_CONFIG .withoutPath("consensusRules.rskip85") ); } | public static ActivationConfig read(Config config) { Map<NetworkUpgrade, Long> networkUpgrades = new EnumMap<>(NetworkUpgrade.class); Config networkUpgradesConfig = config.getConfig(PROPERTY_ACTIVATION_HEIGHTS); for (Map.Entry<String, ConfigValue> e : networkUpgradesConfig.entrySet()) { NetworkUpgrade networkUpgrade = ... | ActivationConfig { public static ActivationConfig read(Config config) { Map<NetworkUpgrade, Long> networkUpgrades = new EnumMap<>(NetworkUpgrade.class); Config networkUpgradesConfig = config.getConfig(PROPERTY_ACTIVATION_HEIGHTS); for (Map.Entry<String, ConfigValue> e : networkUpgradesConfig.entrySet()) { NetworkUpgrad... | ActivationConfig { public static ActivationConfig read(Config config) { Map<NetworkUpgrade, Long> networkUpgrades = new EnumMap<>(NetworkUpgrade.class); Config networkUpgradesConfig = config.getConfig(PROPERTY_ACTIVATION_HEIGHTS); for (Map.Entry<String, ConfigValue> e : networkUpgradesConfig.entrySet()) { NetworkUpgrad... | ActivationConfig { public static ActivationConfig read(Config config) { Map<NetworkUpgrade, Long> networkUpgrades = new EnumMap<>(NetworkUpgrade.class); Config networkUpgradesConfig = config.getConfig(PROPERTY_ACTIVATION_HEIGHTS); for (Map.Entry<String, ConfigValue> e : networkUpgradesConfig.entrySet()) { NetworkUpgrad... | ActivationConfig { public static ActivationConfig read(Config config) { Map<NetworkUpgrade, Long> networkUpgrades = new EnumMap<>(NetworkUpgrade.class); Config networkUpgradesConfig = config.getConfig(PROPERTY_ACTIVATION_HEIGHTS); for (Map.Entry<String, ConfigValue> e : networkUpgradesConfig.entrySet()) { NetworkUpgrad... |
@Test(expected = IllegalArgumentException.class) public void failsReadingWithMissingHardFork() { ActivationConfig.read(BASE_CONFIG .withoutPath("hardforkActivationHeights.orchid") ); } | public static ActivationConfig read(Config config) { Map<NetworkUpgrade, Long> networkUpgrades = new EnumMap<>(NetworkUpgrade.class); Config networkUpgradesConfig = config.getConfig(PROPERTY_ACTIVATION_HEIGHTS); for (Map.Entry<String, ConfigValue> e : networkUpgradesConfig.entrySet()) { NetworkUpgrade networkUpgrade = ... | ActivationConfig { public static ActivationConfig read(Config config) { Map<NetworkUpgrade, Long> networkUpgrades = new EnumMap<>(NetworkUpgrade.class); Config networkUpgradesConfig = config.getConfig(PROPERTY_ACTIVATION_HEIGHTS); for (Map.Entry<String, ConfigValue> e : networkUpgradesConfig.entrySet()) { NetworkUpgrad... | ActivationConfig { public static ActivationConfig read(Config config) { Map<NetworkUpgrade, Long> networkUpgrades = new EnumMap<>(NetworkUpgrade.class); Config networkUpgradesConfig = config.getConfig(PROPERTY_ACTIVATION_HEIGHTS); for (Map.Entry<String, ConfigValue> e : networkUpgradesConfig.entrySet()) { NetworkUpgrad... | ActivationConfig { public static ActivationConfig read(Config config) { Map<NetworkUpgrade, Long> networkUpgrades = new EnumMap<>(NetworkUpgrade.class); Config networkUpgradesConfig = config.getConfig(PROPERTY_ACTIVATION_HEIGHTS); for (Map.Entry<String, ConfigValue> e : networkUpgradesConfig.entrySet()) { NetworkUpgrad... | ActivationConfig { public static ActivationConfig read(Config config) { Map<NetworkUpgrade, Long> networkUpgrades = new EnumMap<>(NetworkUpgrade.class); Config networkUpgradesConfig = config.getConfig(PROPERTY_ACTIVATION_HEIGHTS); for (Map.Entry<String, ConfigValue> e : networkUpgradesConfig.entrySet()) { NetworkUpgrad... |
@Test(expected = IllegalArgumentException.class) public void failsReadingWithUnknownForkConfiguration() { ActivationConfig.read(BASE_CONFIG .withValue("hardforkActivationHeights.orkid", ConfigValueFactory.fromAnyRef(200)) ); } | public static ActivationConfig read(Config config) { Map<NetworkUpgrade, Long> networkUpgrades = new EnumMap<>(NetworkUpgrade.class); Config networkUpgradesConfig = config.getConfig(PROPERTY_ACTIVATION_HEIGHTS); for (Map.Entry<String, ConfigValue> e : networkUpgradesConfig.entrySet()) { NetworkUpgrade networkUpgrade = ... | ActivationConfig { public static ActivationConfig read(Config config) { Map<NetworkUpgrade, Long> networkUpgrades = new EnumMap<>(NetworkUpgrade.class); Config networkUpgradesConfig = config.getConfig(PROPERTY_ACTIVATION_HEIGHTS); for (Map.Entry<String, ConfigValue> e : networkUpgradesConfig.entrySet()) { NetworkUpgrad... | ActivationConfig { public static ActivationConfig read(Config config) { Map<NetworkUpgrade, Long> networkUpgrades = new EnumMap<>(NetworkUpgrade.class); Config networkUpgradesConfig = config.getConfig(PROPERTY_ACTIVATION_HEIGHTS); for (Map.Entry<String, ConfigValue> e : networkUpgradesConfig.entrySet()) { NetworkUpgrad... | ActivationConfig { public static ActivationConfig read(Config config) { Map<NetworkUpgrade, Long> networkUpgrades = new EnumMap<>(NetworkUpgrade.class); Config networkUpgradesConfig = config.getConfig(PROPERTY_ACTIVATION_HEIGHTS); for (Map.Entry<String, ConfigValue> e : networkUpgradesConfig.entrySet()) { NetworkUpgrad... | ActivationConfig { public static ActivationConfig read(Config config) { Map<NetworkUpgrade, Long> networkUpgrades = new EnumMap<>(NetworkUpgrade.class); Config networkUpgradesConfig = config.getConfig(PROPERTY_ACTIVATION_HEIGHTS); for (Map.Entry<String, ConfigValue> e : networkUpgradesConfig.entrySet()) { NetworkUpgrad... |
@Test(expected = IllegalArgumentException.class) public void failsReadingWithUnknownUpgradeConfiguration() { ActivationConfig.read(BASE_CONFIG .withValue("consensusRules.rskip420", ConfigValueFactory.fromAnyRef("orchid")) ); } | public static ActivationConfig read(Config config) { Map<NetworkUpgrade, Long> networkUpgrades = new EnumMap<>(NetworkUpgrade.class); Config networkUpgradesConfig = config.getConfig(PROPERTY_ACTIVATION_HEIGHTS); for (Map.Entry<String, ConfigValue> e : networkUpgradesConfig.entrySet()) { NetworkUpgrade networkUpgrade = ... | ActivationConfig { public static ActivationConfig read(Config config) { Map<NetworkUpgrade, Long> networkUpgrades = new EnumMap<>(NetworkUpgrade.class); Config networkUpgradesConfig = config.getConfig(PROPERTY_ACTIVATION_HEIGHTS); for (Map.Entry<String, ConfigValue> e : networkUpgradesConfig.entrySet()) { NetworkUpgrad... | ActivationConfig { public static ActivationConfig read(Config config) { Map<NetworkUpgrade, Long> networkUpgrades = new EnumMap<>(NetworkUpgrade.class); Config networkUpgradesConfig = config.getConfig(PROPERTY_ACTIVATION_HEIGHTS); for (Map.Entry<String, ConfigValue> e : networkUpgradesConfig.entrySet()) { NetworkUpgrad... | ActivationConfig { public static ActivationConfig read(Config config) { Map<NetworkUpgrade, Long> networkUpgrades = new EnumMap<>(NetworkUpgrade.class); Config networkUpgradesConfig = config.getConfig(PROPERTY_ACTIVATION_HEIGHTS); for (Map.Entry<String, ConfigValue> e : networkUpgradesConfig.entrySet()) { NetworkUpgrad... | ActivationConfig { public static ActivationConfig read(Config config) { Map<NetworkUpgrade, Long> networkUpgrades = new EnumMap<>(NetworkUpgrade.class); Config networkUpgradesConfig = config.getConfig(PROPERTY_ACTIVATION_HEIGHTS); for (Map.Entry<String, ConfigValue> e : networkUpgradesConfig.entrySet()) { NetworkUpgrad... |
@Test public void testCreateAuthInitiate() throws Exception { AuthInitiateMessage message = initiator.createAuthInitiate(new byte[32], myKey); int expectedLength = 65+32+64+32+1; byte[] buffer = message.encode(); assertEquals(expectedLength, buffer.length); } | public AuthInitiateMessage createAuthInitiate(@Nullable byte[] token, ECKey key) { AuthInitiateMessage message = new AuthInitiateMessage(); boolean isToken; if (token == null) { isToken = false; BigInteger secretScalar = remotePublicKey.multiply(key.getPrivKey()).normalize().getXCoord().toBigInteger(); token = ByteUtil... | EncryptionHandshake { public AuthInitiateMessage createAuthInitiate(@Nullable byte[] token, ECKey key) { AuthInitiateMessage message = new AuthInitiateMessage(); boolean isToken; if (token == null) { isToken = false; BigInteger secretScalar = remotePublicKey.multiply(key.getPrivKey()).normalize().getXCoord().toBigInteg... | EncryptionHandshake { public AuthInitiateMessage createAuthInitiate(@Nullable byte[] token, ECKey key) { AuthInitiateMessage message = new AuthInitiateMessage(); boolean isToken; if (token == null) { isToken = false; BigInteger secretScalar = remotePublicKey.multiply(key.getPrivKey()).normalize().getXCoord().toBigInteg... | EncryptionHandshake { public AuthInitiateMessage createAuthInitiate(@Nullable byte[] token, ECKey key) { AuthInitiateMessage message = new AuthInitiateMessage(); boolean isToken; if (token == null) { isToken = false; BigInteger secretScalar = remotePublicKey.multiply(key.getPrivKey()).normalize().getXCoord().toBigInteg... | EncryptionHandshake { public AuthInitiateMessage createAuthInitiate(@Nullable byte[] token, ECKey key) { AuthInitiateMessage message = new AuthInitiateMessage(); boolean isToken; if (token == null) { isToken = false; BigInteger secretScalar = remotePublicKey.multiply(key.getPrivKey()).normalize().getXCoord().toBigInteg... |
@Test public void getBalanceWithAccountAndBlock() throws Exception { World world = new World(); Account acc1 = new AccountBuilder(world).name("acc1").balance(Coin.valueOf(10000)).build(); Block genesis = world.getBlockByName("g00"); Block block1 = new BlockBuilder(null, null, null).parent(genesis).build(); world.getBlo... | @Override public String eth_getBalance(String address, String block) { AccountInformationProvider accountInformationProvider = web3InformationRetriever.getInformationProvider(block); RskAddress addr = new RskAddress(address); Coin balance = accountInformationProvider.getBalance(addr); return toQuantityJsonHex(balance.a... | Web3Impl implements Web3 { @Override public String eth_getBalance(String address, String block) { AccountInformationProvider accountInformationProvider = web3InformationRetriever.getInformationProvider(block); RskAddress addr = new RskAddress(address); Coin balance = accountInformationProvider.getBalance(addr); return ... | Web3Impl implements Web3 { @Override public String eth_getBalance(String address, String block) { AccountInformationProvider accountInformationProvider = web3InformationRetriever.getInformationProvider(block); RskAddress addr = new RskAddress(address); Coin balance = accountInformationProvider.getBalance(addr); return ... | Web3Impl implements Web3 { @Override public String eth_getBalance(String address, String block) { AccountInformationProvider accountInformationProvider = web3InformationRetriever.getInformationProvider(block); RskAddress addr = new RskAddress(address); Coin balance = accountInformationProvider.getBalance(addr); return ... | Web3Impl implements Web3 { @Override public String eth_getBalance(String address, String block) { AccountInformationProvider accountInformationProvider = web3InformationRetriever.getInformationProvider(block); RskAddress addr = new RskAddress(address); Coin balance = accountInformationProvider.getBalance(addr); return ... |
@Test public void getGasPriceWhenValueIsEmpty() throws Exception { Web3.CallArguments args = new Web3.CallArguments(); args.gasPrice = ""; CallArgumentsToByteArray byteArrayArgs = new CallArgumentsToByteArray(args); Assert.assertArrayEquals(new byte[] {0}, byteArrayArgs.getGasPrice()); } | public byte[] getGasPrice() { byte[] gasPrice = new byte[] {0}; if (args.gasPrice != null && args.gasPrice.length() != 0) { gasPrice = stringHexToByteArray(args.gasPrice); } return gasPrice; } | CallArgumentsToByteArray { public byte[] getGasPrice() { byte[] gasPrice = new byte[] {0}; if (args.gasPrice != null && args.gasPrice.length() != 0) { gasPrice = stringHexToByteArray(args.gasPrice); } return gasPrice; } } | CallArgumentsToByteArray { public byte[] getGasPrice() { byte[] gasPrice = new byte[] {0}; if (args.gasPrice != null && args.gasPrice.length() != 0) { gasPrice = stringHexToByteArray(args.gasPrice); } return gasPrice; } CallArgumentsToByteArray(Web3.CallArguments args); } | CallArgumentsToByteArray { public byte[] getGasPrice() { byte[] gasPrice = new byte[] {0}; if (args.gasPrice != null && args.gasPrice.length() != 0) { gasPrice = stringHexToByteArray(args.gasPrice); } return gasPrice; } CallArgumentsToByteArray(Web3.CallArguments args); byte[] getGasPrice(); byte[] getGasLimit(); byte[... | CallArgumentsToByteArray { public byte[] getGasPrice() { byte[] gasPrice = new byte[] {0}; if (args.gasPrice != null && args.gasPrice.length() != 0) { gasPrice = stringHexToByteArray(args.gasPrice); } return gasPrice; } CallArgumentsToByteArray(Web3.CallArguments args); byte[] getGasPrice(); byte[] getGasLimit(); byte[... |
@Test public void getAddress() { Node node = new Node(NODE_ID_1, GOOGLE, GOOGLE_PORT); Pattern pattern = Pattern.compile(IP_ADDRESS_PATTERN); String address = node.getAddress().getAddress().getHostAddress(); Matcher matcher = pattern.matcher(address); Assert.assertTrue(StringUtils.isNotBlank(address)); Assert.assertTru... | public InetSocketAddress getAddress() { return new InetSocketAddress(this.getHost(), this.getPort()); } | Node implements Serializable { public InetSocketAddress getAddress() { return new InetSocketAddress(this.getHost(), this.getPort()); } } | Node implements Serializable { public InetSocketAddress getAddress() { return new InetSocketAddress(this.getHost(), this.getPort()); } Node(String enodeURL); Node(byte[] id, String host, int port); Node(byte[] rlp); } | Node implements Serializable { public InetSocketAddress getAddress() { return new InetSocketAddress(this.getHost(), this.getPort()); } Node(String enodeURL); Node(byte[] id, String host, int port); Node(byte[] rlp); NodeID getId(); String getHexId(); String getHost(); int getPort(); byte[] getRLP(); InetSocketAddress... | Node implements Serializable { public InetSocketAddress getAddress() { return new InetSocketAddress(this.getHost(), this.getPort()); } Node(String enodeURL); Node(byte[] id, String host, int port); Node(byte[] rlp); NodeID getId(); String getHexId(); String getHost(); int getPort(); byte[] getRLP(); InetSocketAddress... |
@Test public void getNodesPeerDiscoveryDisable() { List<Node> activePeers = new ArrayList<>(); activePeers.add(new Node(Hex.decode(NODE_ID_2), "127.0.0.2", 8081)); List<Node> bootNodes = new ArrayList<>(); bootNodes.add(new Node(Hex.decode(NODE_ID_3), "127.0.0.3", 8083)); Mockito.when(config.peerActive()).thenReturn(ac... | public synchronized List<NodeHandler> getNodes(Set<String> nodesInUse) { List<NodeHandler> handlers = new ArrayList<>(); List<Node> foundNodes = this.peerExplorer.getNodes(); if (this.discoveryEnabled && !foundNodes.isEmpty()) { logger.debug("{} Nodes retrieved from the PE.", foundNodes.size()); foundNodes.stream().fil... | NodeManager { public synchronized List<NodeHandler> getNodes(Set<String> nodesInUse) { List<NodeHandler> handlers = new ArrayList<>(); List<Node> foundNodes = this.peerExplorer.getNodes(); if (this.discoveryEnabled && !foundNodes.isEmpty()) { logger.debug("{} Nodes retrieved from the PE.", foundNodes.size()); foundNode... | NodeManager { public synchronized List<NodeHandler> getNodes(Set<String> nodesInUse) { List<NodeHandler> handlers = new ArrayList<>(); List<Node> foundNodes = this.peerExplorer.getNodes(); if (this.discoveryEnabled && !foundNodes.isEmpty()) { logger.debug("{} Nodes retrieved from the PE.", foundNodes.size()); foundNode... | NodeManager { public synchronized List<NodeHandler> getNodes(Set<String> nodesInUse) { List<NodeHandler> handlers = new ArrayList<>(); List<Node> foundNodes = this.peerExplorer.getNodes(); if (this.discoveryEnabled && !foundNodes.isEmpty()) { logger.debug("{} Nodes retrieved from the PE.", foundNodes.size()); foundNode... | NodeManager { public synchronized List<NodeHandler> getNodes(Set<String> nodesInUse) { List<NodeHandler> handlers = new ArrayList<>(); List<Node> foundNodes = this.peerExplorer.getNodes(); if (this.discoveryEnabled && !foundNodes.isEmpty()) { logger.debug("{} Nodes retrieved from the PE.", foundNodes.size()); foundNode... |
@Test public void getNodesPeerDiscoveryEnableNoPeersFound() { List<Node> activePeers = new ArrayList<>(); List<Node> bootNodes = new ArrayList<>(); Mockito.when(config.peerActive()).thenReturn(activePeers); Mockito.when(peerExplorer.getNodes()).thenReturn(bootNodes); Mockito.when(config.isPeerDiscoveryEnabled()).thenRe... | public synchronized List<NodeHandler> getNodes(Set<String> nodesInUse) { List<NodeHandler> handlers = new ArrayList<>(); List<Node> foundNodes = this.peerExplorer.getNodes(); if (this.discoveryEnabled && !foundNodes.isEmpty()) { logger.debug("{} Nodes retrieved from the PE.", foundNodes.size()); foundNodes.stream().fil... | NodeManager { public synchronized List<NodeHandler> getNodes(Set<String> nodesInUse) { List<NodeHandler> handlers = new ArrayList<>(); List<Node> foundNodes = this.peerExplorer.getNodes(); if (this.discoveryEnabled && !foundNodes.isEmpty()) { logger.debug("{} Nodes retrieved from the PE.", foundNodes.size()); foundNode... | NodeManager { public synchronized List<NodeHandler> getNodes(Set<String> nodesInUse) { List<NodeHandler> handlers = new ArrayList<>(); List<Node> foundNodes = this.peerExplorer.getNodes(); if (this.discoveryEnabled && !foundNodes.isEmpty()) { logger.debug("{} Nodes retrieved from the PE.", foundNodes.size()); foundNode... | NodeManager { public synchronized List<NodeHandler> getNodes(Set<String> nodesInUse) { List<NodeHandler> handlers = new ArrayList<>(); List<Node> foundNodes = this.peerExplorer.getNodes(); if (this.discoveryEnabled && !foundNodes.isEmpty()) { logger.debug("{} Nodes retrieved from the PE.", foundNodes.size()); foundNode... | NodeManager { public synchronized List<NodeHandler> getNodes(Set<String> nodesInUse) { List<NodeHandler> handlers = new ArrayList<>(); List<Node> foundNodes = this.peerExplorer.getNodes(); if (this.discoveryEnabled && !foundNodes.isEmpty()) { logger.debug("{} Nodes retrieved from the PE.", foundNodes.size()); foundNode... |
@Test public void getNodesPeerDiscoveryEnable() { List<Node> activePeers = new ArrayList<>(); activePeers.add(new Node(Hex.decode(NODE_ID_2), "127.0.0.2", 8081)); List<Node> bootNodes = new ArrayList<>(); bootNodes.add(new Node(Hex.decode(NODE_ID_3), "127.0.0.3", 8083)); Mockito.when(config.peerActive()).thenReturn(act... | public synchronized List<NodeHandler> getNodes(Set<String> nodesInUse) { List<NodeHandler> handlers = new ArrayList<>(); List<Node> foundNodes = this.peerExplorer.getNodes(); if (this.discoveryEnabled && !foundNodes.isEmpty()) { logger.debug("{} Nodes retrieved from the PE.", foundNodes.size()); foundNodes.stream().fil... | NodeManager { public synchronized List<NodeHandler> getNodes(Set<String> nodesInUse) { List<NodeHandler> handlers = new ArrayList<>(); List<Node> foundNodes = this.peerExplorer.getNodes(); if (this.discoveryEnabled && !foundNodes.isEmpty()) { logger.debug("{} Nodes retrieved from the PE.", foundNodes.size()); foundNode... | NodeManager { public synchronized List<NodeHandler> getNodes(Set<String> nodesInUse) { List<NodeHandler> handlers = new ArrayList<>(); List<Node> foundNodes = this.peerExplorer.getNodes(); if (this.discoveryEnabled && !foundNodes.isEmpty()) { logger.debug("{} Nodes retrieved from the PE.", foundNodes.size()); foundNode... | NodeManager { public synchronized List<NodeHandler> getNodes(Set<String> nodesInUse) { List<NodeHandler> handlers = new ArrayList<>(); List<Node> foundNodes = this.peerExplorer.getNodes(); if (this.discoveryEnabled && !foundNodes.isEmpty()) { logger.debug("{} Nodes retrieved from the PE.", foundNodes.size()); foundNode... | NodeManager { public synchronized List<NodeHandler> getNodes(Set<String> nodesInUse) { List<NodeHandler> handlers = new ArrayList<>(); List<Node> foundNodes = this.peerExplorer.getNodes(); if (this.discoveryEnabled && !foundNodes.isEmpty()) { logger.debug("{} Nodes retrieved from the PE.", foundNodes.size()); foundNode... |
@Test public void purgeNodesTest() { Random random = new Random(); Mockito.when(config.isPeerDiscoveryEnabled()).thenReturn(true); NodeManager nodeManager = new NodeManager(peerExplorer, config); Set<String> keys = new HashSet<>(); for (int i = 0; i <= NodeManager.NODES_TRIM_THRESHOLD+1;i++) { byte[] nodeId = new byte[... | public NodeStatistics getNodeStatistics(Node n) { return discoveryEnabled ? getNodeHandler(n).getNodeStatistics() : DUMMY_STAT; } | NodeManager { public NodeStatistics getNodeStatistics(Node n) { return discoveryEnabled ? getNodeHandler(n).getNodeStatistics() : DUMMY_STAT; } } | NodeManager { public NodeStatistics getNodeStatistics(Node n) { return discoveryEnabled ? getNodeHandler(n).getNodeStatistics() : DUMMY_STAT; } NodeManager(PeerExplorer peerExplorer, SystemProperties config); } | NodeManager { public NodeStatistics getNodeStatistics(Node n) { return discoveryEnabled ? getNodeHandler(n).getNodeStatistics() : DUMMY_STAT; } NodeManager(PeerExplorer peerExplorer, SystemProperties config); NodeStatistics getNodeStatistics(Node n); synchronized List<NodeHandler> getNodes(Set<String> nodesInUse); } | NodeManager { public NodeStatistics getNodeStatistics(Node n) { return discoveryEnabled ? getNodeHandler(n).getNodeStatistics() : DUMMY_STAT; } NodeManager(PeerExplorer peerExplorer, SystemProperties config); NodeStatistics getNodeStatistics(Node n); synchronized List<NodeHandler> getNodes(Set<String> nodesInUse); } |
@Test public void equals_true() { InetSocketAddress inetSocketAddress = mock(InetSocketAddress.class); Channel otherChannel = new Channel( messageQueue, messageCodec, nodeManager, rskWireProtocolFactory, eth62MessageFactory, staticMessages, remoteId); target.setInetSocketAddress(inetSocketAddress); otherChannel.setInet... | public void setInetSocketAddress(InetSocketAddress inetSocketAddress) { this.inetSocketAddress = inetSocketAddress; } | Channel implements Peer { public void setInetSocketAddress(InetSocketAddress inetSocketAddress) { this.inetSocketAddress = inetSocketAddress; } } | Channel implements Peer { public void setInetSocketAddress(InetSocketAddress inetSocketAddress) { this.inetSocketAddress = inetSocketAddress; } Channel(MessageQueue msgQueue,
MessageCodec messageCodec,
NodeManager nodeManager,
RskWireProtocol.Factory rskWireProto... | Channel implements Peer { public void setInetSocketAddress(InetSocketAddress inetSocketAddress) { this.inetSocketAddress = inetSocketAddress; } Channel(MessageQueue msgQueue,
MessageCodec messageCodec,
NodeManager nodeManager,
RskWireProtocol.Factory rskWireProto... | Channel implements Peer { public void setInetSocketAddress(InetSocketAddress inetSocketAddress) { this.inetSocketAddress = inetSocketAddress; } Channel(MessageQueue msgQueue,
MessageCodec messageCodec,
NodeManager nodeManager,
RskWireProtocol.Factory rskWireProto... |
@Test public void equals_false() { InetSocketAddress inetSocketAddress = mock(InetSocketAddress.class); Channel otherChannel = new Channel( messageQueue, messageCodec, nodeManager, rskWireProtocolFactory, eth62MessageFactory, staticMessages, remoteId); target.setInetSocketAddress(inetSocketAddress); assertNotEquals(tar... | public void setInetSocketAddress(InetSocketAddress inetSocketAddress) { this.inetSocketAddress = inetSocketAddress; } | Channel implements Peer { public void setInetSocketAddress(InetSocketAddress inetSocketAddress) { this.inetSocketAddress = inetSocketAddress; } } | Channel implements Peer { public void setInetSocketAddress(InetSocketAddress inetSocketAddress) { this.inetSocketAddress = inetSocketAddress; } Channel(MessageQueue msgQueue,
MessageCodec messageCodec,
NodeManager nodeManager,
RskWireProtocol.Factory rskWireProto... | Channel implements Peer { public void setInetSocketAddress(InetSocketAddress inetSocketAddress) { this.inetSocketAddress = inetSocketAddress; } Channel(MessageQueue msgQueue,
MessageCodec messageCodec,
NodeManager nodeManager,
RskWireProtocol.Factory rskWireProto... | Channel implements Peer { public void setInetSocketAddress(InetSocketAddress inetSocketAddress) { this.inetSocketAddress = inetSocketAddress; } Channel(MessageQueue msgQueue,
MessageCodec messageCodec,
NodeManager nodeManager,
RskWireProtocol.Factory rskWireProto... |
@Test public void getNumberOfPeersToSendStatusTo() { ChannelManagerImpl channelManagerImpl = new ChannelManagerImpl(new TestSystemProperties(), null);; assertEquals(1, channelManagerImpl.getNumberOfPeersToSendStatusTo(1)); assertEquals(2, channelManagerImpl.getNumberOfPeersToSendStatusTo(2)); assertEquals(3, channelMan... | @VisibleForTesting int getNumberOfPeersToSendStatusTo(int peerCount) { int peerCountSqrt = (int) Math.sqrt(peerCount); return Math.min(10, Math.min(Math.max(3, peerCountSqrt), peerCount)); } | ChannelManagerImpl implements ChannelManager { @VisibleForTesting int getNumberOfPeersToSendStatusTo(int peerCount) { int peerCountSqrt = (int) Math.sqrt(peerCount); return Math.min(10, Math.min(Math.max(3, peerCountSqrt), peerCount)); } } | ChannelManagerImpl implements ChannelManager { @VisibleForTesting int getNumberOfPeersToSendStatusTo(int peerCount) { int peerCountSqrt = (int) Math.sqrt(peerCount); return Math.min(10, Math.min(Math.max(3, peerCountSqrt), peerCount)); } ChannelManagerImpl(RskSystemProperties config, SyncPool syncPool); } | ChannelManagerImpl implements ChannelManager { @VisibleForTesting int getNumberOfPeersToSendStatusTo(int peerCount) { int peerCountSqrt = (int) Math.sqrt(peerCount); return Math.min(10, Math.min(Math.max(3, peerCountSqrt), peerCount)); } ChannelManagerImpl(RskSystemProperties config, SyncPool syncPool); @Override void ... | ChannelManagerImpl implements ChannelManager { @VisibleForTesting int getNumberOfPeersToSendStatusTo(int peerCount) { int peerCountSqrt = (int) Math.sqrt(peerCount); return Math.min(10, Math.min(Math.max(3, peerCountSqrt), peerCount)); } ChannelManagerImpl(RskSystemProperties config, SyncPool syncPool); @Override void ... |
@Test public void blockAddressIsAvailable() throws UnknownHostException { ChannelManagerImpl channelManagerImpl = new ChannelManagerImpl(new TestSystemProperties(), null);; Assert.assertTrue(channelManagerImpl.isAddressBlockAvailable(InetAddress.getLocalHost())); } | public boolean isAddressBlockAvailable(InetAddress inetAddress) { synchronized (activePeersLock) { return activePeers.values().stream() .map(ch -> new InetAddressBlock(ch.getInetSocketAddress().getAddress(), networkCIDR)) .filter(block -> block.contains(inetAddress)) .count() < maxConnectionsAllowed; } } | ChannelManagerImpl implements ChannelManager { public boolean isAddressBlockAvailable(InetAddress inetAddress) { synchronized (activePeersLock) { return activePeers.values().stream() .map(ch -> new InetAddressBlock(ch.getInetSocketAddress().getAddress(), networkCIDR)) .filter(block -> block.contains(inetAddress)) .coun... | ChannelManagerImpl implements ChannelManager { public boolean isAddressBlockAvailable(InetAddress inetAddress) { synchronized (activePeersLock) { return activePeers.values().stream() .map(ch -> new InetAddressBlock(ch.getInetSocketAddress().getAddress(), networkCIDR)) .filter(block -> block.contains(inetAddress)) .coun... | ChannelManagerImpl implements ChannelManager { public boolean isAddressBlockAvailable(InetAddress inetAddress) { synchronized (activePeersLock) { return activePeers.values().stream() .map(ch -> new InetAddressBlock(ch.getInetSocketAddress().getAddress(), networkCIDR)) .filter(block -> block.contains(inetAddress)) .coun... | ChannelManagerImpl implements ChannelManager { public boolean isAddressBlockAvailable(InetAddress inetAddress) { synchronized (activePeersLock) { return activePeers.values().stream() .map(ch -> new InetAddressBlock(ch.getInetSocketAddress().getAddress(), networkCIDR)) .filter(block -> block.contains(inetAddress)) .coun... |
@Test public void broadcastBlock() { ChannelManager target = new ChannelManagerImpl(mock(RskSystemProperties.class), mock(SyncPool.class)); Block block = mock(Block.class); when(block.getHash()).thenReturn(new Keccak256(new byte[32])); Set<NodeID> nodeIds = target.broadcastBlock(block); assertTrue(nodeIds.isEmpty()); } | @Nonnull public Set<NodeID> broadcastBlock(@Nonnull final Block block) { final Set<NodeID> nodesIdsBroadcastedTo = new HashSet<>(); final BlockIdentifier bi = new BlockIdentifier(block.getHash().getBytes(), block.getNumber()); final Message newBlock = new BlockMessage(block); final Message newBlockHashes = new NewBlock... | ChannelManagerImpl implements ChannelManager { @Nonnull public Set<NodeID> broadcastBlock(@Nonnull final Block block) { final Set<NodeID> nodesIdsBroadcastedTo = new HashSet<>(); final BlockIdentifier bi = new BlockIdentifier(block.getHash().getBytes(), block.getNumber()); final Message newBlock = new BlockMessage(bloc... | ChannelManagerImpl implements ChannelManager { @Nonnull public Set<NodeID> broadcastBlock(@Nonnull final Block block) { final Set<NodeID> nodesIdsBroadcastedTo = new HashSet<>(); final BlockIdentifier bi = new BlockIdentifier(block.getHash().getBytes(), block.getNumber()); final Message newBlock = new BlockMessage(bloc... | ChannelManagerImpl implements ChannelManager { @Nonnull public Set<NodeID> broadcastBlock(@Nonnull final Block block) { final Set<NodeID> nodesIdsBroadcastedTo = new HashSet<>(); final BlockIdentifier bi = new BlockIdentifier(block.getHash().getBytes(), block.getNumber()); final Message newBlock = new BlockMessage(bloc... | ChannelManagerImpl implements ChannelManager { @Nonnull public Set<NodeID> broadcastBlock(@Nonnull final Block block) { final Set<NodeID> nodesIdsBroadcastedTo = new HashSet<>(); final BlockIdentifier bi = new BlockIdentifier(block.getHash().getBytes(), block.getNumber()); final Message newBlock = new BlockMessage(bloc... |
@Test public void getBalanceWithAccountAndBlockWithTransaction() throws Exception { World world = new World(); BlockChainImpl blockChain = world.getBlockChain(); TransactionPool transactionPool = world.getTransactionPool(); Account acc1 = new AccountBuilder(world).name("acc1").balance(Coin.valueOf(10000000)).build(); A... | @Override public String eth_getBalance(String address, String block) { AccountInformationProvider accountInformationProvider = web3InformationRetriever.getInformationProvider(block); RskAddress addr = new RskAddress(address); Coin balance = accountInformationProvider.getBalance(addr); return toQuantityJsonHex(balance.a... | Web3Impl implements Web3 { @Override public String eth_getBalance(String address, String block) { AccountInformationProvider accountInformationProvider = web3InformationRetriever.getInformationProvider(block); RskAddress addr = new RskAddress(address); Coin balance = accountInformationProvider.getBalance(addr); return ... | Web3Impl implements Web3 { @Override public String eth_getBalance(String address, String block) { AccountInformationProvider accountInformationProvider = web3InformationRetriever.getInformationProvider(block); RskAddress addr = new RskAddress(address); Coin balance = accountInformationProvider.getBalance(addr); return ... | Web3Impl implements Web3 { @Override public String eth_getBalance(String address, String block) { AccountInformationProvider accountInformationProvider = web3InformationRetriever.getInformationProvider(block); RskAddress addr = new RskAddress(address); Coin balance = accountInformationProvider.getBalance(addr); return ... | Web3Impl implements Web3 { @Override public String eth_getBalance(String address, String block) { AccountInformationProvider accountInformationProvider = web3InformationRetriever.getInformationProvider(block); RskAddress addr = new RskAddress(address); Coin balance = accountInformationProvider.getBalance(addr); return ... |
@Test public void put() { byte[] randomKey = TestUtils.randomBytes(20); byte[] randomValue = TestUtils.randomBytes(20); dataSourceWithCache.put(randomKey, randomValue); assertThat(baseDataSource.get(randomKey), is(nullValue())); dataSourceWithCache.flush(); assertThat(baseDataSource.get(randomKey), is(randomValue)); } | @Override public byte[] put(byte[] key, byte[] value) { ByteArrayWrapper wrappedKey = ByteUtil.wrap(key); return put(wrappedKey, value); } | DataSourceWithCache implements KeyValueDataSource { @Override public byte[] put(byte[] key, byte[] value) { ByteArrayWrapper wrappedKey = ByteUtil.wrap(key); return put(wrappedKey, value); } } | DataSourceWithCache implements KeyValueDataSource { @Override public byte[] put(byte[] key, byte[] value) { ByteArrayWrapper wrappedKey = ByteUtil.wrap(key); return put(wrappedKey, value); } DataSourceWithCache(KeyValueDataSource base, int cacheSize); } | DataSourceWithCache implements KeyValueDataSource { @Override public byte[] put(byte[] key, byte[] value) { ByteArrayWrapper wrappedKey = ByteUtil.wrap(key); return put(wrappedKey, value); } DataSourceWithCache(KeyValueDataSource base, int cacheSize); @Override byte[] get(byte[] key); @Override byte[] put(byte[] key, b... | DataSourceWithCache implements KeyValueDataSource { @Override public byte[] put(byte[] key, byte[] value) { ByteArrayWrapper wrappedKey = ByteUtil.wrap(key); return put(wrappedKey, value); } DataSourceWithCache(KeyValueDataSource base, int cacheSize); @Override byte[] get(byte[] key); @Override byte[] put(byte[] key, b... |
@Test public void keys() { Map<ByteArrayWrapper, byte[]> initialEntries = generateRandomValuesToUpdate(CACHE_SIZE); Set<byte[]> initialKeys = initialEntries.keySet().stream().map(ByteArrayWrapper::getData).collect(Collectors.toSet()); baseDataSource.updateBatch(initialEntries, Collections.emptySet()); assertThat(dataSo... | @Override public Set<byte[]> keys() { Stream<ByteArrayWrapper> baseKeys; Stream<ByteArrayWrapper> committedKeys; Stream<ByteArrayWrapper> uncommittedKeys; Set<ByteArrayWrapper> uncommittedKeysToRemove; this.lock.readLock().lock(); try { baseKeys = base.keys().stream().map(ByteArrayWrapper::new); committedKeys = committ... | DataSourceWithCache implements KeyValueDataSource { @Override public Set<byte[]> keys() { Stream<ByteArrayWrapper> baseKeys; Stream<ByteArrayWrapper> committedKeys; Stream<ByteArrayWrapper> uncommittedKeys; Set<ByteArrayWrapper> uncommittedKeysToRemove; this.lock.readLock().lock(); try { baseKeys = base.keys().stream()... | DataSourceWithCache implements KeyValueDataSource { @Override public Set<byte[]> keys() { Stream<ByteArrayWrapper> baseKeys; Stream<ByteArrayWrapper> committedKeys; Stream<ByteArrayWrapper> uncommittedKeys; Set<ByteArrayWrapper> uncommittedKeysToRemove; this.lock.readLock().lock(); try { baseKeys = base.keys().stream()... | DataSourceWithCache implements KeyValueDataSource { @Override public Set<byte[]> keys() { Stream<ByteArrayWrapper> baseKeys; Stream<ByteArrayWrapper> committedKeys; Stream<ByteArrayWrapper> uncommittedKeys; Set<ByteArrayWrapper> uncommittedKeysToRemove; this.lock.readLock().lock(); try { baseKeys = base.keys().stream()... | DataSourceWithCache implements KeyValueDataSource { @Override public Set<byte[]> keys() { Stream<ByteArrayWrapper> baseKeys; Stream<ByteArrayWrapper> committedKeys; Stream<ByteArrayWrapper> uncommittedKeys; Set<ByteArrayWrapper> uncommittedKeysToRemove; this.lock.readLock().lock(); try { baseKeys = base.keys().stream()... |
@Test public void delete() { byte[] randomKey = TestUtils.randomBytes(20); baseDataSource.put(randomKey, TestUtils.randomBytes(20)); dataSourceWithCache.delete(randomKey); dataSourceWithCache.flush(); assertThat(baseDataSource.get(randomKey), is(nullValue())); } | @Override public void delete(byte[] key) { delete(ByteUtil.wrap(key)); } | DataSourceWithCache implements KeyValueDataSource { @Override public void delete(byte[] key) { delete(ByteUtil.wrap(key)); } } | DataSourceWithCache implements KeyValueDataSource { @Override public void delete(byte[] key) { delete(ByteUtil.wrap(key)); } DataSourceWithCache(KeyValueDataSource base, int cacheSize); } | DataSourceWithCache implements KeyValueDataSource { @Override public void delete(byte[] key) { delete(ByteUtil.wrap(key)); } DataSourceWithCache(KeyValueDataSource base, int cacheSize); @Override byte[] get(byte[] key); @Override byte[] put(byte[] key, byte[] value); @Override void delete(byte[] key); @Override Set<byt... | DataSourceWithCache implements KeyValueDataSource { @Override public void delete(byte[] key) { delete(ByteUtil.wrap(key)); } DataSourceWithCache(KeyValueDataSource base, int cacheSize); @Override byte[] get(byte[] key); @Override byte[] put(byte[] key, byte[] value); @Override void delete(byte[] key); @Override Set<byt... |
@Test public void updateBatch() { Map<ByteArrayWrapper, byte[]> initialEntries = generateRandomValuesToUpdate(CACHE_SIZE); baseDataSource.updateBatch(initialEntries, Collections.emptySet()); Set<ByteArrayWrapper> keysToBatchRemove = initialEntries.keySet().stream().limit(CACHE_SIZE / 2).collect(Collectors.toSet()); dat... | @Override public void updateBatch(Map<ByteArrayWrapper, byte[]> rows, Set<ByteArrayWrapper> keysToRemove) { if (rows.containsKey(null) || rows.containsValue(null)) { throw new IllegalArgumentException("Cannot update null values"); } rows.keySet().removeAll(keysToRemove); this.lock.writeLock().lock(); try { rows.forEach... | DataSourceWithCache implements KeyValueDataSource { @Override public void updateBatch(Map<ByteArrayWrapper, byte[]> rows, Set<ByteArrayWrapper> keysToRemove) { if (rows.containsKey(null) || rows.containsValue(null)) { throw new IllegalArgumentException("Cannot update null values"); } rows.keySet().removeAll(keysToRemov... | DataSourceWithCache implements KeyValueDataSource { @Override public void updateBatch(Map<ByteArrayWrapper, byte[]> rows, Set<ByteArrayWrapper> keysToRemove) { if (rows.containsKey(null) || rows.containsValue(null)) { throw new IllegalArgumentException("Cannot update null values"); } rows.keySet().removeAll(keysToRemov... | DataSourceWithCache implements KeyValueDataSource { @Override public void updateBatch(Map<ByteArrayWrapper, byte[]> rows, Set<ByteArrayWrapper> keysToRemove) { if (rows.containsKey(null) || rows.containsValue(null)) { throw new IllegalArgumentException("Cannot update null values"); } rows.keySet().removeAll(keysToRemov... | DataSourceWithCache implements KeyValueDataSource { @Override public void updateBatch(Map<ByteArrayWrapper, byte[]> rows, Set<ByteArrayWrapper> keysToRemove) { if (rows.containsKey(null) || rows.containsValue(null)) { throw new IllegalArgumentException("Cannot update null values"); } rows.keySet().removeAll(keysToRemov... |
@Test public void test_2() { assertTrue(TypeConverter.toJsonHex(EMPTY_BYTE_ARRAY).equals("0x00")); byte[] rlpSuccess = Hex.decode("f9010c808255aeb901000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000... | public byte[] getStatus() { return this.status; } | TransactionReceipt { public byte[] getStatus() { return this.status; } } | TransactionReceipt { public byte[] getStatus() { return this.status; } TransactionReceipt(); TransactionReceipt(byte[] rlp); TransactionReceipt(byte[] postTxState, byte[] cumulativeGas, byte[] gasUsed,
Bloom bloomFilter, List<LogInfo> logInfoList, byte[] status); } | TransactionReceipt { public byte[] getStatus() { return this.status; } TransactionReceipt(); TransactionReceipt(byte[] rlp); TransactionReceipt(byte[] postTxState, byte[] cumulativeGas, byte[] gasUsed,
Bloom bloomFilter, List<LogInfo> logInfoList, byte[] status); byte[] getPostTxState();... | TransactionReceipt { public byte[] getStatus() { return this.status; } TransactionReceipt(); TransactionReceipt(byte[] rlp); TransactionReceipt(byte[] postTxState, byte[] cumulativeGas, byte[] gasUsed,
Bloom bloomFilter, List<LogInfo> logInfoList, byte[] status); byte[] getPostTxState();... |
@Test public void testInitHandlesFreeTransactionsOK() { BlockTxSignatureCache blockTxSignatureCache = mock(BlockTxSignatureCache.class); Transaction transaction = mock(Transaction.class); TransactionExecutor txExecutor = new TransactionExecutor( constants, activationConfig, transaction, txIndex, rskAddress, repository,... | public boolean executeTransaction() { if (!this.init()) { return false; } this.execute(); this.go(); this.finalization(); return true; } | TransactionExecutor { public boolean executeTransaction() { if (!this.init()) { return false; } this.execute(); this.go(); this.finalization(); return true; } } | TransactionExecutor { public boolean executeTransaction() { if (!this.init()) { return false; } this.execute(); this.go(); this.finalization(); return true; } TransactionExecutor(
Constants constants, ActivationConfig activationConfig, Transaction tx, int txindex, RskAddress coinbase,
Repository... | TransactionExecutor { public boolean executeTransaction() { if (!this.init()) { return false; } this.execute(); this.go(); this.finalization(); return true; } TransactionExecutor(
Constants constants, ActivationConfig activationConfig, Transaction tx, int txindex, RskAddress coinbase,
Repository... | TransactionExecutor { public boolean executeTransaction() { if (!this.init()) { return false; } this.execute(); this.go(); this.finalization(); return true; } TransactionExecutor(
Constants constants, ActivationConfig activationConfig, Transaction tx, int txindex, RskAddress coinbase,
Repository... |
@Test public void InvalidTxsIsInBlockAndShouldntBeInCache(){ ReceivedTxSignatureCache receivedTxSignatureCache = mock(ReceivedTxSignatureCache.class); BlockTxSignatureCache blockTxSignatureCache = new BlockTxSignatureCache(receivedTxSignatureCache); MutableRepository cacheTrack = mock(MutableRepository.class); when(rep... | public boolean executeTransaction() { if (!this.init()) { return false; } this.execute(); this.go(); this.finalization(); return true; } | TransactionExecutor { public boolean executeTransaction() { if (!this.init()) { return false; } this.execute(); this.go(); this.finalization(); return true; } } | TransactionExecutor { public boolean executeTransaction() { if (!this.init()) { return false; } this.execute(); this.go(); this.finalization(); return true; } TransactionExecutor(
Constants constants, ActivationConfig activationConfig, Transaction tx, int txindex, RskAddress coinbase,
Repository... | TransactionExecutor { public boolean executeTransaction() { if (!this.init()) { return false; } this.execute(); this.go(); this.finalization(); return true; } TransactionExecutor(
Constants constants, ActivationConfig activationConfig, Transaction tx, int txindex, RskAddress coinbase,
Repository... | TransactionExecutor { public boolean executeTransaction() { if (!this.init()) { return false; } this.execute(); this.go(); this.finalization(); return true; } TransactionExecutor(
Constants constants, ActivationConfig activationConfig, Transaction tx, int txindex, RskAddress coinbase,
Repository... |
@Test public void remascTxIsReceivedAndShouldntBeInCache(){ ReceivedTxSignatureCache receivedTxSignatureCache = mock(ReceivedTxSignatureCache.class); BlockTxSignatureCache blockTxSignatureCache = new BlockTxSignatureCache(receivedTxSignatureCache); MutableRepository cacheTrack = mock(MutableRepository.class); when(repo... | public boolean executeTransaction() { if (!this.init()) { return false; } this.execute(); this.go(); this.finalization(); return true; } | TransactionExecutor { public boolean executeTransaction() { if (!this.init()) { return false; } this.execute(); this.go(); this.finalization(); return true; } } | TransactionExecutor { public boolean executeTransaction() { if (!this.init()) { return false; } this.execute(); this.go(); this.finalization(); return true; } TransactionExecutor(
Constants constants, ActivationConfig activationConfig, Transaction tx, int txindex, RskAddress coinbase,
Repository... | TransactionExecutor { public boolean executeTransaction() { if (!this.init()) { return false; } this.execute(); this.go(); this.finalization(); return true; } TransactionExecutor(
Constants constants, ActivationConfig activationConfig, Transaction tx, int txindex, RskAddress coinbase,
Repository... | TransactionExecutor { public boolean executeTransaction() { if (!this.init()) { return false; } this.execute(); this.go(); this.finalization(); return true; } TransactionExecutor(
Constants constants, ActivationConfig activationConfig, Transaction tx, int txindex, RskAddress coinbase,
Repository... |
@Test public void createsHeaderWithEmptyStateRoot() { BlockHeader header = blockHeaderBuilder.build(); assertArrayEquals(HashUtil.EMPTY_TRIE_HASH, header.getStateRoot()); } | public BlockHeader build() { initializeWithDefaultValues(); if (createConsensusCompliantHeader) { useRskip92Encoding = activationConfig.isActive(ConsensusRule.RSKIP92, number); includeForkDetectionData = activationConfig.isActive(ConsensusRule.RSKIP110, number) && mergedMiningForkDetectionData.length > 0; } if (createU... | BlockHeaderBuilder { public BlockHeader build() { initializeWithDefaultValues(); if (createConsensusCompliantHeader) { useRskip92Encoding = activationConfig.isActive(ConsensusRule.RSKIP92, number); includeForkDetectionData = activationConfig.isActive(ConsensusRule.RSKIP110, number) && mergedMiningForkDetectionData.leng... | BlockHeaderBuilder { public BlockHeader build() { initializeWithDefaultValues(); if (createConsensusCompliantHeader) { useRskip92Encoding = activationConfig.isActive(ConsensusRule.RSKIP92, number); includeForkDetectionData = activationConfig.isActive(ConsensusRule.RSKIP110, number) && mergedMiningForkDetectionData.leng... | BlockHeaderBuilder { public BlockHeader build() { initializeWithDefaultValues(); if (createConsensusCompliantHeader) { useRskip92Encoding = activationConfig.isActive(ConsensusRule.RSKIP92, number); includeForkDetectionData = activationConfig.isActive(ConsensusRule.RSKIP110, number) && mergedMiningForkDetectionData.leng... | BlockHeaderBuilder { public BlockHeader build() { initializeWithDefaultValues(); if (createConsensusCompliantHeader) { useRskip92Encoding = activationConfig.isActive(ConsensusRule.RSKIP92, number); includeForkDetectionData = activationConfig.isActive(ConsensusRule.RSKIP110, number) && mergedMiningForkDetectionData.leng... |
@Test public void createsHeaderWithEmptyTxTrieRoot() { BlockHeader header = blockHeaderBuilder.build(); assertArrayEquals(HashUtil.EMPTY_TRIE_HASH, header.getTxTrieRoot()); } | public BlockHeader build() { initializeWithDefaultValues(); if (createConsensusCompliantHeader) { useRskip92Encoding = activationConfig.isActive(ConsensusRule.RSKIP92, number); includeForkDetectionData = activationConfig.isActive(ConsensusRule.RSKIP110, number) && mergedMiningForkDetectionData.length > 0; } if (createU... | BlockHeaderBuilder { public BlockHeader build() { initializeWithDefaultValues(); if (createConsensusCompliantHeader) { useRskip92Encoding = activationConfig.isActive(ConsensusRule.RSKIP92, number); includeForkDetectionData = activationConfig.isActive(ConsensusRule.RSKIP110, number) && mergedMiningForkDetectionData.leng... | BlockHeaderBuilder { public BlockHeader build() { initializeWithDefaultValues(); if (createConsensusCompliantHeader) { useRskip92Encoding = activationConfig.isActive(ConsensusRule.RSKIP92, number); includeForkDetectionData = activationConfig.isActive(ConsensusRule.RSKIP110, number) && mergedMiningForkDetectionData.leng... | BlockHeaderBuilder { public BlockHeader build() { initializeWithDefaultValues(); if (createConsensusCompliantHeader) { useRskip92Encoding = activationConfig.isActive(ConsensusRule.RSKIP92, number); includeForkDetectionData = activationConfig.isActive(ConsensusRule.RSKIP110, number) && mergedMiningForkDetectionData.leng... | BlockHeaderBuilder { public BlockHeader build() { initializeWithDefaultValues(); if (createConsensusCompliantHeader) { useRskip92Encoding = activationConfig.isActive(ConsensusRule.RSKIP92, number); includeForkDetectionData = activationConfig.isActive(ConsensusRule.RSKIP110, number) && mergedMiningForkDetectionData.leng... |
@Test public void eth_mining() { Ethereum ethMock = Web3Mocks.getMockEthereum(); Blockchain blockchain = Web3Mocks.getMockBlockchain(); BlockStore blockStore = Web3Mocks.getMockBlockStore(); RskSystemProperties mockProperties = Web3Mocks.getMockProperties(); MinerClient minerClient = new SimpleMinerClient(); PersonalMo... | @Override public boolean eth_mining() { Boolean s = null; try { return s = minerClient.isMining(); } finally { if (logger.isDebugEnabled()) { logger.debug("eth_mining(): {}", s); } } } | Web3Impl implements Web3 { @Override public boolean eth_mining() { Boolean s = null; try { return s = minerClient.isMining(); } finally { if (logger.isDebugEnabled()) { logger.debug("eth_mining(): {}", s); } } } } | Web3Impl implements Web3 { @Override public boolean eth_mining() { Boolean s = null; try { return s = minerClient.isMining(); } finally { if (logger.isDebugEnabled()) { logger.debug("eth_mining(): {}", s); } } } protected Web3Impl(
Ethereum eth,
Blockchain blockchain,
BlockStore blo... | Web3Impl implements Web3 { @Override public boolean eth_mining() { Boolean s = null; try { return s = minerClient.isMining(); } finally { if (logger.isDebugEnabled()) { logger.debug("eth_mining(): {}", s); } } } protected Web3Impl(
Ethereum eth,
Blockchain blockchain,
BlockStore blo... | Web3Impl implements Web3 { @Override public boolean eth_mining() { Boolean s = null; try { return s = minerClient.isMining(); } finally { if (logger.isDebugEnabled()) { logger.debug("eth_mining(): {}", s); } } } protected Web3Impl(
Ethereum eth,
Blockchain blockchain,
BlockStore blo... |
@Test public void createsHeaderWithEmptyReceiptTrieRoot() { BlockHeader header = blockHeaderBuilder.build(); assertArrayEquals(HashUtil.EMPTY_TRIE_HASH, header.getReceiptsRoot()); } | public BlockHeader build() { initializeWithDefaultValues(); if (createConsensusCompliantHeader) { useRskip92Encoding = activationConfig.isActive(ConsensusRule.RSKIP92, number); includeForkDetectionData = activationConfig.isActive(ConsensusRule.RSKIP110, number) && mergedMiningForkDetectionData.length > 0; } if (createU... | BlockHeaderBuilder { public BlockHeader build() { initializeWithDefaultValues(); if (createConsensusCompliantHeader) { useRskip92Encoding = activationConfig.isActive(ConsensusRule.RSKIP92, number); includeForkDetectionData = activationConfig.isActive(ConsensusRule.RSKIP110, number) && mergedMiningForkDetectionData.leng... | BlockHeaderBuilder { public BlockHeader build() { initializeWithDefaultValues(); if (createConsensusCompliantHeader) { useRskip92Encoding = activationConfig.isActive(ConsensusRule.RSKIP92, number); includeForkDetectionData = activationConfig.isActive(ConsensusRule.RSKIP110, number) && mergedMiningForkDetectionData.leng... | BlockHeaderBuilder { public BlockHeader build() { initializeWithDefaultValues(); if (createConsensusCompliantHeader) { useRskip92Encoding = activationConfig.isActive(ConsensusRule.RSKIP92, number); includeForkDetectionData = activationConfig.isActive(ConsensusRule.RSKIP110, number) && mergedMiningForkDetectionData.leng... | BlockHeaderBuilder { public BlockHeader build() { initializeWithDefaultValues(); if (createConsensusCompliantHeader) { useRskip92Encoding = activationConfig.isActive(ConsensusRule.RSKIP92, number); includeForkDetectionData = activationConfig.isActive(ConsensusRule.RSKIP110, number) && mergedMiningForkDetectionData.leng... |
@Test public void createsHeaderWithEmptyLogsBloom() { BlockHeader header = blockHeaderBuilder.build(); assertArrayEquals(new Bloom().getData(), header.getLogsBloom()); } | public BlockHeader build() { initializeWithDefaultValues(); if (createConsensusCompliantHeader) { useRskip92Encoding = activationConfig.isActive(ConsensusRule.RSKIP92, number); includeForkDetectionData = activationConfig.isActive(ConsensusRule.RSKIP110, number) && mergedMiningForkDetectionData.length > 0; } if (createU... | BlockHeaderBuilder { public BlockHeader build() { initializeWithDefaultValues(); if (createConsensusCompliantHeader) { useRskip92Encoding = activationConfig.isActive(ConsensusRule.RSKIP92, number); includeForkDetectionData = activationConfig.isActive(ConsensusRule.RSKIP110, number) && mergedMiningForkDetectionData.leng... | BlockHeaderBuilder { public BlockHeader build() { initializeWithDefaultValues(); if (createConsensusCompliantHeader) { useRskip92Encoding = activationConfig.isActive(ConsensusRule.RSKIP92, number); includeForkDetectionData = activationConfig.isActive(ConsensusRule.RSKIP110, number) && mergedMiningForkDetectionData.leng... | BlockHeaderBuilder { public BlockHeader build() { initializeWithDefaultValues(); if (createConsensusCompliantHeader) { useRskip92Encoding = activationConfig.isActive(ConsensusRule.RSKIP92, number); includeForkDetectionData = activationConfig.isActive(ConsensusRule.RSKIP110, number) && mergedMiningForkDetectionData.leng... | BlockHeaderBuilder { public BlockHeader build() { initializeWithDefaultValues(); if (createConsensusCompliantHeader) { useRskip92Encoding = activationConfig.isActive(ConsensusRule.RSKIP92, number); includeForkDetectionData = activationConfig.isActive(ConsensusRule.RSKIP110, number) && mergedMiningForkDetectionData.leng... |
@Test public void createsHeaderWithEmptyPaidFees() { BlockHeader header = blockHeaderBuilder.build(); assertEquals(Coin.valueOf(0), header.getPaidFees()); } | public BlockHeader build() { initializeWithDefaultValues(); if (createConsensusCompliantHeader) { useRskip92Encoding = activationConfig.isActive(ConsensusRule.RSKIP92, number); includeForkDetectionData = activationConfig.isActive(ConsensusRule.RSKIP110, number) && mergedMiningForkDetectionData.length > 0; } if (createU... | BlockHeaderBuilder { public BlockHeader build() { initializeWithDefaultValues(); if (createConsensusCompliantHeader) { useRskip92Encoding = activationConfig.isActive(ConsensusRule.RSKIP92, number); includeForkDetectionData = activationConfig.isActive(ConsensusRule.RSKIP110, number) && mergedMiningForkDetectionData.leng... | BlockHeaderBuilder { public BlockHeader build() { initializeWithDefaultValues(); if (createConsensusCompliantHeader) { useRskip92Encoding = activationConfig.isActive(ConsensusRule.RSKIP92, number); includeForkDetectionData = activationConfig.isActive(ConsensusRule.RSKIP110, number) && mergedMiningForkDetectionData.leng... | BlockHeaderBuilder { public BlockHeader build() { initializeWithDefaultValues(); if (createConsensusCompliantHeader) { useRskip92Encoding = activationConfig.isActive(ConsensusRule.RSKIP92, number); includeForkDetectionData = activationConfig.isActive(ConsensusRule.RSKIP110, number) && mergedMiningForkDetectionData.leng... | BlockHeaderBuilder { public BlockHeader build() { initializeWithDefaultValues(); if (createConsensusCompliantHeader) { useRskip92Encoding = activationConfig.isActive(ConsensusRule.RSKIP92, number); includeForkDetectionData = activationConfig.isActive(ConsensusRule.RSKIP110, number) && mergedMiningForkDetectionData.leng... |
@Test public void createsHeaderWithEmptyMinimumGasPrice() { BlockHeader header = blockHeaderBuilder.build(); assertEquals(Coin.valueOf(0), header.getMinimumGasPrice()); } | public BlockHeader build() { initializeWithDefaultValues(); if (createConsensusCompliantHeader) { useRskip92Encoding = activationConfig.isActive(ConsensusRule.RSKIP92, number); includeForkDetectionData = activationConfig.isActive(ConsensusRule.RSKIP110, number) && mergedMiningForkDetectionData.length > 0; } if (createU... | BlockHeaderBuilder { public BlockHeader build() { initializeWithDefaultValues(); if (createConsensusCompliantHeader) { useRskip92Encoding = activationConfig.isActive(ConsensusRule.RSKIP92, number); includeForkDetectionData = activationConfig.isActive(ConsensusRule.RSKIP110, number) && mergedMiningForkDetectionData.leng... | BlockHeaderBuilder { public BlockHeader build() { initializeWithDefaultValues(); if (createConsensusCompliantHeader) { useRskip92Encoding = activationConfig.isActive(ConsensusRule.RSKIP92, number); includeForkDetectionData = activationConfig.isActive(ConsensusRule.RSKIP110, number) && mergedMiningForkDetectionData.leng... | BlockHeaderBuilder { public BlockHeader build() { initializeWithDefaultValues(); if (createConsensusCompliantHeader) { useRskip92Encoding = activationConfig.isActive(ConsensusRule.RSKIP92, number); includeForkDetectionData = activationConfig.isActive(ConsensusRule.RSKIP110, number) && mergedMiningForkDetectionData.leng... | BlockHeaderBuilder { public BlockHeader build() { initializeWithDefaultValues(); if (createConsensusCompliantHeader) { useRskip92Encoding = activationConfig.isActive(ConsensusRule.RSKIP92, number); includeForkDetectionData = activationConfig.isActive(ConsensusRule.RSKIP110, number) && mergedMiningForkDetectionData.leng... |
@Test public void createsHeaderWithEmptyMergedMiningFields() { BlockHeader header = blockHeaderBuilder.build(); assertTrue(Arrays.equals(new byte[0], header.getBitcoinMergedMiningMerkleProof())); assertTrue(Arrays.equals(new byte[0], header.getBitcoinMergedMiningHeader())); assertTrue(Arrays.equals(new byte[0], header.... | public BlockHeader build() { initializeWithDefaultValues(); if (createConsensusCompliantHeader) { useRskip92Encoding = activationConfig.isActive(ConsensusRule.RSKIP92, number); includeForkDetectionData = activationConfig.isActive(ConsensusRule.RSKIP110, number) && mergedMiningForkDetectionData.length > 0; } if (createU... | BlockHeaderBuilder { public BlockHeader build() { initializeWithDefaultValues(); if (createConsensusCompliantHeader) { useRskip92Encoding = activationConfig.isActive(ConsensusRule.RSKIP92, number); includeForkDetectionData = activationConfig.isActive(ConsensusRule.RSKIP110, number) && mergedMiningForkDetectionData.leng... | BlockHeaderBuilder { public BlockHeader build() { initializeWithDefaultValues(); if (createConsensusCompliantHeader) { useRskip92Encoding = activationConfig.isActive(ConsensusRule.RSKIP92, number); includeForkDetectionData = activationConfig.isActive(ConsensusRule.RSKIP110, number) && mergedMiningForkDetectionData.leng... | BlockHeaderBuilder { public BlockHeader build() { initializeWithDefaultValues(); if (createConsensusCompliantHeader) { useRskip92Encoding = activationConfig.isActive(ConsensusRule.RSKIP92, number); includeForkDetectionData = activationConfig.isActive(ConsensusRule.RSKIP110, number) && mergedMiningForkDetectionData.leng... | BlockHeaderBuilder { public BlockHeader build() { initializeWithDefaultValues(); if (createConsensusCompliantHeader) { useRskip92Encoding = activationConfig.isActive(ConsensusRule.RSKIP92, number); includeForkDetectionData = activationConfig.isActive(ConsensusRule.RSKIP110, number) && mergedMiningForkDetectionData.leng... |
@Test public void createsHeaderWithEmptyUmmRootAndRskipUmmOn() { BlockHeader header = blockHeaderBuilder.build(); assertArrayEquals(new byte[0], header.getUmmRoot()); } | public BlockHeader build() { initializeWithDefaultValues(); if (createConsensusCompliantHeader) { useRskip92Encoding = activationConfig.isActive(ConsensusRule.RSKIP92, number); includeForkDetectionData = activationConfig.isActive(ConsensusRule.RSKIP110, number) && mergedMiningForkDetectionData.length > 0; } if (createU... | BlockHeaderBuilder { public BlockHeader build() { initializeWithDefaultValues(); if (createConsensusCompliantHeader) { useRskip92Encoding = activationConfig.isActive(ConsensusRule.RSKIP92, number); includeForkDetectionData = activationConfig.isActive(ConsensusRule.RSKIP110, number) && mergedMiningForkDetectionData.leng... | BlockHeaderBuilder { public BlockHeader build() { initializeWithDefaultValues(); if (createConsensusCompliantHeader) { useRskip92Encoding = activationConfig.isActive(ConsensusRule.RSKIP92, number); includeForkDetectionData = activationConfig.isActive(ConsensusRule.RSKIP110, number) && mergedMiningForkDetectionData.leng... | BlockHeaderBuilder { public BlockHeader build() { initializeWithDefaultValues(); if (createConsensusCompliantHeader) { useRskip92Encoding = activationConfig.isActive(ConsensusRule.RSKIP92, number); includeForkDetectionData = activationConfig.isActive(ConsensusRule.RSKIP110, number) && mergedMiningForkDetectionData.leng... | BlockHeaderBuilder { public BlockHeader build() { initializeWithDefaultValues(); if (createConsensusCompliantHeader) { useRskip92Encoding = activationConfig.isActive(ConsensusRule.RSKIP92, number); includeForkDetectionData = activationConfig.isActive(ConsensusRule.RSKIP110, number) && mergedMiningForkDetectionData.leng... |
@Test public void createsHeaderWithEmptyUmmRootAndRskipUmmOff() { BlockHeaderBuilder builder = new BlockHeaderBuilder(ActivationConfigsForTest.allBut(ConsensusRule.RSKIPUMM)); BlockHeader header = builder.build(); assertNull(header.getUmmRoot()); } | public BlockHeader build() { initializeWithDefaultValues(); if (createConsensusCompliantHeader) { useRskip92Encoding = activationConfig.isActive(ConsensusRule.RSKIP92, number); includeForkDetectionData = activationConfig.isActive(ConsensusRule.RSKIP110, number) && mergedMiningForkDetectionData.length > 0; } if (createU... | BlockHeaderBuilder { public BlockHeader build() { initializeWithDefaultValues(); if (createConsensusCompliantHeader) { useRskip92Encoding = activationConfig.isActive(ConsensusRule.RSKIP92, number); includeForkDetectionData = activationConfig.isActive(ConsensusRule.RSKIP110, number) && mergedMiningForkDetectionData.leng... | BlockHeaderBuilder { public BlockHeader build() { initializeWithDefaultValues(); if (createConsensusCompliantHeader) { useRskip92Encoding = activationConfig.isActive(ConsensusRule.RSKIP92, number); includeForkDetectionData = activationConfig.isActive(ConsensusRule.RSKIP110, number) && mergedMiningForkDetectionData.leng... | BlockHeaderBuilder { public BlockHeader build() { initializeWithDefaultValues(); if (createConsensusCompliantHeader) { useRskip92Encoding = activationConfig.isActive(ConsensusRule.RSKIP92, number); includeForkDetectionData = activationConfig.isActive(ConsensusRule.RSKIP110, number) && mergedMiningForkDetectionData.leng... | BlockHeaderBuilder { public BlockHeader build() { initializeWithDefaultValues(); if (createConsensusCompliantHeader) { useRskip92Encoding = activationConfig.isActive(ConsensusRule.RSKIP92, number); includeForkDetectionData = activationConfig.isActive(ConsensusRule.RSKIP110, number) && mergedMiningForkDetectionData.leng... |
@Test public void getEmptyTransactionList() { TransactionSet txset = new TransactionSet(); List<Transaction> result = txset.getTransactions(); Assert.assertNotNull(result); Assert.assertTrue(result.isEmpty()); } | public List<Transaction> getTransactions() { return transactionsByHash.values().stream() .collect(Collectors.collectingAndThen(Collectors.toList(), Collections::unmodifiableList)); } | TransactionSet { public List<Transaction> getTransactions() { return transactionsByHash.values().stream() .collect(Collectors.collectingAndThen(Collectors.toList(), Collections::unmodifiableList)); } } | TransactionSet { public List<Transaction> getTransactions() { return transactionsByHash.values().stream() .collect(Collectors.collectingAndThen(Collectors.toList(), Collections::unmodifiableList)); } TransactionSet(); TransactionSet(TransactionSet transactionSet); TransactionSet(Map<Keccak256, Transaction> transactio... | TransactionSet { public List<Transaction> getTransactions() { return transactionsByHash.values().stream() .collect(Collectors.collectingAndThen(Collectors.toList(), Collections::unmodifiableList)); } TransactionSet(); TransactionSet(TransactionSet transactionSet); TransactionSet(Map<Keccak256, Transaction> transactio... | TransactionSet { public List<Transaction> getTransactions() { return transactionsByHash.values().stream() .collect(Collectors.collectingAndThen(Collectors.toList(), Collections::unmodifiableList)); } TransactionSet(); TransactionSet(TransactionSet transactionSet); TransactionSet(Map<Keccak256, Transaction> transactio... |
@Test public void hasTransaction() { TransactionSet txset = new TransactionSet(); Transaction transaction1 = createSampleTransaction(10); Transaction transaction2 = createSampleTransaction(20); Transaction transaction3 = createSampleTransaction(30); txset.addTransaction(transaction1); txset.addTransaction(transaction2)... | public boolean hasTransaction(Transaction transaction) { return this.transactionsByHash.containsKey(transaction.getHash()); } | TransactionSet { public boolean hasTransaction(Transaction transaction) { return this.transactionsByHash.containsKey(transaction.getHash()); } } | TransactionSet { public boolean hasTransaction(Transaction transaction) { return this.transactionsByHash.containsKey(transaction.getHash()); } TransactionSet(); TransactionSet(TransactionSet transactionSet); TransactionSet(Map<Keccak256, Transaction> transactionsByHash, Map<RskAddress, List<Transaction>> transactions... | TransactionSet { public boolean hasTransaction(Transaction transaction) { return this.transactionsByHash.containsKey(transaction.getHash()); } TransactionSet(); TransactionSet(TransactionSet transactionSet); TransactionSet(Map<Keccak256, Transaction> transactionsByHash, Map<RskAddress, List<Transaction>> transactions... | TransactionSet { public boolean hasTransaction(Transaction transaction) { return this.transactionsByHash.containsKey(transaction.getHash()); } TransactionSet(); TransactionSet(TransactionSet transactionSet); TransactionSet(Map<Keccak256, Transaction> transactionsByHash, Map<RskAddress, List<Transaction>> transactions... |
@Test public void getEmptyTransactionListByUnknownSender() { TransactionSet txset = new TransactionSet(); List<Transaction> result = txset.getTransactionsWithSender(new RskAddress(new byte[20])); Assert.assertNotNull(result); Assert.assertTrue(result.isEmpty()); } | public List<Transaction> getTransactionsWithSender(RskAddress senderAddress) { List<Transaction> list = this.transactionsByAddress.get(senderAddress); if (list == null) { return Collections.emptyList(); } return list; } | TransactionSet { public List<Transaction> getTransactionsWithSender(RskAddress senderAddress) { List<Transaction> list = this.transactionsByAddress.get(senderAddress); if (list == null) { return Collections.emptyList(); } return list; } } | TransactionSet { public List<Transaction> getTransactionsWithSender(RskAddress senderAddress) { List<Transaction> list = this.transactionsByAddress.get(senderAddress); if (list == null) { return Collections.emptyList(); } return list; } TransactionSet(); TransactionSet(TransactionSet transactionSet); TransactionSet(M... | TransactionSet { public List<Transaction> getTransactionsWithSender(RskAddress senderAddress) { List<Transaction> list = this.transactionsByAddress.get(senderAddress); if (list == null) { return Collections.emptyList(); } return list; } TransactionSet(); TransactionSet(TransactionSet transactionSet); TransactionSet(M... | TransactionSet { public List<Transaction> getTransactionsWithSender(RskAddress senderAddress) { List<Transaction> list = this.transactionsByAddress.get(senderAddress); if (list == null) { return Collections.emptyList(); } return list; } TransactionSet(); TransactionSet(TransactionSet transactionSet); TransactionSet(M... |
@Test public void getGasPrice() { Web3Impl web3 = createWeb3(); web3.eth = new SimpleEthereum(); String expectedValue = ByteUtil.toHexString(new BigInteger("20000000000").toByteArray()); expectedValue = "0x" + (expectedValue.startsWith("0") ? expectedValue.substring(1) : expectedValue); org.junit.Assert.assertEquals(ex... | @Override public String eth_gasPrice() { String gasPrice = null; try { gasPrice = TypeConverter.toQuantityJsonHex(eth.getGasPrice().asBigInteger().longValue()); return gasPrice; } finally { if (logger.isDebugEnabled()) { logger.debug("eth_gasPrice(): {}", gasPrice); } } } | Web3Impl implements Web3 { @Override public String eth_gasPrice() { String gasPrice = null; try { gasPrice = TypeConverter.toQuantityJsonHex(eth.getGasPrice().asBigInteger().longValue()); return gasPrice; } finally { if (logger.isDebugEnabled()) { logger.debug("eth_gasPrice(): {}", gasPrice); } } } } | Web3Impl implements Web3 { @Override public String eth_gasPrice() { String gasPrice = null; try { gasPrice = TypeConverter.toQuantityJsonHex(eth.getGasPrice().asBigInteger().longValue()); return gasPrice; } finally { if (logger.isDebugEnabled()) { logger.debug("eth_gasPrice(): {}", gasPrice); } } } protected Web3Impl(... | Web3Impl implements Web3 { @Override public String eth_gasPrice() { String gasPrice = null; try { gasPrice = TypeConverter.toQuantityJsonHex(eth.getGasPrice().asBigInteger().longValue()); return gasPrice; } finally { if (logger.isDebugEnabled()) { logger.debug("eth_gasPrice(): {}", gasPrice); } } } protected Web3Impl(... | Web3Impl implements Web3 { @Override public String eth_gasPrice() { String gasPrice = null; try { gasPrice = TypeConverter.toQuantityJsonHex(eth.getGasPrice().asBigInteger().longValue()); return gasPrice; } finally { if (logger.isDebugEnabled()) { logger.debug("eth_gasPrice(): {}", gasPrice); } } } protected Web3Impl(... |
@Ignore @Test public void encodeReceiptTest() { String data = "f90244a0f5ff3fbd159773816a7c707a9b8cb6bb778b934a8f6466c7830ed970498f4b688301e848b90200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000... | public byte[] getEncoded() { if (this.rlpEncoding == null) { byte[] v; byte[] r; byte[] s; if (this.signature != null) { v = RLP.encodeByte((byte) (chainId == 0 ? signature.getV() : (signature.getV() - LOWER_REAL_V) + (chainId * 2 + CHAIN_ID_INC))); r = RLP.encodeElement(BigIntegers.asUnsignedByteArray(signature.getR()... | Transaction { public byte[] getEncoded() { if (this.rlpEncoding == null) { byte[] v; byte[] r; byte[] s; if (this.signature != null) { v = RLP.encodeByte((byte) (chainId == 0 ? signature.getV() : (signature.getV() - LOWER_REAL_V) + (chainId * 2 + CHAIN_ID_INC))); r = RLP.encodeElement(BigIntegers.asUnsignedByteArray(si... | Transaction { public byte[] getEncoded() { if (this.rlpEncoding == null) { byte[] v; byte[] r; byte[] s; if (this.signature != null) { v = RLP.encodeByte((byte) (chainId == 0 ? signature.getV() : (signature.getV() - LOWER_REAL_V) + (chainId * 2 + CHAIN_ID_INC))); r = RLP.encodeElement(BigIntegers.asUnsignedByteArray(si... | Transaction { public byte[] getEncoded() { if (this.rlpEncoding == null) { byte[] v; byte[] r; byte[] s; if (this.signature != null) { v = RLP.encodeByte((byte) (chainId == 0 ? signature.getV() : (signature.getV() - LOWER_REAL_V) + (chainId * 2 + CHAIN_ID_INC))); r = RLP.encodeElement(BigIntegers.asUnsignedByteArray(si... | Transaction { public byte[] getEncoded() { if (this.rlpEncoding == null) { byte[] v; byte[] r; byte[] s; if (this.signature != null) { v = RLP.encodeByte((byte) (chainId == 0 ? signature.getV() : (signature.getV() - LOWER_REAL_V) + (chainId * 2 + CHAIN_ID_INC))); r = RLP.encodeElement(BigIntegers.asUnsignedByteArray(si... |
@Test public void verifyTx_noSignature() { BigInteger value = new BigInteger("1000000000000000000000"); byte[] privKey = HashUtil.keccak256("cat".getBytes()); ECKey ecKey = ECKey.fromPrivate(privKey); byte[] gasPrice = Hex.decode("09184e72a000"); byte[] gas = Hex.decode("4255"); Transaction tx = new Transaction(new byt... | public void verify() { validate(); } | Transaction { public void verify() { validate(); } } | Transaction { public void verify() { validate(); } protected Transaction(byte[] rawData); Transaction(byte[] nonce, byte[] gasPriceRaw, byte[] gasLimit, byte[] receiveAddress, byte[] value, byte[] data); Transaction(byte[] nonce, byte[] gasPriceRaw, byte[] gasLimit, byte[] receiveAddress, byte[] value, byte[] data, ... | Transaction { public void verify() { validate(); } protected Transaction(byte[] rawData); Transaction(byte[] nonce, byte[] gasPriceRaw, byte[] gasLimit, byte[] receiveAddress, byte[] value, byte[] data); Transaction(byte[] nonce, byte[] gasPriceRaw, byte[] gasLimit, byte[] receiveAddress, byte[] value, byte[] data, ... | Transaction { public void verify() { validate(); } protected Transaction(byte[] rawData); Transaction(byte[] nonce, byte[] gasPriceRaw, byte[] gasLimit, byte[] receiveAddress, byte[] value, byte[] data); Transaction(byte[] nonce, byte[] gasPriceRaw, byte[] gasLimit, byte[] receiveAddress, byte[] value, byte[] data, ... |
@Test public void toString_nullElements() { byte[] encodedNull = RLP.encodeElement(null); byte[] encodedEmptyArray = RLP.encodeElement(EMPTY_BYTE_ARRAY); byte[] rawData = RLP.encodeList(encodedNull, encodedNull, encodedNull, encodedNull, encodedNull, encodedNull, encodedEmptyArray, encodedEmptyArray, encodedEmptyArray)... | @Override public String toString() { return "TransactionData [" + "hash=" + ByteUtil.toHexStringOrEmpty(getHash().getBytes()) + " nonce=" + ByteUtil.toHexStringOrEmpty(nonce) + ", gasPrice=" + gasPrice + ", gas=" + ByteUtil.toHexStringOrEmpty(gasLimit) + ", receiveAddress=" + receiveAddress + ", value=" + value + ", da... | Transaction { @Override public String toString() { return "TransactionData [" + "hash=" + ByteUtil.toHexStringOrEmpty(getHash().getBytes()) + " nonce=" + ByteUtil.toHexStringOrEmpty(nonce) + ", gasPrice=" + gasPrice + ", gas=" + ByteUtil.toHexStringOrEmpty(gasLimit) + ", receiveAddress=" + receiveAddress + ", value=" +... | Transaction { @Override public String toString() { return "TransactionData [" + "hash=" + ByteUtil.toHexStringOrEmpty(getHash().getBytes()) + " nonce=" + ByteUtil.toHexStringOrEmpty(nonce) + ", gasPrice=" + gasPrice + ", gas=" + ByteUtil.toHexStringOrEmpty(gasLimit) + ", receiveAddress=" + receiveAddress + ", value=" +... | Transaction { @Override public String toString() { return "TransactionData [" + "hash=" + ByteUtil.toHexStringOrEmpty(getHash().getBytes()) + " nonce=" + ByteUtil.toHexStringOrEmpty(nonce) + ", gasPrice=" + gasPrice + ", gas=" + ByteUtil.toHexStringOrEmpty(gasLimit) + ", receiveAddress=" + receiveAddress + ", value=" +... | Transaction { @Override public String toString() { return "TransactionData [" + "hash=" + ByteUtil.toHexStringOrEmpty(getHash().getBytes()) + " nonce=" + ByteUtil.toHexStringOrEmpty(nonce) + ", gasPrice=" + gasPrice + ", gas=" + ByteUtil.toHexStringOrEmpty(gasLimit) + ", receiveAddress=" + receiveAddress + ", value=" +... |
@Test public void testGetEncoded() { String expected = "dc809a0100000000000000000000000000000000000000000000000000"; AccountState acct = new AccountState(BigInteger.ZERO, new Coin(BigInteger.valueOf(2).pow(200))); assertEquals(expected, ByteUtil.toHexString(acct.getEncoded())); } | public byte[] getEncoded() { if (rlpEncoded == null) { byte[] anonce = RLP.encodeBigInteger(this.nonce); byte[] abalance = RLP.encodeSignedCoinNonNullZero(this.balance); if (stateFlags != 0) { byte[] astateFlags = RLP.encodeInt(this.stateFlags); this.rlpEncoded = RLP.encodeList(anonce, abalance, astateFlags); } else { ... | AccountState { public byte[] getEncoded() { if (rlpEncoded == null) { byte[] anonce = RLP.encodeBigInteger(this.nonce); byte[] abalance = RLP.encodeSignedCoinNonNullZero(this.balance); if (stateFlags != 0) { byte[] astateFlags = RLP.encodeInt(this.stateFlags); this.rlpEncoded = RLP.encodeList(anonce, abalance, astateFl... | AccountState { public byte[] getEncoded() { if (rlpEncoded == null) { byte[] anonce = RLP.encodeBigInteger(this.nonce); byte[] abalance = RLP.encodeSignedCoinNonNullZero(this.balance); if (stateFlags != 0) { byte[] astateFlags = RLP.encodeInt(this.stateFlags); this.rlpEncoded = RLP.encodeList(anonce, abalance, astateFl... | AccountState { public byte[] getEncoded() { if (rlpEncoded == null) { byte[] anonce = RLP.encodeBigInteger(this.nonce); byte[] abalance = RLP.encodeSignedCoinNonNullZero(this.balance); if (stateFlags != 0) { byte[] astateFlags = RLP.encodeInt(this.stateFlags); this.rlpEncoded = RLP.encodeList(anonce, abalance, astateFl... | AccountState { public byte[] getEncoded() { if (rlpEncoded == null) { byte[] anonce = RLP.encodeBigInteger(this.nonce); byte[] abalance = RLP.encodeSignedCoinNonNullZero(this.balance); if (stateFlags != 0) { byte[] astateFlags = RLP.encodeInt(this.stateFlags); this.rlpEncoded = RLP.encodeList(anonce, abalance, astateFl... |
@Ignore @Test public void parentDifficultyLessHeaderDifficulty() { BlockHeader header = getHeader(10004); BlockHeader parent = getHeader(10000); assertTrue(rule.validate(header, parent)); } | @Override public boolean validate(BlockHeader header, BlockHeader parent) { BlockDifficulty calcDifficulty = difficultyCalculator.calcDifficulty(header, parent); BlockDifficulty difficulty = header.getDifficulty(); if (!difficulty.equals(calcDifficulty)) { logger.error("#{}: difficulty != calcDifficulty", header.getNum... | DifficultyRule extends DependentBlockHeaderRule { @Override public boolean validate(BlockHeader header, BlockHeader parent) { BlockDifficulty calcDifficulty = difficultyCalculator.calcDifficulty(header, parent); BlockDifficulty difficulty = header.getDifficulty(); if (!difficulty.equals(calcDifficulty)) { logger.error(... | DifficultyRule extends DependentBlockHeaderRule { @Override public boolean validate(BlockHeader header, BlockHeader parent) { BlockDifficulty calcDifficulty = difficultyCalculator.calcDifficulty(header, parent); BlockDifficulty difficulty = header.getDifficulty(); if (!difficulty.equals(calcDifficulty)) { logger.error(... | DifficultyRule extends DependentBlockHeaderRule { @Override public boolean validate(BlockHeader header, BlockHeader parent) { BlockDifficulty calcDifficulty = difficultyCalculator.calcDifficulty(header, parent); BlockDifficulty difficulty = header.getDifficulty(); if (!difficulty.equals(calcDifficulty)) { logger.error(... | DifficultyRule extends DependentBlockHeaderRule { @Override public boolean validate(BlockHeader header, BlockHeader parent) { BlockDifficulty calcDifficulty = difficultyCalculator.calcDifficulty(header, parent); BlockDifficulty difficulty = header.getDifficulty(); if (!difficulty.equals(calcDifficulty)) { logger.error(... |
@Test public void parentDifficultyEqualHeaderDifficulty() { BlockHeader header = getHeader(10000); BlockHeader parent = getHeader(10000); assertFalse(rule.validate(header, parent)); } | @Override public boolean validate(BlockHeader header, BlockHeader parent) { BlockDifficulty calcDifficulty = difficultyCalculator.calcDifficulty(header, parent); BlockDifficulty difficulty = header.getDifficulty(); if (!difficulty.equals(calcDifficulty)) { logger.error("#{}: difficulty != calcDifficulty", header.getNum... | DifficultyRule extends DependentBlockHeaderRule { @Override public boolean validate(BlockHeader header, BlockHeader parent) { BlockDifficulty calcDifficulty = difficultyCalculator.calcDifficulty(header, parent); BlockDifficulty difficulty = header.getDifficulty(); if (!difficulty.equals(calcDifficulty)) { logger.error(... | DifficultyRule extends DependentBlockHeaderRule { @Override public boolean validate(BlockHeader header, BlockHeader parent) { BlockDifficulty calcDifficulty = difficultyCalculator.calcDifficulty(header, parent); BlockDifficulty difficulty = header.getDifficulty(); if (!difficulty.equals(calcDifficulty)) { logger.error(... | DifficultyRule extends DependentBlockHeaderRule { @Override public boolean validate(BlockHeader header, BlockHeader parent) { BlockDifficulty calcDifficulty = difficultyCalculator.calcDifficulty(header, parent); BlockDifficulty difficulty = header.getDifficulty(); if (!difficulty.equals(calcDifficulty)) { logger.error(... | DifficultyRule extends DependentBlockHeaderRule { @Override public boolean validate(BlockHeader header, BlockHeader parent) { BlockDifficulty calcDifficulty = difficultyCalculator.calcDifficulty(header, parent); BlockDifficulty difficulty = header.getDifficulty(); if (!difficulty.equals(calcDifficulty)) { logger.error(... |
@Test public void parentNumberEqualBlockNumberMinusOne() { BlockHeader header = getHeader(10000); BlockHeader parent = getHeader(9999); assertTrue(rule.validate(header, parent)); } | @Override public boolean validate(BlockHeader header, BlockHeader parent) { if (header.getNumber() != (parent.getNumber() + 1)) { logger.error(String.format("#%d: block number is not parentBlock number + 1", header.getNumber())); return false; } return true; } | ParentNumberRule extends DependentBlockHeaderRule { @Override public boolean validate(BlockHeader header, BlockHeader parent) { if (header.getNumber() != (parent.getNumber() + 1)) { logger.error(String.format("#%d: block number is not parentBlock number + 1", header.getNumber())); return false; } return true; } } | ParentNumberRule extends DependentBlockHeaderRule { @Override public boolean validate(BlockHeader header, BlockHeader parent) { if (header.getNumber() != (parent.getNumber() + 1)) { logger.error(String.format("#%d: block number is not parentBlock number + 1", header.getNumber())); return false; } return true; } } | ParentNumberRule extends DependentBlockHeaderRule { @Override public boolean validate(BlockHeader header, BlockHeader parent) { if (header.getNumber() != (parent.getNumber() + 1)) { logger.error(String.format("#%d: block number is not parentBlock number + 1", header.getNumber())); return false; } return true; } @Overr... | ParentNumberRule extends DependentBlockHeaderRule { @Override public boolean validate(BlockHeader header, BlockHeader parent) { if (header.getNumber() != (parent.getNumber() + 1)) { logger.error(String.format("#%d: block number is not parentBlock number + 1", header.getNumber())); return false; } return true; } @Overr... |
@Test public void parentNumberEqualBlockNumber() { BlockHeader header = getHeader(100); BlockHeader parent = getHeader(100); assertFalse(rule.validate(header, parent)); } | @Override public boolean validate(BlockHeader header, BlockHeader parent) { if (header.getNumber() != (parent.getNumber() + 1)) { logger.error(String.format("#%d: block number is not parentBlock number + 1", header.getNumber())); return false; } return true; } | ParentNumberRule extends DependentBlockHeaderRule { @Override public boolean validate(BlockHeader header, BlockHeader parent) { if (header.getNumber() != (parent.getNumber() + 1)) { logger.error(String.format("#%d: block number is not parentBlock number + 1", header.getNumber())); return false; } return true; } } | ParentNumberRule extends DependentBlockHeaderRule { @Override public boolean validate(BlockHeader header, BlockHeader parent) { if (header.getNumber() != (parent.getNumber() + 1)) { logger.error(String.format("#%d: block number is not parentBlock number + 1", header.getNumber())); return false; } return true; } } | ParentNumberRule extends DependentBlockHeaderRule { @Override public boolean validate(BlockHeader header, BlockHeader parent) { if (header.getNumber() != (parent.getNumber() + 1)) { logger.error(String.format("#%d: block number is not parentBlock number + 1", header.getNumber())); return false; } return true; } @Overr... | ParentNumberRule extends DependentBlockHeaderRule { @Override public boolean validate(BlockHeader header, BlockHeader parent) { if (header.getNumber() != (parent.getNumber() + 1)) { logger.error(String.format("#%d: block number is not parentBlock number + 1", header.getNumber())); return false; } return true; } @Overr... |
@Test public void parentNumberGreaterThanBlockNumber() { BlockHeader header = getHeader(100); BlockHeader parent = getHeader(101); assertFalse(rule.validate(header, parent)); } | @Override public boolean validate(BlockHeader header, BlockHeader parent) { if (header.getNumber() != (parent.getNumber() + 1)) { logger.error(String.format("#%d: block number is not parentBlock number + 1", header.getNumber())); return false; } return true; } | ParentNumberRule extends DependentBlockHeaderRule { @Override public boolean validate(BlockHeader header, BlockHeader parent) { if (header.getNumber() != (parent.getNumber() + 1)) { logger.error(String.format("#%d: block number is not parentBlock number + 1", header.getNumber())); return false; } return true; } } | ParentNumberRule extends DependentBlockHeaderRule { @Override public boolean validate(BlockHeader header, BlockHeader parent) { if (header.getNumber() != (parent.getNumber() + 1)) { logger.error(String.format("#%d: block number is not parentBlock number + 1", header.getNumber())); return false; } return true; } } | ParentNumberRule extends DependentBlockHeaderRule { @Override public boolean validate(BlockHeader header, BlockHeader parent) { if (header.getNumber() != (parent.getNumber() + 1)) { logger.error(String.format("#%d: block number is not parentBlock number + 1", header.getNumber())); return false; } return true; } @Overr... | ParentNumberRule extends DependentBlockHeaderRule { @Override public boolean validate(BlockHeader header, BlockHeader parent) { if (header.getNumber() != (parent.getNumber() + 1)) { logger.error(String.format("#%d: block number is not parentBlock number + 1", header.getNumber())); return false; } return true; } @Overr... |
@Test public void parentGasLimitLessThanGasLimit() { BlockHeader header = getHeader(10000); BlockHeader parent = getHeader(9999); assertTrue(rule.validate(header, parent)); } | @Override public boolean validate(BlockHeader header, BlockHeader parent) { BigInteger headerGasLimit = new BigInteger(1, header.getGasLimit()); BigInteger parentGasLimit = new BigInteger(1, parent.getGasLimit()); BigInteger deltaLimit = parentGasLimit.divide(gasLimitBoundDivisor); if (headerGasLimit.compareTo(parentGa... | ParentGasLimitRule extends DependentBlockHeaderRule { @Override public boolean validate(BlockHeader header, BlockHeader parent) { BigInteger headerGasLimit = new BigInteger(1, header.getGasLimit()); BigInteger parentGasLimit = new BigInteger(1, parent.getGasLimit()); BigInteger deltaLimit = parentGasLimit.divide(gasLim... | ParentGasLimitRule extends DependentBlockHeaderRule { @Override public boolean validate(BlockHeader header, BlockHeader parent) { BigInteger headerGasLimit = new BigInteger(1, header.getGasLimit()); BigInteger parentGasLimit = new BigInteger(1, parent.getGasLimit()); BigInteger deltaLimit = parentGasLimit.divide(gasLim... | ParentGasLimitRule extends DependentBlockHeaderRule { @Override public boolean validate(BlockHeader header, BlockHeader parent) { BigInteger headerGasLimit = new BigInteger(1, header.getGasLimit()); BigInteger parentGasLimit = new BigInteger(1, parent.getGasLimit()); BigInteger deltaLimit = parentGasLimit.divide(gasLim... | ParentGasLimitRule extends DependentBlockHeaderRule { @Override public boolean validate(BlockHeader header, BlockHeader parent) { BigInteger headerGasLimit = new BigInteger(1, header.getGasLimit()); BigInteger parentGasLimit = new BigInteger(1, parent.getGasLimit()); BigInteger deltaLimit = parentGasLimit.divide(gasLim... |
@Test public void getUnknownTransactionReceipt() throws Exception { ReceiptStore receiptStore = new ReceiptStoreImpl(new HashMapDB()); World world = new World(receiptStore); Web3Impl web3 = createWeb3(world, receiptStore); Account acc1 = new AccountBuilder().name("acc1").build(); Account acc2 = new AccountBuilder().nam... | @Override public TransactionReceiptDTO eth_getTransactionReceipt(String transactionHash) { logger.trace("eth_getTransactionReceipt({})", transactionHash); byte[] hash = stringHexToByteArray(transactionHash); TransactionInfo txInfo = receiptStore.getInMainChain(hash, blockStore); if (txInfo == null) { logger.trace("No t... | Web3Impl implements Web3 { @Override public TransactionReceiptDTO eth_getTransactionReceipt(String transactionHash) { logger.trace("eth_getTransactionReceipt({})", transactionHash); byte[] hash = stringHexToByteArray(transactionHash); TransactionInfo txInfo = receiptStore.getInMainChain(hash, blockStore); if (txInfo ==... | Web3Impl implements Web3 { @Override public TransactionReceiptDTO eth_getTransactionReceipt(String transactionHash) { logger.trace("eth_getTransactionReceipt({})", transactionHash); byte[] hash = stringHexToByteArray(transactionHash); TransactionInfo txInfo = receiptStore.getInMainChain(hash, blockStore); if (txInfo ==... | Web3Impl implements Web3 { @Override public TransactionReceiptDTO eth_getTransactionReceipt(String transactionHash) { logger.trace("eth_getTransactionReceipt({})", transactionHash); byte[] hash = stringHexToByteArray(transactionHash); TransactionInfo txInfo = receiptStore.getInMainChain(hash, blockStore); if (txInfo ==... | Web3Impl implements Web3 { @Override public TransactionReceiptDTO eth_getTransactionReceipt(String transactionHash) { logger.trace("eth_getTransactionReceipt({})", transactionHash); byte[] hash = stringHexToByteArray(transactionHash); TransactionInfo txInfo = receiptStore.getInMainChain(hash, blockStore); if (txInfo ==... |
@Test public void parentGasLimitTooLessThanGasLimit() { BlockHeader header = getHeader(100); BlockHeader parent = getHeader(9); assertFalse(rule.validate(header, parent)); } | @Override public boolean validate(BlockHeader header, BlockHeader parent) { BigInteger headerGasLimit = new BigInteger(1, header.getGasLimit()); BigInteger parentGasLimit = new BigInteger(1, parent.getGasLimit()); BigInteger deltaLimit = parentGasLimit.divide(gasLimitBoundDivisor); if (headerGasLimit.compareTo(parentGa... | ParentGasLimitRule extends DependentBlockHeaderRule { @Override public boolean validate(BlockHeader header, BlockHeader parent) { BigInteger headerGasLimit = new BigInteger(1, header.getGasLimit()); BigInteger parentGasLimit = new BigInteger(1, parent.getGasLimit()); BigInteger deltaLimit = parentGasLimit.divide(gasLim... | ParentGasLimitRule extends DependentBlockHeaderRule { @Override public boolean validate(BlockHeader header, BlockHeader parent) { BigInteger headerGasLimit = new BigInteger(1, header.getGasLimit()); BigInteger parentGasLimit = new BigInteger(1, parent.getGasLimit()); BigInteger deltaLimit = parentGasLimit.divide(gasLim... | ParentGasLimitRule extends DependentBlockHeaderRule { @Override public boolean validate(BlockHeader header, BlockHeader parent) { BigInteger headerGasLimit = new BigInteger(1, header.getGasLimit()); BigInteger parentGasLimit = new BigInteger(1, parent.getGasLimit()); BigInteger deltaLimit = parentGasLimit.divide(gasLim... | ParentGasLimitRule extends DependentBlockHeaderRule { @Override public boolean validate(BlockHeader header, BlockHeader parent) { BigInteger headerGasLimit = new BigInteger(1, header.getGasLimit()); BigInteger parentGasLimit = new BigInteger(1, parent.getGasLimit()); BigInteger deltaLimit = parentGasLimit.divide(gasLim... |
@Test public void parentGasLimitGreaterThanGasLimit() { BlockHeader header = getHeader(10000); BlockHeader parent = getHeader(10001); assertTrue(rule.validate(header, parent)); } | @Override public boolean validate(BlockHeader header, BlockHeader parent) { BigInteger headerGasLimit = new BigInteger(1, header.getGasLimit()); BigInteger parentGasLimit = new BigInteger(1, parent.getGasLimit()); BigInteger deltaLimit = parentGasLimit.divide(gasLimitBoundDivisor); if (headerGasLimit.compareTo(parentGa... | ParentGasLimitRule extends DependentBlockHeaderRule { @Override public boolean validate(BlockHeader header, BlockHeader parent) { BigInteger headerGasLimit = new BigInteger(1, header.getGasLimit()); BigInteger parentGasLimit = new BigInteger(1, parent.getGasLimit()); BigInteger deltaLimit = parentGasLimit.divide(gasLim... | ParentGasLimitRule extends DependentBlockHeaderRule { @Override public boolean validate(BlockHeader header, BlockHeader parent) { BigInteger headerGasLimit = new BigInteger(1, header.getGasLimit()); BigInteger parentGasLimit = new BigInteger(1, parent.getGasLimit()); BigInteger deltaLimit = parentGasLimit.divide(gasLim... | ParentGasLimitRule extends DependentBlockHeaderRule { @Override public boolean validate(BlockHeader header, BlockHeader parent) { BigInteger headerGasLimit = new BigInteger(1, header.getGasLimit()); BigInteger parentGasLimit = new BigInteger(1, parent.getGasLimit()); BigInteger deltaLimit = parentGasLimit.divide(gasLim... | ParentGasLimitRule extends DependentBlockHeaderRule { @Override public boolean validate(BlockHeader header, BlockHeader parent) { BigInteger headerGasLimit = new BigInteger(1, header.getGasLimit()); BigInteger parentGasLimit = new BigInteger(1, parent.getGasLimit()); BigInteger deltaLimit = parentGasLimit.divide(gasLim... |
@Test public void parentGasLimitTooGreaterThanGasLimit() { BlockHeader header = getHeader(9); BlockHeader parent = getHeader(100); assertFalse(rule.validate(header, parent)); } | @Override public boolean validate(BlockHeader header, BlockHeader parent) { BigInteger headerGasLimit = new BigInteger(1, header.getGasLimit()); BigInteger parentGasLimit = new BigInteger(1, parent.getGasLimit()); BigInteger deltaLimit = parentGasLimit.divide(gasLimitBoundDivisor); if (headerGasLimit.compareTo(parentGa... | ParentGasLimitRule extends DependentBlockHeaderRule { @Override public boolean validate(BlockHeader header, BlockHeader parent) { BigInteger headerGasLimit = new BigInteger(1, header.getGasLimit()); BigInteger parentGasLimit = new BigInteger(1, parent.getGasLimit()); BigInteger deltaLimit = parentGasLimit.divide(gasLim... | ParentGasLimitRule extends DependentBlockHeaderRule { @Override public boolean validate(BlockHeader header, BlockHeader parent) { BigInteger headerGasLimit = new BigInteger(1, header.getGasLimit()); BigInteger parentGasLimit = new BigInteger(1, parent.getGasLimit()); BigInteger deltaLimit = parentGasLimit.divide(gasLim... | ParentGasLimitRule extends DependentBlockHeaderRule { @Override public boolean validate(BlockHeader header, BlockHeader parent) { BigInteger headerGasLimit = new BigInteger(1, header.getGasLimit()); BigInteger parentGasLimit = new BigInteger(1, parent.getGasLimit()); BigInteger deltaLimit = parentGasLimit.divide(gasLim... | ParentGasLimitRule extends DependentBlockHeaderRule { @Override public boolean validate(BlockHeader header, BlockHeader parent) { BigInteger headerGasLimit = new BigInteger(1, header.getGasLimit()); BigInteger parentGasLimit = new BigInteger(1, parent.getGasLimit()); BigInteger deltaLimit = parentGasLimit.divide(gasLim... |
@Test public void parentGasLimitOfBy1Tests() { BlockHeader parent = getHeader(2049); BlockHeader headerGGood = getHeader(2051); BlockHeader headerGBad = getHeader(2052); BlockHeader headerLGood = getHeader(2047); BlockHeader headerLBad = getHeader(2046); assertTrue(rule.validate(headerGGood, parent)); assertTrue(rule.v... | @Override public boolean validate(BlockHeader header, BlockHeader parent) { BigInteger headerGasLimit = new BigInteger(1, header.getGasLimit()); BigInteger parentGasLimit = new BigInteger(1, parent.getGasLimit()); BigInteger deltaLimit = parentGasLimit.divide(gasLimitBoundDivisor); if (headerGasLimit.compareTo(parentGa... | ParentGasLimitRule extends DependentBlockHeaderRule { @Override public boolean validate(BlockHeader header, BlockHeader parent) { BigInteger headerGasLimit = new BigInteger(1, header.getGasLimit()); BigInteger parentGasLimit = new BigInteger(1, parent.getGasLimit()); BigInteger deltaLimit = parentGasLimit.divide(gasLim... | ParentGasLimitRule extends DependentBlockHeaderRule { @Override public boolean validate(BlockHeader header, BlockHeader parent) { BigInteger headerGasLimit = new BigInteger(1, header.getGasLimit()); BigInteger parentGasLimit = new BigInteger(1, parent.getGasLimit()); BigInteger deltaLimit = parentGasLimit.divide(gasLim... | ParentGasLimitRule extends DependentBlockHeaderRule { @Override public boolean validate(BlockHeader header, BlockHeader parent) { BigInteger headerGasLimit = new BigInteger(1, header.getGasLimit()); BigInteger parentGasLimit = new BigInteger(1, parent.getGasLimit()); BigInteger deltaLimit = parentGasLimit.divide(gasLim... | ParentGasLimitRule extends DependentBlockHeaderRule { @Override public boolean validate(BlockHeader header, BlockHeader parent) { BigInteger headerGasLimit = new BigInteger(1, header.getGasLimit()); BigInteger parentGasLimit = new BigInteger(1, parent.getGasLimit()); BigInteger deltaLimit = parentGasLimit.divide(gasLim... |
@Test public void toGas() { Assert.assertEquals(0, GasCost.toGas(new byte[0])); Assert.assertEquals(1, GasCost.toGas(new byte[] { 0x01 })); Assert.assertEquals(255, GasCost.toGas(new byte[] { (byte)0xff })); Assert.assertEquals( Long.MAX_VALUE, GasCost.toGas(BigInteger.valueOf(Long.MAX_VALUE).toByteArray()) ); } | public static long toGas(byte[] bytes) throws InvalidGasException { if (bytes.length > 8) { return Long.MAX_VALUE; } long result = ByteUtil.byteArrayToLong(bytes); if (result < 0) { throw new InvalidGasException(bytes); } return result; } | GasCost { public static long toGas(byte[] bytes) throws InvalidGasException { if (bytes.length > 8) { return Long.MAX_VALUE; } long result = ByteUtil.byteArrayToLong(bytes); if (result < 0) { throw new InvalidGasException(bytes); } return result; } } | GasCost { public static long toGas(byte[] bytes) throws InvalidGasException { if (bytes.length > 8) { return Long.MAX_VALUE; } long result = ByteUtil.byteArrayToLong(bytes); if (result < 0) { throw new InvalidGasException(bytes); } return result; } private GasCost(); } | GasCost { public static long toGas(byte[] bytes) throws InvalidGasException { if (bytes.length > 8) { return Long.MAX_VALUE; } long result = ByteUtil.byteArrayToLong(bytes); if (result < 0) { throw new InvalidGasException(bytes); } return result; } private GasCost(); static long toGas(byte[] bytes); static long toGas(... | GasCost { public static long toGas(byte[] bytes) throws InvalidGasException { if (bytes.length > 8) { return Long.MAX_VALUE; } long result = ByteUtil.byteArrayToLong(bytes); if (result < 0) { throw new InvalidGasException(bytes); } return result; } private GasCost(); static long toGas(byte[] bytes); static long toGas(... |
@Test public void toGasOverflowsSlightly() { byte[] bytes = new byte[32]; for (int k = 0; k < 17; k++) { bytes[k] = (byte)0x00; } bytes[17] = (byte)0x80; for (int k = 18; k < 32; k++) { bytes[k] = (byte)0x00; } Assert.assertEquals(GasCost.toGas(bytes), Long.MAX_VALUE); } | public static long toGas(byte[] bytes) throws InvalidGasException { if (bytes.length > 8) { return Long.MAX_VALUE; } long result = ByteUtil.byteArrayToLong(bytes); if (result < 0) { throw new InvalidGasException(bytes); } return result; } | GasCost { public static long toGas(byte[] bytes) throws InvalidGasException { if (bytes.length > 8) { return Long.MAX_VALUE; } long result = ByteUtil.byteArrayToLong(bytes); if (result < 0) { throw new InvalidGasException(bytes); } return result; } } | GasCost { public static long toGas(byte[] bytes) throws InvalidGasException { if (bytes.length > 8) { return Long.MAX_VALUE; } long result = ByteUtil.byteArrayToLong(bytes); if (result < 0) { throw new InvalidGasException(bytes); } return result; } private GasCost(); } | GasCost { public static long toGas(byte[] bytes) throws InvalidGasException { if (bytes.length > 8) { return Long.MAX_VALUE; } long result = ByteUtil.byteArrayToLong(bytes); if (result < 0) { throw new InvalidGasException(bytes); } return result; } private GasCost(); static long toGas(byte[] bytes); static long toGas(... | GasCost { public static long toGas(byte[] bytes) throws InvalidGasException { if (bytes.length > 8) { return Long.MAX_VALUE; } long result = ByteUtil.byteArrayToLong(bytes); if (result < 0) { throw new InvalidGasException(bytes); } return result; } private GasCost(); static long toGas(byte[] bytes); static long toGas(... |
@Test(expected = GasCost.InvalidGasException.class) public void toGasGivesNegativeValue() throws GasCost.InvalidGasException { byte[] negativeBytes = new byte[]{ (byte)255, (byte)255, (byte)255, (byte)255, (byte)255, (byte)255, (byte)255, (byte)255, }; GasCost.toGas(negativeBytes); } | public static long toGas(byte[] bytes) throws InvalidGasException { if (bytes.length > 8) { return Long.MAX_VALUE; } long result = ByteUtil.byteArrayToLong(bytes); if (result < 0) { throw new InvalidGasException(bytes); } return result; } | GasCost { public static long toGas(byte[] bytes) throws InvalidGasException { if (bytes.length > 8) { return Long.MAX_VALUE; } long result = ByteUtil.byteArrayToLong(bytes); if (result < 0) { throw new InvalidGasException(bytes); } return result; } } | GasCost { public static long toGas(byte[] bytes) throws InvalidGasException { if (bytes.length > 8) { return Long.MAX_VALUE; } long result = ByteUtil.byteArrayToLong(bytes); if (result < 0) { throw new InvalidGasException(bytes); } return result; } private GasCost(); } | GasCost { public static long toGas(byte[] bytes) throws InvalidGasException { if (bytes.length > 8) { return Long.MAX_VALUE; } long result = ByteUtil.byteArrayToLong(bytes); if (result < 0) { throw new InvalidGasException(bytes); } return result; } private GasCost(); static long toGas(byte[] bytes); static long toGas(... | GasCost { public static long toGas(byte[] bytes) throws InvalidGasException { if (bytes.length > 8) { return Long.MAX_VALUE; } long result = ByteUtil.byteArrayToLong(bytes); if (result < 0) { throw new InvalidGasException(bytes); } return result; } private GasCost(); static long toGas(byte[] bytes); static long toGas(... |
@Test public void toGasArrayTooBig() throws GasCost.InvalidGasException { byte[] bigArray = new byte[]{ (byte)255, (byte)255, (byte)255, (byte)255, (byte)255, (byte)255, (byte)255, (byte)255, (byte)255, (byte)255, (byte)255, (byte)255, }; Assert.assertEquals(GasCost.toGas(bigArray), Long.MAX_VALUE); } | public static long toGas(byte[] bytes) throws InvalidGasException { if (bytes.length > 8) { return Long.MAX_VALUE; } long result = ByteUtil.byteArrayToLong(bytes); if (result < 0) { throw new InvalidGasException(bytes); } return result; } | GasCost { public static long toGas(byte[] bytes) throws InvalidGasException { if (bytes.length > 8) { return Long.MAX_VALUE; } long result = ByteUtil.byteArrayToLong(bytes); if (result < 0) { throw new InvalidGasException(bytes); } return result; } } | GasCost { public static long toGas(byte[] bytes) throws InvalidGasException { if (bytes.length > 8) { return Long.MAX_VALUE; } long result = ByteUtil.byteArrayToLong(bytes); if (result < 0) { throw new InvalidGasException(bytes); } return result; } private GasCost(); } | GasCost { public static long toGas(byte[] bytes) throws InvalidGasException { if (bytes.length > 8) { return Long.MAX_VALUE; } long result = ByteUtil.byteArrayToLong(bytes); if (result < 0) { throw new InvalidGasException(bytes); } return result; } private GasCost(); static long toGas(byte[] bytes); static long toGas(... | GasCost { public static long toGas(byte[] bytes) throws InvalidGasException { if (bytes.length > 8) { return Long.MAX_VALUE; } long result = ByteUtil.byteArrayToLong(bytes); if (result < 0) { throw new InvalidGasException(bytes); } return result; } private GasCost(); static long toGas(byte[] bytes); static long toGas(... |
@Test(expected = GasCost.InvalidGasException.class) public void toGasFromLongWithNegativeLong() { GasCost.toGas(-1L); } | public static long toGas(byte[] bytes) throws InvalidGasException { if (bytes.length > 8) { return Long.MAX_VALUE; } long result = ByteUtil.byteArrayToLong(bytes); if (result < 0) { throw new InvalidGasException(bytes); } return result; } | GasCost { public static long toGas(byte[] bytes) throws InvalidGasException { if (bytes.length > 8) { return Long.MAX_VALUE; } long result = ByteUtil.byteArrayToLong(bytes); if (result < 0) { throw new InvalidGasException(bytes); } return result; } } | GasCost { public static long toGas(byte[] bytes) throws InvalidGasException { if (bytes.length > 8) { return Long.MAX_VALUE; } long result = ByteUtil.byteArrayToLong(bytes); if (result < 0) { throw new InvalidGasException(bytes); } return result; } private GasCost(); } | GasCost { public static long toGas(byte[] bytes) throws InvalidGasException { if (bytes.length > 8) { return Long.MAX_VALUE; } long result = ByteUtil.byteArrayToLong(bytes); if (result < 0) { throw new InvalidGasException(bytes); } return result; } private GasCost(); static long toGas(byte[] bytes); static long toGas(... | GasCost { public static long toGas(byte[] bytes) throws InvalidGasException { if (bytes.length > 8) { return Long.MAX_VALUE; } long result = ByteUtil.byteArrayToLong(bytes); if (result < 0) { throw new InvalidGasException(bytes); } return result; } private GasCost(); static long toGas(byte[] bytes); static long toGas(... |
@Test(expected = GasCost.InvalidGasException.class) public void toGasFromOverflowedLong() { Assert.assertEquals(Long.MAX_VALUE, GasCost.toGas(Long.MAX_VALUE + 1)); } | public static long toGas(byte[] bytes) throws InvalidGasException { if (bytes.length > 8) { return Long.MAX_VALUE; } long result = ByteUtil.byteArrayToLong(bytes); if (result < 0) { throw new InvalidGasException(bytes); } return result; } | GasCost { public static long toGas(byte[] bytes) throws InvalidGasException { if (bytes.length > 8) { return Long.MAX_VALUE; } long result = ByteUtil.byteArrayToLong(bytes); if (result < 0) { throw new InvalidGasException(bytes); } return result; } } | GasCost { public static long toGas(byte[] bytes) throws InvalidGasException { if (bytes.length > 8) { return Long.MAX_VALUE; } long result = ByteUtil.byteArrayToLong(bytes); if (result < 0) { throw new InvalidGasException(bytes); } return result; } private GasCost(); } | GasCost { public static long toGas(byte[] bytes) throws InvalidGasException { if (bytes.length > 8) { return Long.MAX_VALUE; } long result = ByteUtil.byteArrayToLong(bytes); if (result < 0) { throw new InvalidGasException(bytes); } return result; } private GasCost(); static long toGas(byte[] bytes); static long toGas(... | GasCost { public static long toGas(byte[] bytes) throws InvalidGasException { if (bytes.length > 8) { return Long.MAX_VALUE; } long result = ByteUtil.byteArrayToLong(bytes); if (result < 0) { throw new InvalidGasException(bytes); } return result; } private GasCost(); static long toGas(byte[] bytes); static long toGas(... |
@Test public void getTransactionReceipt() throws Exception { ReceiptStore receiptStore = new ReceiptStoreImpl(new HashMapDB()); World world = new World(receiptStore); Web3Impl web3 = createWeb3(world, receiptStore); Account acc1 = new AccountBuilder(world).name("acc1").balance(Coin.valueOf(2000000)).build(); Account ac... | @Override public TransactionReceiptDTO eth_getTransactionReceipt(String transactionHash) { logger.trace("eth_getTransactionReceipt({})", transactionHash); byte[] hash = stringHexToByteArray(transactionHash); TransactionInfo txInfo = receiptStore.getInMainChain(hash, blockStore); if (txInfo == null) { logger.trace("No t... | Web3Impl implements Web3 { @Override public TransactionReceiptDTO eth_getTransactionReceipt(String transactionHash) { logger.trace("eth_getTransactionReceipt({})", transactionHash); byte[] hash = stringHexToByteArray(transactionHash); TransactionInfo txInfo = receiptStore.getInMainChain(hash, blockStore); if (txInfo ==... | Web3Impl implements Web3 { @Override public TransactionReceiptDTO eth_getTransactionReceipt(String transactionHash) { logger.trace("eth_getTransactionReceipt({})", transactionHash); byte[] hash = stringHexToByteArray(transactionHash); TransactionInfo txInfo = receiptStore.getInMainChain(hash, blockStore); if (txInfo ==... | Web3Impl implements Web3 { @Override public TransactionReceiptDTO eth_getTransactionReceipt(String transactionHash) { logger.trace("eth_getTransactionReceipt({})", transactionHash); byte[] hash = stringHexToByteArray(transactionHash); TransactionInfo txInfo = receiptStore.getInMainChain(hash, blockStore); if (txInfo ==... | Web3Impl implements Web3 { @Override public TransactionReceiptDTO eth_getTransactionReceipt(String transactionHash) { logger.trace("eth_getTransactionReceipt({})", transactionHash); byte[] hash = stringHexToByteArray(transactionHash); TransactionInfo txInfo = receiptStore.getInMainChain(hash, blockStore); if (txInfo ==... |
@Test public void toGasFromLong() { Assert.assertEquals(Long.MAX_VALUE, GasCost.toGas(Long.MAX_VALUE)); Assert.assertEquals(123L, GasCost.toGas(123L)); } | public static long toGas(byte[] bytes) throws InvalidGasException { if (bytes.length > 8) { return Long.MAX_VALUE; } long result = ByteUtil.byteArrayToLong(bytes); if (result < 0) { throw new InvalidGasException(bytes); } return result; } | GasCost { public static long toGas(byte[] bytes) throws InvalidGasException { if (bytes.length > 8) { return Long.MAX_VALUE; } long result = ByteUtil.byteArrayToLong(bytes); if (result < 0) { throw new InvalidGasException(bytes); } return result; } } | GasCost { public static long toGas(byte[] bytes) throws InvalidGasException { if (bytes.length > 8) { return Long.MAX_VALUE; } long result = ByteUtil.byteArrayToLong(bytes); if (result < 0) { throw new InvalidGasException(bytes); } return result; } private GasCost(); } | GasCost { public static long toGas(byte[] bytes) throws InvalidGasException { if (bytes.length > 8) { return Long.MAX_VALUE; } long result = ByteUtil.byteArrayToLong(bytes); if (result < 0) { throw new InvalidGasException(bytes); } return result; } private GasCost(); static long toGas(byte[] bytes); static long toGas(... | GasCost { public static long toGas(byte[] bytes) throws InvalidGasException { if (bytes.length > 8) { return Long.MAX_VALUE; } long result = ByteUtil.byteArrayToLong(bytes); if (result < 0) { throw new InvalidGasException(bytes); } return result; } private GasCost(); static long toGas(byte[] bytes); static long toGas(... |
@Test public void toGasWithBigInteger() { BigInteger bi = BigInteger.valueOf(Long.MAX_VALUE - 10); Assert.assertEquals(Long.MAX_VALUE - 10, GasCost.toGas(bi)); } | public static long toGas(byte[] bytes) throws InvalidGasException { if (bytes.length > 8) { return Long.MAX_VALUE; } long result = ByteUtil.byteArrayToLong(bytes); if (result < 0) { throw new InvalidGasException(bytes); } return result; } | GasCost { public static long toGas(byte[] bytes) throws InvalidGasException { if (bytes.length > 8) { return Long.MAX_VALUE; } long result = ByteUtil.byteArrayToLong(bytes); if (result < 0) { throw new InvalidGasException(bytes); } return result; } } | GasCost { public static long toGas(byte[] bytes) throws InvalidGasException { if (bytes.length > 8) { return Long.MAX_VALUE; } long result = ByteUtil.byteArrayToLong(bytes); if (result < 0) { throw new InvalidGasException(bytes); } return result; } private GasCost(); } | GasCost { public static long toGas(byte[] bytes) throws InvalidGasException { if (bytes.length > 8) { return Long.MAX_VALUE; } long result = ByteUtil.byteArrayToLong(bytes); if (result < 0) { throw new InvalidGasException(bytes); } return result; } private GasCost(); static long toGas(byte[] bytes); static long toGas(... | GasCost { public static long toGas(byte[] bytes) throws InvalidGasException { if (bytes.length > 8) { return Long.MAX_VALUE; } long result = ByteUtil.byteArrayToLong(bytes); if (result < 0) { throw new InvalidGasException(bytes); } return result; } private GasCost(); static long toGas(byte[] bytes); static long toGas(... |
@Test(expected = GasCost.InvalidGasException.class) public void toGasWithNegativeBigInteger() { BigInteger bi = BigInteger.valueOf(-1); GasCost.toGas(bi); } | public static long toGas(byte[] bytes) throws InvalidGasException { if (bytes.length > 8) { return Long.MAX_VALUE; } long result = ByteUtil.byteArrayToLong(bytes); if (result < 0) { throw new InvalidGasException(bytes); } return result; } | GasCost { public static long toGas(byte[] bytes) throws InvalidGasException { if (bytes.length > 8) { return Long.MAX_VALUE; } long result = ByteUtil.byteArrayToLong(bytes); if (result < 0) { throw new InvalidGasException(bytes); } return result; } } | GasCost { public static long toGas(byte[] bytes) throws InvalidGasException { if (bytes.length > 8) { return Long.MAX_VALUE; } long result = ByteUtil.byteArrayToLong(bytes); if (result < 0) { throw new InvalidGasException(bytes); } return result; } private GasCost(); } | GasCost { public static long toGas(byte[] bytes) throws InvalidGasException { if (bytes.length > 8) { return Long.MAX_VALUE; } long result = ByteUtil.byteArrayToLong(bytes); if (result < 0) { throw new InvalidGasException(bytes); } return result; } private GasCost(); static long toGas(byte[] bytes); static long toGas(... | GasCost { public static long toGas(byte[] bytes) throws InvalidGasException { if (bytes.length > 8) { return Long.MAX_VALUE; } long result = ByteUtil.byteArrayToLong(bytes); if (result < 0) { throw new InvalidGasException(bytes); } return result; } private GasCost(); static long toGas(byte[] bytes); static long toGas(... |
@Test(expected = GasCost.InvalidGasException.class) public void moreNegativeBiToGas() { Assert.assertEquals(Long.MAX_VALUE, GasCost.toGas(BigInteger.valueOf(-3512))); } | public static long toGas(byte[] bytes) throws InvalidGasException { if (bytes.length > 8) { return Long.MAX_VALUE; } long result = ByteUtil.byteArrayToLong(bytes); if (result < 0) { throw new InvalidGasException(bytes); } return result; } | GasCost { public static long toGas(byte[] bytes) throws InvalidGasException { if (bytes.length > 8) { return Long.MAX_VALUE; } long result = ByteUtil.byteArrayToLong(bytes); if (result < 0) { throw new InvalidGasException(bytes); } return result; } } | GasCost { public static long toGas(byte[] bytes) throws InvalidGasException { if (bytes.length > 8) { return Long.MAX_VALUE; } long result = ByteUtil.byteArrayToLong(bytes); if (result < 0) { throw new InvalidGasException(bytes); } return result; } private GasCost(); } | GasCost { public static long toGas(byte[] bytes) throws InvalidGasException { if (bytes.length > 8) { return Long.MAX_VALUE; } long result = ByteUtil.byteArrayToLong(bytes); if (result < 0) { throw new InvalidGasException(bytes); } return result; } private GasCost(); static long toGas(byte[] bytes); static long toGas(... | GasCost { public static long toGas(byte[] bytes) throws InvalidGasException { if (bytes.length > 8) { return Long.MAX_VALUE; } long result = ByteUtil.byteArrayToLong(bytes); if (result < 0) { throw new InvalidGasException(bytes); } return result; } private GasCost(); static long toGas(byte[] bytes); static long toGas(... |
@Test(expected = GasCost.InvalidGasException.class) public void mostNegativeBiToGas() { Assert.assertEquals(Long.MAX_VALUE, GasCost.toGas(BigInteger.valueOf(-99999999999999L))); } | public static long toGas(byte[] bytes) throws InvalidGasException { if (bytes.length > 8) { return Long.MAX_VALUE; } long result = ByteUtil.byteArrayToLong(bytes); if (result < 0) { throw new InvalidGasException(bytes); } return result; } | GasCost { public static long toGas(byte[] bytes) throws InvalidGasException { if (bytes.length > 8) { return Long.MAX_VALUE; } long result = ByteUtil.byteArrayToLong(bytes); if (result < 0) { throw new InvalidGasException(bytes); } return result; } } | GasCost { public static long toGas(byte[] bytes) throws InvalidGasException { if (bytes.length > 8) { return Long.MAX_VALUE; } long result = ByteUtil.byteArrayToLong(bytes); if (result < 0) { throw new InvalidGasException(bytes); } return result; } private GasCost(); } | GasCost { public static long toGas(byte[] bytes) throws InvalidGasException { if (bytes.length > 8) { return Long.MAX_VALUE; } long result = ByteUtil.byteArrayToLong(bytes); if (result < 0) { throw new InvalidGasException(bytes); } return result; } private GasCost(); static long toGas(byte[] bytes); static long toGas(... | GasCost { public static long toGas(byte[] bytes) throws InvalidGasException { if (bytes.length > 8) { return Long.MAX_VALUE; } long result = ByteUtil.byteArrayToLong(bytes); if (result < 0) { throw new InvalidGasException(bytes); } return result; } private GasCost(); static long toGas(byte[] bytes); static long toGas(... |
@Test public void calculateAddGas() { Assert.assertEquals(1, GasCost.add(1, 0)); Assert.assertEquals(2, GasCost.add(1, 1)); Assert.assertEquals(1000000, GasCost.add(500000, 500000)); } | public static long add(long x, long y) throws InvalidGasException { if (x < 0 || y < 0) { throw new InvalidGasException(String.format("%d + %d", x, y)); } long result = x + y; if (result < 0) { return Long.MAX_VALUE; } return result; } | GasCost { public static long add(long x, long y) throws InvalidGasException { if (x < 0 || y < 0) { throw new InvalidGasException(String.format("%d + %d", x, y)); } long result = x + y; if (result < 0) { return Long.MAX_VALUE; } return result; } } | GasCost { public static long add(long x, long y) throws InvalidGasException { if (x < 0 || y < 0) { throw new InvalidGasException(String.format("%d + %d", x, y)); } long result = x + y; if (result < 0) { return Long.MAX_VALUE; } return result; } private GasCost(); } | GasCost { public static long add(long x, long y) throws InvalidGasException { if (x < 0 || y < 0) { throw new InvalidGasException(String.format("%d + %d", x, y)); } long result = x + y; if (result < 0) { return Long.MAX_VALUE; } return result; } private GasCost(); static long toGas(byte[] bytes); static long toGas(Big... | GasCost { public static long add(long x, long y) throws InvalidGasException { if (x < 0 || y < 0) { throw new InvalidGasException(String.format("%d + %d", x, y)); } long result = x + y; if (result < 0) { return Long.MAX_VALUE; } return result; } private GasCost(); static long toGas(byte[] bytes); static long toGas(Big... |
@Test public void calculateAddGasWithOverflow() { Assert.assertEquals(Long.MAX_VALUE, GasCost.add(Long.MAX_VALUE, 1)); Assert.assertEquals(Long.MAX_VALUE, GasCost.add(1, Long.MAX_VALUE)); Assert.assertEquals(Long.MAX_VALUE, GasCost.add(Long.MAX_VALUE, Long.MAX_VALUE)); } | public static long add(long x, long y) throws InvalidGasException { if (x < 0 || y < 0) { throw new InvalidGasException(String.format("%d + %d", x, y)); } long result = x + y; if (result < 0) { return Long.MAX_VALUE; } return result; } | GasCost { public static long add(long x, long y) throws InvalidGasException { if (x < 0 || y < 0) { throw new InvalidGasException(String.format("%d + %d", x, y)); } long result = x + y; if (result < 0) { return Long.MAX_VALUE; } return result; } } | GasCost { public static long add(long x, long y) throws InvalidGasException { if (x < 0 || y < 0) { throw new InvalidGasException(String.format("%d + %d", x, y)); } long result = x + y; if (result < 0) { return Long.MAX_VALUE; } return result; } private GasCost(); } | GasCost { public static long add(long x, long y) throws InvalidGasException { if (x < 0 || y < 0) { throw new InvalidGasException(String.format("%d + %d", x, y)); } long result = x + y; if (result < 0) { return Long.MAX_VALUE; } return result; } private GasCost(); static long toGas(byte[] bytes); static long toGas(Big... | GasCost { public static long add(long x, long y) throws InvalidGasException { if (x < 0 || y < 0) { throw new InvalidGasException(String.format("%d + %d", x, y)); } long result = x + y; if (result < 0) { return Long.MAX_VALUE; } return result; } private GasCost(); static long toGas(byte[] bytes); static long toGas(Big... |
@Test(expected = GasCost.InvalidGasException.class) public void calculateAddGasCostWithSecondNegativeInputAndResult() throws GasCost.InvalidGasException { GasCost.add(0, -1); } | public static long add(long x, long y) throws InvalidGasException { if (x < 0 || y < 0) { throw new InvalidGasException(String.format("%d + %d", x, y)); } long result = x + y; if (result < 0) { return Long.MAX_VALUE; } return result; } | GasCost { public static long add(long x, long y) throws InvalidGasException { if (x < 0 || y < 0) { throw new InvalidGasException(String.format("%d + %d", x, y)); } long result = x + y; if (result < 0) { return Long.MAX_VALUE; } return result; } } | GasCost { public static long add(long x, long y) throws InvalidGasException { if (x < 0 || y < 0) { throw new InvalidGasException(String.format("%d + %d", x, y)); } long result = x + y; if (result < 0) { return Long.MAX_VALUE; } return result; } private GasCost(); } | GasCost { public static long add(long x, long y) throws InvalidGasException { if (x < 0 || y < 0) { throw new InvalidGasException(String.format("%d + %d", x, y)); } long result = x + y; if (result < 0) { return Long.MAX_VALUE; } return result; } private GasCost(); static long toGas(byte[] bytes); static long toGas(Big... | GasCost { public static long add(long x, long y) throws InvalidGasException { if (x < 0 || y < 0) { throw new InvalidGasException(String.format("%d + %d", x, y)); } long result = x + y; if (result < 0) { return Long.MAX_VALUE; } return result; } private GasCost(); static long toGas(byte[] bytes); static long toGas(Big... |
@Test(expected = GasCost.InvalidGasException.class) public void calculateAddGasCostWithFirstNegativeInputAndResult() throws GasCost.InvalidGasException { GasCost.add(-1, 1); } | public static long add(long x, long y) throws InvalidGasException { if (x < 0 || y < 0) { throw new InvalidGasException(String.format("%d + %d", x, y)); } long result = x + y; if (result < 0) { return Long.MAX_VALUE; } return result; } | GasCost { public static long add(long x, long y) throws InvalidGasException { if (x < 0 || y < 0) { throw new InvalidGasException(String.format("%d + %d", x, y)); } long result = x + y; if (result < 0) { return Long.MAX_VALUE; } return result; } } | GasCost { public static long add(long x, long y) throws InvalidGasException { if (x < 0 || y < 0) { throw new InvalidGasException(String.format("%d + %d", x, y)); } long result = x + y; if (result < 0) { return Long.MAX_VALUE; } return result; } private GasCost(); } | GasCost { public static long add(long x, long y) throws InvalidGasException { if (x < 0 || y < 0) { throw new InvalidGasException(String.format("%d + %d", x, y)); } long result = x + y; if (result < 0) { return Long.MAX_VALUE; } return result; } private GasCost(); static long toGas(byte[] bytes); static long toGas(Big... | GasCost { public static long add(long x, long y) throws InvalidGasException { if (x < 0 || y < 0) { throw new InvalidGasException(String.format("%d + %d", x, y)); } long result = x + y; if (result < 0) { return Long.MAX_VALUE; } return result; } private GasCost(); static long toGas(byte[] bytes); static long toGas(Big... |
@Test public void calculateSubtractGasCost() { Assert.assertEquals(1, GasCost.subtract(1, 0)); Assert.assertEquals(0, GasCost.subtract(1, 1)); Assert.assertEquals(1000000, GasCost.subtract(1500000, 500000)); Assert.assertEquals(0, GasCost.subtract(Long.MAX_VALUE, Long.MAX_VALUE)); } | public static long subtract(long x, long y) throws InvalidGasException { if (y < 0 || y > x) { throw new InvalidGasException(String.format("%d - %d", x, y)); } return x - y; } | GasCost { public static long subtract(long x, long y) throws InvalidGasException { if (y < 0 || y > x) { throw new InvalidGasException(String.format("%d - %d", x, y)); } return x - y; } } | GasCost { public static long subtract(long x, long y) throws InvalidGasException { if (y < 0 || y > x) { throw new InvalidGasException(String.format("%d - %d", x, y)); } return x - y; } private GasCost(); } | GasCost { public static long subtract(long x, long y) throws InvalidGasException { if (y < 0 || y > x) { throw new InvalidGasException(String.format("%d - %d", x, y)); } return x - y; } private GasCost(); static long toGas(byte[] bytes); static long toGas(BigInteger big); static long toGas(long number); static long ad... | GasCost { public static long subtract(long x, long y) throws InvalidGasException { if (y < 0 || y > x) { throw new InvalidGasException(String.format("%d - %d", x, y)); } return x - y; } private GasCost(); static long toGas(byte[] bytes); static long toGas(BigInteger big); static long toGas(long number); static long ad... |
@Test public void getTransactionReceiptNotInMainBlockchain() throws Exception { ReceiptStore receiptStore = new ReceiptStoreImpl(new HashMapDB()); World world = new World(receiptStore); Web3Impl web3 = createWeb3(world, receiptStore); Account acc1 = new AccountBuilder(world).name("acc1").balance(Coin.valueOf(2000000)).... | @Override public TransactionReceiptDTO eth_getTransactionReceipt(String transactionHash) { logger.trace("eth_getTransactionReceipt({})", transactionHash); byte[] hash = stringHexToByteArray(transactionHash); TransactionInfo txInfo = receiptStore.getInMainChain(hash, blockStore); if (txInfo == null) { logger.trace("No t... | Web3Impl implements Web3 { @Override public TransactionReceiptDTO eth_getTransactionReceipt(String transactionHash) { logger.trace("eth_getTransactionReceipt({})", transactionHash); byte[] hash = stringHexToByteArray(transactionHash); TransactionInfo txInfo = receiptStore.getInMainChain(hash, blockStore); if (txInfo ==... | Web3Impl implements Web3 { @Override public TransactionReceiptDTO eth_getTransactionReceipt(String transactionHash) { logger.trace("eth_getTransactionReceipt({})", transactionHash); byte[] hash = stringHexToByteArray(transactionHash); TransactionInfo txInfo = receiptStore.getInMainChain(hash, blockStore); if (txInfo ==... | Web3Impl implements Web3 { @Override public TransactionReceiptDTO eth_getTransactionReceipt(String transactionHash) { logger.trace("eth_getTransactionReceipt({})", transactionHash); byte[] hash = stringHexToByteArray(transactionHash); TransactionInfo txInfo = receiptStore.getInMainChain(hash, blockStore); if (txInfo ==... | Web3Impl implements Web3 { @Override public TransactionReceiptDTO eth_getTransactionReceipt(String transactionHash) { logger.trace("eth_getTransactionReceipt({})", transactionHash); byte[] hash = stringHexToByteArray(transactionHash); TransactionInfo txInfo = receiptStore.getInMainChain(hash, blockStore); if (txInfo ==... |
@Test(expected = GasCost.InvalidGasException.class) public void calculateSubtractWithNegativeInput() throws GasCost.InvalidGasException { GasCost.subtract(1, -1); } | public static long subtract(long x, long y) throws InvalidGasException { if (y < 0 || y > x) { throw new InvalidGasException(String.format("%d - %d", x, y)); } return x - y; } | GasCost { public static long subtract(long x, long y) throws InvalidGasException { if (y < 0 || y > x) { throw new InvalidGasException(String.format("%d - %d", x, y)); } return x - y; } } | GasCost { public static long subtract(long x, long y) throws InvalidGasException { if (y < 0 || y > x) { throw new InvalidGasException(String.format("%d - %d", x, y)); } return x - y; } private GasCost(); } | GasCost { public static long subtract(long x, long y) throws InvalidGasException { if (y < 0 || y > x) { throw new InvalidGasException(String.format("%d - %d", x, y)); } return x - y; } private GasCost(); static long toGas(byte[] bytes); static long toGas(BigInteger big); static long toGas(long number); static long ad... | GasCost { public static long subtract(long x, long y) throws InvalidGasException { if (y < 0 || y > x) { throw new InvalidGasException(String.format("%d - %d", x, y)); } return x - y; } private GasCost(); static long toGas(byte[] bytes); static long toGas(BigInteger big); static long toGas(long number); static long ad... |
@Test(expected = GasCost.InvalidGasException.class) public void calculateSubtractWithExtremelyNegativeResult() throws GasCost.InvalidGasException { GasCost.subtract(0, Long.MAX_VALUE); } | public static long subtract(long x, long y) throws InvalidGasException { if (y < 0 || y > x) { throw new InvalidGasException(String.format("%d - %d", x, y)); } return x - y; } | GasCost { public static long subtract(long x, long y) throws InvalidGasException { if (y < 0 || y > x) { throw new InvalidGasException(String.format("%d - %d", x, y)); } return x - y; } } | GasCost { public static long subtract(long x, long y) throws InvalidGasException { if (y < 0 || y > x) { throw new InvalidGasException(String.format("%d - %d", x, y)); } return x - y; } private GasCost(); } | GasCost { public static long subtract(long x, long y) throws InvalidGasException { if (y < 0 || y > x) { throw new InvalidGasException(String.format("%d - %d", x, y)); } return x - y; } private GasCost(); static long toGas(byte[] bytes); static long toGas(BigInteger big); static long toGas(long number); static long ad... | GasCost { public static long subtract(long x, long y) throws InvalidGasException { if (y < 0 || y > x) { throw new InvalidGasException(String.format("%d - %d", x, y)); } return x - y; } private GasCost(); static long toGas(byte[] bytes); static long toGas(BigInteger big); static long toGas(long number); static long ad... |
@Test(expected = GasCost.InvalidGasException.class) public void calculateSubtractGasToInvalidSubtle() throws GasCost.InvalidGasException { GasCost.subtract(1, 2); } | public static long subtract(long x, long y) throws InvalidGasException { if (y < 0 || y > x) { throw new InvalidGasException(String.format("%d - %d", x, y)); } return x - y; } | GasCost { public static long subtract(long x, long y) throws InvalidGasException { if (y < 0 || y > x) { throw new InvalidGasException(String.format("%d - %d", x, y)); } return x - y; } } | GasCost { public static long subtract(long x, long y) throws InvalidGasException { if (y < 0 || y > x) { throw new InvalidGasException(String.format("%d - %d", x, y)); } return x - y; } private GasCost(); } | GasCost { public static long subtract(long x, long y) throws InvalidGasException { if (y < 0 || y > x) { throw new InvalidGasException(String.format("%d - %d", x, y)); } return x - y; } private GasCost(); static long toGas(byte[] bytes); static long toGas(BigInteger big); static long toGas(long number); static long ad... | GasCost { public static long subtract(long x, long y) throws InvalidGasException { if (y < 0 || y > x) { throw new InvalidGasException(String.format("%d - %d", x, y)); } return x - y; } private GasCost(); static long toGas(byte[] bytes); static long toGas(BigInteger big); static long toGas(long number); static long ad... |
@Test(expected = GasCost.InvalidGasException.class) public void calculateSubtractGasToInvalidObvious() throws GasCost.InvalidGasException { GasCost.subtract(1, 159); } | public static long subtract(long x, long y) throws InvalidGasException { if (y < 0 || y > x) { throw new InvalidGasException(String.format("%d - %d", x, y)); } return x - y; } | GasCost { public static long subtract(long x, long y) throws InvalidGasException { if (y < 0 || y > x) { throw new InvalidGasException(String.format("%d - %d", x, y)); } return x - y; } } | GasCost { public static long subtract(long x, long y) throws InvalidGasException { if (y < 0 || y > x) { throw new InvalidGasException(String.format("%d - %d", x, y)); } return x - y; } private GasCost(); } | GasCost { public static long subtract(long x, long y) throws InvalidGasException { if (y < 0 || y > x) { throw new InvalidGasException(String.format("%d - %d", x, y)); } return x - y; } private GasCost(); static long toGas(byte[] bytes); static long toGas(BigInteger big); static long toGas(long number); static long ad... | GasCost { public static long subtract(long x, long y) throws InvalidGasException { if (y < 0 || y > x) { throw new InvalidGasException(String.format("%d - %d", x, y)); } return x - y; } private GasCost(); static long toGas(byte[] bytes); static long toGas(BigInteger big); static long toGas(long number); static long ad... |
@Test(expected = GasCost.InvalidGasException.class) public void multiplyWithNegativeValues() throws GasCost.InvalidGasException { GasCost.multiply(-1, -2); } | public static long multiply(long x, long y) throws InvalidGasException { if (x < 0 || y < 0) { throw new InvalidGasException(String.format("%d * %d", x, y)); } long result = x * y; if (multiplicationOverflowed(x, y, result)) { return Long.MAX_VALUE; } return result; } | GasCost { public static long multiply(long x, long y) throws InvalidGasException { if (x < 0 || y < 0) { throw new InvalidGasException(String.format("%d * %d", x, y)); } long result = x * y; if (multiplicationOverflowed(x, y, result)) { return Long.MAX_VALUE; } return result; } } | GasCost { public static long multiply(long x, long y) throws InvalidGasException { if (x < 0 || y < 0) { throw new InvalidGasException(String.format("%d * %d", x, y)); } long result = x * y; if (multiplicationOverflowed(x, y, result)) { return Long.MAX_VALUE; } return result; } private GasCost(); } | GasCost { public static long multiply(long x, long y) throws InvalidGasException { if (x < 0 || y < 0) { throw new InvalidGasException(String.format("%d * %d", x, y)); } long result = x * y; if (multiplicationOverflowed(x, y, result)) { return Long.MAX_VALUE; } return result; } private GasCost(); static long toGas(byt... | GasCost { public static long multiply(long x, long y) throws InvalidGasException { if (x < 0 || y < 0) { throw new InvalidGasException(String.format("%d * %d", x, y)); } long result = x * y; if (multiplicationOverflowed(x, y, result)) { return Long.MAX_VALUE; } return result; } private GasCost(); static long toGas(byt... |
@Test(expected = GasCost.InvalidGasException.class) public void multiplyWithXNegative() throws GasCost.InvalidGasException { GasCost.multiply(-1, 123); } | public static long multiply(long x, long y) throws InvalidGasException { if (x < 0 || y < 0) { throw new InvalidGasException(String.format("%d * %d", x, y)); } long result = x * y; if (multiplicationOverflowed(x, y, result)) { return Long.MAX_VALUE; } return result; } | GasCost { public static long multiply(long x, long y) throws InvalidGasException { if (x < 0 || y < 0) { throw new InvalidGasException(String.format("%d * %d", x, y)); } long result = x * y; if (multiplicationOverflowed(x, y, result)) { return Long.MAX_VALUE; } return result; } } | GasCost { public static long multiply(long x, long y) throws InvalidGasException { if (x < 0 || y < 0) { throw new InvalidGasException(String.format("%d * %d", x, y)); } long result = x * y; if (multiplicationOverflowed(x, y, result)) { return Long.MAX_VALUE; } return result; } private GasCost(); } | GasCost { public static long multiply(long x, long y) throws InvalidGasException { if (x < 0 || y < 0) { throw new InvalidGasException(String.format("%d * %d", x, y)); } long result = x * y; if (multiplicationOverflowed(x, y, result)) { return Long.MAX_VALUE; } return result; } private GasCost(); static long toGas(byt... | GasCost { public static long multiply(long x, long y) throws InvalidGasException { if (x < 0 || y < 0) { throw new InvalidGasException(String.format("%d * %d", x, y)); } long result = x * y; if (multiplicationOverflowed(x, y, result)) { return Long.MAX_VALUE; } return result; } private GasCost(); static long toGas(byt... |
@Test(expected = GasCost.InvalidGasException.class) public void multiplyWithYNegative() throws GasCost.InvalidGasException { GasCost.multiply(1, -9123); } | public static long multiply(long x, long y) throws InvalidGasException { if (x < 0 || y < 0) { throw new InvalidGasException(String.format("%d * %d", x, y)); } long result = x * y; if (multiplicationOverflowed(x, y, result)) { return Long.MAX_VALUE; } return result; } | GasCost { public static long multiply(long x, long y) throws InvalidGasException { if (x < 0 || y < 0) { throw new InvalidGasException(String.format("%d * %d", x, y)); } long result = x * y; if (multiplicationOverflowed(x, y, result)) { return Long.MAX_VALUE; } return result; } } | GasCost { public static long multiply(long x, long y) throws InvalidGasException { if (x < 0 || y < 0) { throw new InvalidGasException(String.format("%d * %d", x, y)); } long result = x * y; if (multiplicationOverflowed(x, y, result)) { return Long.MAX_VALUE; } return result; } private GasCost(); } | GasCost { public static long multiply(long x, long y) throws InvalidGasException { if (x < 0 || y < 0) { throw new InvalidGasException(String.format("%d * %d", x, y)); } long result = x * y; if (multiplicationOverflowed(x, y, result)) { return Long.MAX_VALUE; } return result; } private GasCost(); static long toGas(byt... | GasCost { public static long multiply(long x, long y) throws InvalidGasException { if (x < 0 || y < 0) { throw new InvalidGasException(String.format("%d * %d", x, y)); } long result = x * y; if (multiplicationOverflowed(x, y, result)) { return Long.MAX_VALUE; } return result; } private GasCost(); static long toGas(byt... |
@Test public void multiply() { long x = (long) Math.pow(2, 62); long y = (long) Math.pow(2, 12); long overflowed = GasCost.multiply(x, y); Assert.assertEquals("overflowed is coverted to max gas", Long.MAX_VALUE, overflowed); } | public static long multiply(long x, long y) throws InvalidGasException { if (x < 0 || y < 0) { throw new InvalidGasException(String.format("%d * %d", x, y)); } long result = x * y; if (multiplicationOverflowed(x, y, result)) { return Long.MAX_VALUE; } return result; } | GasCost { public static long multiply(long x, long y) throws InvalidGasException { if (x < 0 || y < 0) { throw new InvalidGasException(String.format("%d * %d", x, y)); } long result = x * y; if (multiplicationOverflowed(x, y, result)) { return Long.MAX_VALUE; } return result; } } | GasCost { public static long multiply(long x, long y) throws InvalidGasException { if (x < 0 || y < 0) { throw new InvalidGasException(String.format("%d * %d", x, y)); } long result = x * y; if (multiplicationOverflowed(x, y, result)) { return Long.MAX_VALUE; } return result; } private GasCost(); } | GasCost { public static long multiply(long x, long y) throws InvalidGasException { if (x < 0 || y < 0) { throw new InvalidGasException(String.format("%d * %d", x, y)); } long result = x * y; if (multiplicationOverflowed(x, y, result)) { return Long.MAX_VALUE; } return result; } private GasCost(); static long toGas(byt... | GasCost { public static long multiply(long x, long y) throws InvalidGasException { if (x < 0 || y < 0) { throw new InvalidGasException(String.format("%d * %d", x, y)); } long result = x * y; if (multiplicationOverflowed(x, y, result)) { return Long.MAX_VALUE; } return result; } private GasCost(); static long toGas(byt... |
@Test public void multiplyOverflowing() throws GasCost.InvalidGasException { Assert.assertEquals(Long.MAX_VALUE, GasCost.multiply(4611686018427387903L, 4096L)); } | public static long multiply(long x, long y) throws InvalidGasException { if (x < 0 || y < 0) { throw new InvalidGasException(String.format("%d * %d", x, y)); } long result = x * y; if (multiplicationOverflowed(x, y, result)) { return Long.MAX_VALUE; } return result; } | GasCost { public static long multiply(long x, long y) throws InvalidGasException { if (x < 0 || y < 0) { throw new InvalidGasException(String.format("%d * %d", x, y)); } long result = x * y; if (multiplicationOverflowed(x, y, result)) { return Long.MAX_VALUE; } return result; } } | GasCost { public static long multiply(long x, long y) throws InvalidGasException { if (x < 0 || y < 0) { throw new InvalidGasException(String.format("%d * %d", x, y)); } long result = x * y; if (multiplicationOverflowed(x, y, result)) { return Long.MAX_VALUE; } return result; } private GasCost(); } | GasCost { public static long multiply(long x, long y) throws InvalidGasException { if (x < 0 || y < 0) { throw new InvalidGasException(String.format("%d * %d", x, y)); } long result = x * y; if (multiplicationOverflowed(x, y, result)) { return Long.MAX_VALUE; } return result; } private GasCost(); static long toGas(byt... | GasCost { public static long multiply(long x, long y) throws InvalidGasException { if (x < 0 || y < 0) { throw new InvalidGasException(String.format("%d * %d", x, y)); } long result = x * y; if (multiplicationOverflowed(x, y, result)) { return Long.MAX_VALUE; } return result; } private GasCost(); static long toGas(byt... |
@Test(expected = GasCost.InvalidGasException.class) public void multiplyWithNegativeInput() throws GasCost.InvalidGasException { GasCost.multiply(1, -9123); } | public static long multiply(long x, long y) throws InvalidGasException { if (x < 0 || y < 0) { throw new InvalidGasException(String.format("%d * %d", x, y)); } long result = x * y; if (multiplicationOverflowed(x, y, result)) { return Long.MAX_VALUE; } return result; } | GasCost { public static long multiply(long x, long y) throws InvalidGasException { if (x < 0 || y < 0) { throw new InvalidGasException(String.format("%d * %d", x, y)); } long result = x * y; if (multiplicationOverflowed(x, y, result)) { return Long.MAX_VALUE; } return result; } } | GasCost { public static long multiply(long x, long y) throws InvalidGasException { if (x < 0 || y < 0) { throw new InvalidGasException(String.format("%d * %d", x, y)); } long result = x * y; if (multiplicationOverflowed(x, y, result)) { return Long.MAX_VALUE; } return result; } private GasCost(); } | GasCost { public static long multiply(long x, long y) throws InvalidGasException { if (x < 0 || y < 0) { throw new InvalidGasException(String.format("%d * %d", x, y)); } long result = x * y; if (multiplicationOverflowed(x, y, result)) { return Long.MAX_VALUE; } return result; } private GasCost(); static long toGas(byt... | GasCost { public static long multiply(long x, long y) throws InvalidGasException { if (x < 0 || y < 0) { throw new InvalidGasException(String.format("%d * %d", x, y)); } long result = x * y; if (multiplicationOverflowed(x, y, result)) { return Long.MAX_VALUE; } return result; } private GasCost(); static long toGas(byt... |
@Test public void getTransactionByHash() throws Exception { ReceiptStore receiptStore = new ReceiptStoreImpl(new HashMapDB()); World world = new World(receiptStore); Web3Impl web3 = createWeb3(world, receiptStore); Account acc1 = new AccountBuilder(world).name("acc1").balance(Coin.valueOf(2000000)).build(); Account acc... | @Override public TransactionResultDTO eth_getTransactionByHash(String transactionHash) { TransactionResultDTO s = null; try { Keccak256 txHash = new Keccak256(stringHexToByteArray(transactionHash)); Block block = null; TransactionInfo txInfo = this.receiptStore.getInMainChain(txHash.getBytes(), blockStore); if (txInfo ... | Web3Impl implements Web3 { @Override public TransactionResultDTO eth_getTransactionByHash(String transactionHash) { TransactionResultDTO s = null; try { Keccak256 txHash = new Keccak256(stringHexToByteArray(transactionHash)); Block block = null; TransactionInfo txInfo = this.receiptStore.getInMainChain(txHash.getBytes(... | Web3Impl implements Web3 { @Override public TransactionResultDTO eth_getTransactionByHash(String transactionHash) { TransactionResultDTO s = null; try { Keccak256 txHash = new Keccak256(stringHexToByteArray(transactionHash)); Block block = null; TransactionInfo txInfo = this.receiptStore.getInMainChain(txHash.getBytes(... | Web3Impl implements Web3 { @Override public TransactionResultDTO eth_getTransactionByHash(String transactionHash) { TransactionResultDTO s = null; try { Keccak256 txHash = new Keccak256(stringHexToByteArray(transactionHash)); Block block = null; TransactionInfo txInfo = this.receiptStore.getInMainChain(txHash.getBytes(... | Web3Impl implements Web3 { @Override public TransactionResultDTO eth_getTransactionByHash(String transactionHash) { TransactionResultDTO s = null; try { Keccak256 txHash = new Keccak256(stringHexToByteArray(transactionHash)); Block block = null; TransactionInfo txInfo = this.receiptStore.getInMainChain(txHash.getBytes(... |
@Test public void calculateGasCost() throws GasCost.InvalidGasException { Assert.assertEquals(1, GasCost.calculateTotal(1, 0, 0)); Assert.assertEquals(2, GasCost.calculateTotal(0, 2, 1)); Assert.assertEquals(7, GasCost.calculateTotal(1, 2, 3)); Assert.assertEquals(10, GasCost.calculateTotal(4, 3, 2)); Assert.assertEqua... | public static long calculateTotal(long baseCost, long unitCost, long units) throws InvalidGasException { if (baseCost < 0 || unitCost < 0 || units < 0) { throw new InvalidGasException(String.format("%d + %d * %d", baseCost, unitCost, units)); } long mult = unitCost * units; if (multiplicationOverflowed(unitCost, units,... | GasCost { public static long calculateTotal(long baseCost, long unitCost, long units) throws InvalidGasException { if (baseCost < 0 || unitCost < 0 || units < 0) { throw new InvalidGasException(String.format("%d + %d * %d", baseCost, unitCost, units)); } long mult = unitCost * units; if (multiplicationOverflowed(unitCo... | GasCost { public static long calculateTotal(long baseCost, long unitCost, long units) throws InvalidGasException { if (baseCost < 0 || unitCost < 0 || units < 0) { throw new InvalidGasException(String.format("%d + %d * %d", baseCost, unitCost, units)); } long mult = unitCost * units; if (multiplicationOverflowed(unitCo... | GasCost { public static long calculateTotal(long baseCost, long unitCost, long units) throws InvalidGasException { if (baseCost < 0 || unitCost < 0 || units < 0) { throw new InvalidGasException(String.format("%d + %d * %d", baseCost, unitCost, units)); } long mult = unitCost * units; if (multiplicationOverflowed(unitCo... | GasCost { public static long calculateTotal(long baseCost, long unitCost, long units) throws InvalidGasException { if (baseCost < 0 || unitCost < 0 || units < 0) { throw new InvalidGasException(String.format("%d + %d * %d", baseCost, unitCost, units)); } long mult = unitCost * units; if (multiplicationOverflowed(unitCo... |
@Test(expected = GasCost.InvalidGasException.class) public void calculateGasCostWithNegativeSecondInputs() throws GasCost.InvalidGasException { GasCost.calculateTotal(1, -1, 1); } | public static long calculateTotal(long baseCost, long unitCost, long units) throws InvalidGasException { if (baseCost < 0 || unitCost < 0 || units < 0) { throw new InvalidGasException(String.format("%d + %d * %d", baseCost, unitCost, units)); } long mult = unitCost * units; if (multiplicationOverflowed(unitCost, units,... | GasCost { public static long calculateTotal(long baseCost, long unitCost, long units) throws InvalidGasException { if (baseCost < 0 || unitCost < 0 || units < 0) { throw new InvalidGasException(String.format("%d + %d * %d", baseCost, unitCost, units)); } long mult = unitCost * units; if (multiplicationOverflowed(unitCo... | GasCost { public static long calculateTotal(long baseCost, long unitCost, long units) throws InvalidGasException { if (baseCost < 0 || unitCost < 0 || units < 0) { throw new InvalidGasException(String.format("%d + %d * %d", baseCost, unitCost, units)); } long mult = unitCost * units; if (multiplicationOverflowed(unitCo... | GasCost { public static long calculateTotal(long baseCost, long unitCost, long units) throws InvalidGasException { if (baseCost < 0 || unitCost < 0 || units < 0) { throw new InvalidGasException(String.format("%d + %d * %d", baseCost, unitCost, units)); } long mult = unitCost * units; if (multiplicationOverflowed(unitCo... | GasCost { public static long calculateTotal(long baseCost, long unitCost, long units) throws InvalidGasException { if (baseCost < 0 || unitCost < 0 || units < 0) { throw new InvalidGasException(String.format("%d + %d * %d", baseCost, unitCost, units)); } long mult = unitCost * units; if (multiplicationOverflowed(unitCo... |
@Test(expected = GasCost.InvalidGasException.class) public void calculateGasCostWithNegativeFirstInput() throws GasCost.InvalidGasException { GasCost.calculateTotal(-1, 1, 1); } | public static long calculateTotal(long baseCost, long unitCost, long units) throws InvalidGasException { if (baseCost < 0 || unitCost < 0 || units < 0) { throw new InvalidGasException(String.format("%d + %d * %d", baseCost, unitCost, units)); } long mult = unitCost * units; if (multiplicationOverflowed(unitCost, units,... | GasCost { public static long calculateTotal(long baseCost, long unitCost, long units) throws InvalidGasException { if (baseCost < 0 || unitCost < 0 || units < 0) { throw new InvalidGasException(String.format("%d + %d * %d", baseCost, unitCost, units)); } long mult = unitCost * units; if (multiplicationOverflowed(unitCo... | GasCost { public static long calculateTotal(long baseCost, long unitCost, long units) throws InvalidGasException { if (baseCost < 0 || unitCost < 0 || units < 0) { throw new InvalidGasException(String.format("%d + %d * %d", baseCost, unitCost, units)); } long mult = unitCost * units; if (multiplicationOverflowed(unitCo... | GasCost { public static long calculateTotal(long baseCost, long unitCost, long units) throws InvalidGasException { if (baseCost < 0 || unitCost < 0 || units < 0) { throw new InvalidGasException(String.format("%d + %d * %d", baseCost, unitCost, units)); } long mult = unitCost * units; if (multiplicationOverflowed(unitCo... | GasCost { public static long calculateTotal(long baseCost, long unitCost, long units) throws InvalidGasException { if (baseCost < 0 || unitCost < 0 || units < 0) { throw new InvalidGasException(String.format("%d + %d * %d", baseCost, unitCost, units)); } long mult = unitCost * units; if (multiplicationOverflowed(unitCo... |
@Test(expected = GasCost.InvalidGasException.class) public void calculateGasCostWithNegativeThirdInput() throws GasCost.InvalidGasException { GasCost.calculateTotal(1, 1, -1); } | public static long calculateTotal(long baseCost, long unitCost, long units) throws InvalidGasException { if (baseCost < 0 || unitCost < 0 || units < 0) { throw new InvalidGasException(String.format("%d + %d * %d", baseCost, unitCost, units)); } long mult = unitCost * units; if (multiplicationOverflowed(unitCost, units,... | GasCost { public static long calculateTotal(long baseCost, long unitCost, long units) throws InvalidGasException { if (baseCost < 0 || unitCost < 0 || units < 0) { throw new InvalidGasException(String.format("%d + %d * %d", baseCost, unitCost, units)); } long mult = unitCost * units; if (multiplicationOverflowed(unitCo... | GasCost { public static long calculateTotal(long baseCost, long unitCost, long units) throws InvalidGasException { if (baseCost < 0 || unitCost < 0 || units < 0) { throw new InvalidGasException(String.format("%d + %d * %d", baseCost, unitCost, units)); } long mult = unitCost * units; if (multiplicationOverflowed(unitCo... | GasCost { public static long calculateTotal(long baseCost, long unitCost, long units) throws InvalidGasException { if (baseCost < 0 || unitCost < 0 || units < 0) { throw new InvalidGasException(String.format("%d + %d * %d", baseCost, unitCost, units)); } long mult = unitCost * units; if (multiplicationOverflowed(unitCo... | GasCost { public static long calculateTotal(long baseCost, long unitCost, long units) throws InvalidGasException { if (baseCost < 0 || unitCost < 0 || units < 0) { throw new InvalidGasException(String.format("%d + %d * %d", baseCost, unitCost, units)); } long mult = unitCost * units; if (multiplicationOverflowed(unitCo... |
@Test public void calculateGasCostBeyondMaxGas() throws GasCost.InvalidGasException { Assert.assertEquals(Long.MAX_VALUE, GasCost.calculateTotal(1, Long.MAX_VALUE, 1)); Assert.assertEquals(Long.MAX_VALUE, GasCost.calculateTotal(1, Long.MAX_VALUE, 1)); Assert.assertEquals(Long.MAX_VALUE, GasCost.calculateTotal(Long.MAX_... | public static long calculateTotal(long baseCost, long unitCost, long units) throws InvalidGasException { if (baseCost < 0 || unitCost < 0 || units < 0) { throw new InvalidGasException(String.format("%d + %d * %d", baseCost, unitCost, units)); } long mult = unitCost * units; if (multiplicationOverflowed(unitCost, units,... | GasCost { public static long calculateTotal(long baseCost, long unitCost, long units) throws InvalidGasException { if (baseCost < 0 || unitCost < 0 || units < 0) { throw new InvalidGasException(String.format("%d + %d * %d", baseCost, unitCost, units)); } long mult = unitCost * units; if (multiplicationOverflowed(unitCo... | GasCost { public static long calculateTotal(long baseCost, long unitCost, long units) throws InvalidGasException { if (baseCost < 0 || unitCost < 0 || units < 0) { throw new InvalidGasException(String.format("%d + %d * %d", baseCost, unitCost, units)); } long mult = unitCost * units; if (multiplicationOverflowed(unitCo... | GasCost { public static long calculateTotal(long baseCost, long unitCost, long units) throws InvalidGasException { if (baseCost < 0 || unitCost < 0 || units < 0) { throw new InvalidGasException(String.format("%d + %d * %d", baseCost, unitCost, units)); } long mult = unitCost * units; if (multiplicationOverflowed(unitCo... | GasCost { public static long calculateTotal(long baseCost, long unitCost, long units) throws InvalidGasException { if (baseCost < 0 || unitCost < 0 || units < 0) { throw new InvalidGasException(String.format("%d + %d * %d", baseCost, unitCost, units)); } long mult = unitCost * units; if (multiplicationOverflowed(unitCo... |
@Test public void testAdd() { byte[] three = new byte[32]; for (int i = 0; i < three.length; i++) { three[i] = (byte) 0xff; } DataWord x = DataWord.valueOf(three); byte[] xdata = x.getData(); DataWord result = x.add(DataWord.valueOf(three)); assertArrayEquals(xdata, x.getData()); assertEquals(32, result.getData().lengt... | public DataWord add(DataWord word) { byte[] newdata = new byte[BYTES]; for (int i = 31, overflow = 0; i >= 0; i--) { int v = (this.data[i] & 0xff) + (word.data[i] & 0xff) + overflow; newdata[i] = (byte) v; overflow = v >>> 8; } return new DataWord(newdata); } | DataWord implements Comparable<DataWord> { public DataWord add(DataWord word) { byte[] newdata = new byte[BYTES]; for (int i = 31, overflow = 0; i >= 0; i--) { int v = (this.data[i] & 0xff) + (word.data[i] & 0xff) + overflow; newdata[i] = (byte) v; overflow = v >>> 8; } return new DataWord(newdata); } } | DataWord implements Comparable<DataWord> { public DataWord add(DataWord word) { byte[] newdata = new byte[BYTES]; for (int i = 31, overflow = 0; i >= 0; i--) { int v = (this.data[i] & 0xff) + (word.data[i] & 0xff) + overflow; newdata[i] = (byte) v; overflow = v >>> 8; } return new DataWord(newdata); } private DataWord... | DataWord implements Comparable<DataWord> { public DataWord add(DataWord word) { byte[] newdata = new byte[BYTES]; for (int i = 31, overflow = 0; i >= 0; i--) { int v = (this.data[i] & 0xff) + (word.data[i] & 0xff) + overflow; newdata[i] = (byte) v; overflow = v >>> 8; } return new DataWord(newdata); } private DataWord... | DataWord implements Comparable<DataWord> { public DataWord add(DataWord word) { byte[] newdata = new byte[BYTES]; for (int i = 31, overflow = 0; i >= 0; i--) { int v = (this.data[i] & 0xff) + (word.data[i] & 0xff) + overflow; newdata[i] = (byte) v; overflow = v >>> 8; } return new DataWord(newdata); } private DataWord... |
@Test public void testMod() { String expected = "000000000000000000000000000000000000000000000000000000000000001a"; byte[] one = new byte[32]; one[31] = 0x1e; byte[] two = new byte[32]; for (int i = 0; i < two.length; i++) { two[i] = (byte) 0xff; } two[31] = 0x56; DataWord x = DataWord.valueOf(one); byte[] xdata = x.ge... | public DataWord mod(DataWord word) { if (word.isZero()) { return DataWord.ZERO; } BigInteger result = value().mod(word.value()); return valueOf(result.and(MAX_VALUE)); } | DataWord implements Comparable<DataWord> { public DataWord mod(DataWord word) { if (word.isZero()) { return DataWord.ZERO; } BigInteger result = value().mod(word.value()); return valueOf(result.and(MAX_VALUE)); } } | DataWord implements Comparable<DataWord> { public DataWord mod(DataWord word) { if (word.isZero()) { return DataWord.ZERO; } BigInteger result = value().mod(word.value()); return valueOf(result.and(MAX_VALUE)); } private DataWord(byte[] data); } | DataWord implements Comparable<DataWord> { public DataWord mod(DataWord word) { if (word.isZero()) { return DataWord.ZERO; } BigInteger result = value().mod(word.value()); return valueOf(result.and(MAX_VALUE)); } private DataWord(byte[] data); byte[] getData(); byte[] getNoLeadZeroesData(); byte[] getByteArrayForStora... | DataWord implements Comparable<DataWord> { public DataWord mod(DataWord word) { if (word.isZero()) { return DataWord.ZERO; } BigInteger result = value().mod(word.value()); return valueOf(result.and(MAX_VALUE)); } private DataWord(byte[] data); byte[] getData(); byte[] getNoLeadZeroesData(); byte[] getByteArrayForStora... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.