mirror of
https://github.com/benjamin-wilson/public-pool.git
synced 2026-09-29 17:15:03 -07:00
misc improvements from blitzpool
This commit is contained in:
@@ -82,4 +82,32 @@ describe('MiningJob', () => {
|
||||
|
||||
expect(updatedBlock.version).toBe(jobTemplate.block.version);
|
||||
});
|
||||
|
||||
it('should expose coinbase helpers for downstream validation', () => {
|
||||
const notify = JSON.parse(job.response(jobTemplate));
|
||||
|
||||
expect(job.getCoinbaseTxHex()).toContain(notify.params[2]);
|
||||
expect(job.getCoinbasePrefixBuffer().toString('hex')).toBe(notify.params[2]);
|
||||
expect(job.getCoinbaseSuffixBuffer().toString('hex')).toBe(notify.params[3]);
|
||||
const clone = job.cloneCoinbaseTransaction();
|
||||
const nonWitnessCoinbase = bitcoinjs.Transaction.fromHex(job.getCoinbaseTxHex());
|
||||
expect(clone.ins[0].script.toString('hex')).toBe(nonWitnessCoinbase.ins[0].script.toString('hex'));
|
||||
expect(clone.outs).toHaveLength(nonWitnessCoinbase.outs.length);
|
||||
expect(clone.ins[0].witness[0]).toHaveLength(32);
|
||||
});
|
||||
|
||||
it('should omit oversized pool identifiers from the coinbase script', () => {
|
||||
jest.spyOn(console, 'warn').mockImplementation(() => undefined);
|
||||
const oversizedIdentifier = 'x'.repeat(120);
|
||||
const oversizedJob = new MiningJob(
|
||||
bitcoinjs.networks.testnet,
|
||||
'2',
|
||||
[{ address: 'tb1qumezefzdeqqwn5zfvgdrhxjzc5ylr39uhuxcz4', percent: 100 }],
|
||||
jobTemplate,
|
||||
oversizedIdentifier
|
||||
);
|
||||
const coinbase = bitcoinjs.Transaction.fromHex(oversizedJob.getCoinbaseTxHex());
|
||||
|
||||
expect(coinbase.ins[0].script.toString()).not.toContain(oversizedIdentifier);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user