Skip to content
This repository has been archived by the owner on Sep 26, 2019. It is now read-only.

FilterIdGenerator fixes #1544

Merged
merged 1 commit into from
Jun 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,15 @@
import tech.pegasys.pantheon.crypto.SecureRandomProvider;
import tech.pegasys.pantheon.ethereum.jsonrpc.internal.results.Quantity;

import java.security.SecureRandom;

public class FilterIdGenerator {

private final SecureRandom secureRandom = SecureRandomProvider.createSecureRandom();

public String nextId() {
final byte[] randomBytes = new byte[16];
SecureRandomProvider.createSecureRandom().nextBytes(randomBytes);
secureRandom.nextBytes(randomBytes);
return Quantity.create(randomBytes);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

import static org.junit.Assert.assertEquals;

import tech.pegasys.pantheon.util.bytes.BytesValue;
import tech.pegasys.pantheon.util.uint.UInt256;

import org.junit.Test;

Expand All @@ -24,7 +24,7 @@ public class FilterIdGeneratorTest {
public void idIsAHexString() {
final FilterIdGenerator generator = new FilterIdGenerator();
final String s = generator.nextId();
final BytesValue bytesValue = BytesValue.fromHexString(s);
assertEquals(s, bytesValue.toString());
final UInt256 bytesValue = UInt256.fromHexString(s);
assertEquals(s, bytesValue.toShortHexString());
}
}