use of org.ethereum.core.Bloom in project rskj by rsksmart.
the class BlockStoreTest method saveHeader.
@Test
public void saveHeader() {
BlockStore store = new BlockStore();
BlockHeader blockHeader = new BlockHeader(new byte[] {}, new byte[] {}, RskAddress.nullAddress().getBytes(), new Bloom().getData(), new byte[] {}, 1, new byte[] {}, 0, 0, new byte[] {}, new byte[] {}, new byte[] {}, new byte[] {}, new byte[] {}, 0);
store.saveHeader(blockHeader);
Assert.assertTrue(store.hasHeader(blockHeader.getHash()));
}
use of org.ethereum.core.Bloom in project rskj by rsksmart.
the class AddressesTopicsFilterTest method noMatchEmptyBloomWithFilterWithAccount.
@Test
public void noMatchEmptyBloomWithFilterWithAccount() {
Account account = new AccountBuilder().name("account").build();
RskAddress address = account.getAddress();
AddressesTopicsFilter filter = new AddressesTopicsFilter(new RskAddress[] { address }, null);
Assert.assertFalse(filter.matchBloom(new Bloom()));
}
use of org.ethereum.core.Bloom in project rskj by rsksmart.
the class BlockEncodingTest method testBadBlockEncoding1.
@Test(expected = ArithmeticException.class)
public void testBadBlockEncoding1() {
List<Transaction> txs = new ArrayList<>();
Transaction tx = new Transaction(BigInteger.ZERO.toByteArray(), BigInteger.ONE.toByteArray(), BigInteger.valueOf(21000).toByteArray(), new ECKey().getAddress(), BigInteger.valueOf(1000).toByteArray(), null);
txs.add(tx);
byte[] bigBadByteArray = new byte[10000];
Arrays.fill(bigBadByteArray, (byte) -1);
FreeBlock fblock = new FreeBlock(// parent hash
PegTestUtils.createHash3().getBytes(), // uncle hash
EMPTY_LIST_HASH, // coinbase
TestUtils.randomAddress().getBytes(), // logs bloom
new Bloom().getData(), // difficulty
BigInteger.ONE.toByteArray(), bigBadByteArray, // gasLimit
bigBadByteArray, // gasUsed
bigBadByteArray, // timestamp
bigBadByteArray, // extraData
new byte[0], // mixHash
new byte[0], // provisory nonce
new byte[] { 0 }, // receipts root
HashUtil.EMPTY_TRIE_HASH, // transaction root
BlockChainImpl.calcTxTrie(txs), // EMPTY_TRIE_HASH, // state root
HashUtil.EMPTY_TRIE_HASH, // transaction list
txs, // uncle list
null, BigInteger.TEN.toByteArray(), new byte[0]);
// Now decode, and re-encode
Block parsedBlock = new Block(fblock.getEncoded());
// must throw java.lang.ArithmeticException
// forced parse
parsedBlock.getGasLimit();
}
use of org.ethereum.core.Bloom in project rskj by rsksmart.
the class BlockStoreTest method removeHeader.
@Test
public void removeHeader() {
BlockStore store = new BlockStore();
BlockHeader blockHeader = new BlockHeader(new byte[] {}, new byte[] {}, RskAddress.nullAddress().getBytes(), new Bloom().getData(), new byte[] {}, 1, new byte[] {}, 0, 0, new byte[] {}, new byte[] {}, new byte[] {}, new byte[] {}, new byte[] {}, 0);
store.saveHeader(blockHeader);
store.removeHeader(blockHeader);
Assert.assertFalse(store.hasHeader(blockHeader.getHash()));
}
use of org.ethereum.core.Bloom in project rskj by rsksmart.
the class AddressesTopicsFilter method initBlooms.
private void initBlooms() {
if (filterBlooms != null) {
return;
}
List<byte[][]> addrAndTopics = new ArrayList<>(2);
for (Topic[] toplist : topics) {
byte[][] tops = new byte[toplist.length][];
for (int k = 0; k < tops.length; k++) {
tops[k] = toplist[k].getBytes();
}
addrAndTopics.add(tops);
}
byte[][] addrs = new byte[addresses.length][];
for (int k = 0; k < addresses.length; k++) {
addrs[k] = addresses[k].getBytes();
}
addrAndTopics.add(addrs);
filterBlooms = new Bloom[addrAndTopics.size()][];
for (int i = 0; i < addrAndTopics.size(); i++) {
byte[][] orTopics = addrAndTopics.get(i);
if (orTopics == null || orTopics.length == 0) {
// always matches
filterBlooms[i] = new Bloom[] { new Bloom() };
} else {
filterBlooms[i] = new Bloom[orTopics.length];
for (int j = 0; j < orTopics.length; j++) {
filterBlooms[i][j] = Bloom.create(Keccak256Helper.keccak256(orTopics[j]));
}
}
}
}
Aggregations