use of co.rsk.validators.Rskip92MerkleProofValidator in project rskj by rsksmart.
the class Rskip92MerkleProofValidatorTests method isValid_PassValidHashes_ShouldReturnTrue.
@Test
public void isValid_PassValidHashes_ShouldReturnTrue() {
List<byte[]> hashList = makeHashList();
byte[] pmtSerialized = join(hashList);
Sha256Hash coinbaseHash = Sha256Hash.wrap(hashList.get(0));
Rskip92MerkleProofValidator rskip92MerkleProofValidator = new Rskip92MerkleProofValidator(pmtSerialized, true);
Sha256Hash rootHash = hashList.stream().map(Sha256Hash::wrap).reduce(coinbaseHash, MerkleTreeUtils::combineLeftRight);
boolean actualResult = rskip92MerkleProofValidator.isValid(rootHash, coinbaseHash);
assertTrue(actualResult);
}
use of co.rsk.validators.Rskip92MerkleProofValidator in project rskj by rsksmart.
the class Rskip92MerkleProofValidatorTests method isValid_PassInvalidCoinbaseHash_ShouldReturnFalse.
@Test
public void isValid_PassInvalidCoinbaseHash_ShouldReturnFalse() {
List<byte[]> hashList = makeHashList();
byte[] pmtSerialized = join(hashList);
Sha256Hash coinbaseHash = Sha256Hash.wrap(hashList.get(0));
Rskip92MerkleProofValidator rskip92MerkleProofValidator = new Rskip92MerkleProofValidator(pmtSerialized, true);
Sha256Hash rootHash = hashList.stream().map(Sha256Hash::wrap).reduce(coinbaseHash, MerkleTreeUtils::combineLeftRight);
boolean actualResult = rskip92MerkleProofValidator.isValid(rootHash, Sha256Hash.wrap(new byte[Sha256Hash.LENGTH]));
assertFalse(actualResult);
}
use of co.rsk.validators.Rskip92MerkleProofValidator in project rskj by rsksmart.
the class Rskip92MerkleProofValidatorTests method createInstance_PassLargeProofAndRskip180Disabled_ShouldNotThrowError.
@Test
public void createInstance_PassLargeProofAndRskip180Disabled_ShouldNotThrowError() {
byte[] pmtSerialized = new byte[MAX_MERKLE_PROOF_SIZE + Sha256Hash.LENGTH];
Rskip92MerkleProofValidator instance = new Rskip92MerkleProofValidator(pmtSerialized, false);
assertNotNull(instance);
}
use of co.rsk.validators.Rskip92MerkleProofValidator in project rskj by rsksmart.
the class Rskip92MerkleProofValidatorTests method isValid_PassInvalidRootHash_ShouldReturnFalse.
@Test
public void isValid_PassInvalidRootHash_ShouldReturnFalse() {
List<byte[]> hashList = makeHashList();
byte[] pmtSerialized = join(hashList);
Sha256Hash coinbaseHash = Sha256Hash.wrap(hashList.get(0));
Rskip92MerkleProofValidator rskip92MerkleProofValidator = new Rskip92MerkleProofValidator(pmtSerialized, true);
Sha256Hash rootHash = Sha256Hash.wrap(new byte[Sha256Hash.LENGTH]);
boolean actualResult = rskip92MerkleProofValidator.isValid(rootHash, coinbaseHash);
assertFalse(actualResult);
}
Aggregations