3
0
mirror of https://github.com/Qortal/altcoinj.git synced 2025-02-11 17:55:53 +00:00

Correct cast of network parameters to AuxPoW parameters

Also adds unit test coverage
This commit is contained in:
Ross Nicoll 2015-08-26 21:29:43 +01:00
parent a2ba8da774
commit 1a5184ab4b
2 changed files with 12 additions and 1 deletions

View File

@ -241,7 +241,7 @@ public class AltcoinBlock extends org.bitcoinj.core.Block {
if (params instanceof AltcoinNetworkParameters) {
BigInteger target = getDifficultyTargetAsInteger();
final AuxPoWNetworkParameters altParams = (AuxPoWNetworkParameters)auxpow;
final AuxPoWNetworkParameters altParams = (AuxPoWNetworkParameters)this.params;
if (altParams.isAuxPoWBlockVersion(getRawVersion()) && null != auxpow) {
return auxpow.checkProofOfWork(this.getHash(), target, throwException);
}

View File

@ -117,4 +117,15 @@ public class DogecoinBlockTest {
assertEquals(6, block.getTransactions().size());
}
/**
* Confirm that checking proof of work on an AuxPoW block works.
*/
@Test
public void shouldCheckAuxPoWProofOfWork() throws IOException {
byte[] payload = Util.getBytes(getClass().getResourceAsStream("dogecoin_block371337.bin"));
AltcoinSerializer serializer = (AltcoinSerializer)params.getDefaultSerializer();
final AltcoinBlock block = (AltcoinBlock)serializer.makeBlock(payload);
assertEquals(true, block.checkProofOfWork(true));
}
}