Repository navigation
fix(sdk): update dashcore-lib to 0.26.1 and refresh the testnet whitelist for Core V24 #5687
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
fa9b933
fix(sdk): update dashcore-lib to 0.26.1 for Core V24
shumkov 175d79c
test(sdk): discover nodes from a Core V24 testnet masternode list
shumkov 4d7b7e6
fix(sdk): refresh the testnet DAPI address whitelist
PastaPastaPasta 8c9079e
docs(sdk): describe the testnet DAPI whitelist as a snapshot
PastaPastaPasta File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Binary file removed
BIN
-880 KB
.yarn/cache/@dashevo-dashcore-lib-npm-0.22.0-9a6dd273b9-ac9e268f6e.zip
Binary file not shown.
Binary file added
BIN
+373 KB
.yarn/cache/@dashevo-dashcore-lib-npm-0.26.1-a5ae7b63b3-da3a8914ef.zip
Binary file not shown.
Binary file not shown.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
packages/js-dapi-client/test/fixtures/coreV24TestnetMasternodeListDiff.json
Large diffs are not rendered by default.
Oops, something went wrong.
103 changes: 103 additions & 0 deletions
103
...-dapi-client/test/integration/SMLProvider/SimplifiedMasternodeListProviderCoreV24.spec.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,103 @@ | ||
| const EventEmitter = require('events'); | ||
| const cbor = require('cbor'); | ||
| const networks = require('@dashevo/dashcore-lib/lib/networks'); | ||
| const SimplifiedMNList = require('@dashevo/dashcore-lib/lib/deterministicmnlist/SimplifiedMNList'); | ||
|
|
||
| const SimplifiedMasternodeListProvider = require('../../../lib/SimplifiedMasternodeListProvider/SimplifiedMasternodeListProvider'); | ||
| const SimplifiedMasternodeListDAPIAddressProvider = require('../../../lib/dapiAddressProvider/SimplifiedMasternodeListDAPIAddressProvider'); | ||
| const ListDAPIAddressProvider = require('../../../lib/dapiAddressProvider/ListDAPIAddressProvider'); | ||
|
|
||
| // The full masternode list diff a testnet DAPI node streamed for block 1,582,244, after | ||
| // Core V24 activated at block 1,578,000. Its coinbase is a version 4 CbTx, and 12 of its | ||
| // 399 entries are version 3 (ExtAddr) entries, which Core hashes with ExtNetInfo. | ||
| const coreV24DiffFixture = require('../../fixtures/coreV24TestnetMasternodeListDiff.json'); | ||
|
|
||
| describe('SimplifiedMasternodeListProvider with a Core V24 masternode list', () => { | ||
| let diffBuffer; | ||
| let regtestWasEnabled; | ||
| let stream; | ||
| let createStream; | ||
| let smlProvider; | ||
|
|
||
| before(async () => { | ||
| // Synchronous cbor.encode silently truncates past its stream's buffer limit, | ||
| // and the diff is far larger | ||
| diffBuffer = await cbor.encodeAsync(coreV24DiffFixture); | ||
| }); | ||
|
|
||
| beforeEach(function beforeEach() { | ||
| // dashcore-lib's regtest is its shared testnet object with regtest switched on, and | ||
| // looking up the 'local' or 'regtest' network switches it on for the whole process. | ||
| // These cases need testnet itself. | ||
| regtestWasEnabled = networks.testnet.regtestEnabled; | ||
| networks.disableRegtest(); | ||
|
|
||
| stream = new EventEmitter(); | ||
| stream.cancel = this.sinon.stub(); | ||
| // The provider hands a diff it can't parse or apply to retryOnError. Turn that into | ||
| // a stream error, so the test fails with the provider's error instead of a timeout | ||
| // or an empty list. | ||
| stream.retryOnError = this.sinon.stub().callsFake((error) => stream.emit('error', error)); | ||
|
|
||
| const response = { | ||
| getMasternodeListDiff_asU8: () => new Uint8Array(diffBuffer), | ||
| }; | ||
|
|
||
| createStream = this.sinon.stub().callsFake(async () => { | ||
| // The provider subscribes to the stream after it resolves | ||
| setTimeout(() => stream.emit('data', response), 0); | ||
|
|
||
| return stream; | ||
| }); | ||
|
|
||
| smlProvider = new SimplifiedMasternodeListProvider(createStream, { | ||
| network: 'testnet', | ||
| loggerOptions: { | ||
| identifier: 'test', | ||
| }, | ||
| }); | ||
| }); | ||
|
|
||
| afterEach(() => { | ||
| if (regtestWasEnabled) { | ||
| networks.enableRegtest(); | ||
| } | ||
| }); | ||
|
|
||
| it('should rebuild the masternode list Core committed to in the coinbase', async () => { | ||
| const sml = await smlProvider.getSimplifiedMNList(); | ||
|
|
||
| expect(sml).to.be.an.instanceOf(SimplifiedMNList); | ||
| expect(sml.blockHash).to.equal(coreV24DiffFixture.blockHash); | ||
| expect(sml.mnList).to.have.lengthOf(coreV24DiffFixture.mnList.length); | ||
| expect(sml.mnList.filter((entry) => entry.nVersion === 3)).to.not.be.empty(); | ||
|
|
||
| const { extraPayload: cbTxPayload } = sml.cbTx; | ||
|
|
||
| expect(cbTxPayload.version).to.equal(4); | ||
| expect(sml.calculateMerkleRoot()).to.equal(cbTxPayload.merkleRootMNList); | ||
| expect(sml.calculateMerkleRootQuorums()).to.equal(cbTxPayload.merkleRootQuorums); | ||
| }); | ||
|
|
||
| it('should offer every valid evonode at the Platform HTTPS address Core reports', async () => { | ||
| const listDAPIAddressProvider = new ListDAPIAddressProvider([], { network: 'testnet' }); | ||
| const dapiAddressProvider = new SimplifiedMasternodeListDAPIAddressProvider( | ||
| smlProvider, | ||
| listDAPIAddressProvider, | ||
| [], | ||
| { network: 'testnet' }, | ||
| ); | ||
|
|
||
| await dapiAddressProvider.getLiveAddress(); | ||
|
|
||
| const offeredAddresses = listDAPIAddressProvider.getAllAddresses() | ||
| .map((address) => `${address.getHost()}:${address.getPort()}`); | ||
|
|
||
| const platformHTTPSAddresses = coreV24DiffFixture.mnList | ||
| .filter((entry) => entry.nType === 1 && entry.isValid) | ||
| .map((entry) => entry.addresses.platform_https[0]); | ||
|
|
||
| expect(platformHTTPSAddresses).to.not.be.empty(); | ||
| expect(offeredAddresses).to.have.members(platformHTTPSAddresses); | ||
| }); | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟡 Suggestion: Make the V24 discovery test cover the whitelist and distinct Platform HTTPS endpoints
This test does not exercise the default discovery path it claims to cover.
SimplifiedMasternodeListDAPIAddressProvideraccepts only three constructor arguments, so the fourth{ network: 'testnet' }argument is ignored, and the explicitly supplied empty whitelist disables filtering entirely. The fixture also gives valid V3 entries the same host forcore_p2pandplatform_https; the provider currently usessmlEntry.getIp()withplatformHTTPPort, so the assertion can pass even if endpoint selection ignores a distinctplatform_httpshost. Test through the factory or explicitly pass the refreshed whitelist, and add a fixture case with different Core P2P and Platform HTTPS hosts. If endpoint selection remains deferred, track that follow-up separately rather than relying on this test as coverage for it.source:
muse-spark-1.3-contributor(phase1-reviewer: general);gpt-6.1-sol(phase2-reviewer: general, architecture-layering)