use of co.rsk.peg.utils.MerkleTreeUtils 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.peg.utils.MerkleTreeUtils 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);
}
Aggregations