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:
parent
a2ba8da774
commit
1a5184ab4b
@ -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);
|
||||
}
|
||||
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user