mirror of
https://github.com/Qortal/altcoinj.git
synced 2025-11-02 05:27:17 +00:00
Correct cast of network parameters to AuxPoW parameters
Also adds unit test coverage
This commit is contained in:
@@ -241,7 +241,7 @@ public class AltcoinBlock extends org.bitcoinj.core.Block {
|
|||||||
if (params instanceof AltcoinNetworkParameters) {
|
if (params instanceof AltcoinNetworkParameters) {
|
||||||
BigInteger target = getDifficultyTargetAsInteger();
|
BigInteger target = getDifficultyTargetAsInteger();
|
||||||
|
|
||||||
final AuxPoWNetworkParameters altParams = (AuxPoWNetworkParameters)auxpow;
|
final AuxPoWNetworkParameters altParams = (AuxPoWNetworkParameters)this.params;
|
||||||
if (altParams.isAuxPoWBlockVersion(getRawVersion()) && null != auxpow) {
|
if (altParams.isAuxPoWBlockVersion(getRawVersion()) && null != auxpow) {
|
||||||
return auxpow.checkProofOfWork(this.getHash(), target, throwException);
|
return auxpow.checkProofOfWork(this.getHash(), target, throwException);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -117,4 +117,15 @@ public class DogecoinBlockTest {
|
|||||||
|
|
||||||
assertEquals(6, block.getTransactions().size());
|
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));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user