This repository was archived by the owner on Mar 5, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5.1k
add test coverage to web3-core #7091
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
dbeec51
add test coverage to web3-core
c5d47f8
make types compitable
eab5a68
Merge branch '4.x' into web3-core-coverage
3246f82
update
c1a51a5
update
90ec3ec
update types
e6c6485
update types
db1a4a9
update
26e094f
update tests
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -30,7 +30,6 @@ import { | |
| Web3APISpec, | ||
| } from 'web3-types'; | ||
| import { jsonRpc } from 'web3-utils'; | ||
| import { SubscriptionError } from 'web3-errors'; | ||
|
|
||
| // eslint-disable-next-line import/no-cycle | ||
| import { Web3SubscriptionManager } from './web3_subscription_manager.js'; | ||
|
|
@@ -82,16 +81,6 @@ export abstract class Web3Subscription< | |
| super(); | ||
| const { requestManager } = options as { requestManager: Web3RequestManager<API> }; | ||
| const { subscriptionManager } = options as { subscriptionManager: Web3SubscriptionManager }; | ||
| if (requestManager && subscriptionManager) { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. removed, in the constructor |
||
| throw new SubscriptionError( | ||
| 'Only requestManager or subscriptionManager should be provided at Subscription constructor', | ||
| ); | ||
| } | ||
| if (!requestManager && !subscriptionManager) { | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. removed, in the constructor |
||
| throw new SubscriptionError( | ||
| 'Either requestManager or subscriptionManager should be provided at Subscription constructor', | ||
| ); | ||
| } | ||
| if (requestManager) { | ||
| // eslint-disable-next-line deprecation/deprecation | ||
| this._subscriptionManager = new Web3SubscriptionManager(requestManager, {}, true); | ||
|
|
||
73 changes: 73 additions & 0 deletions
73
packages/web3-core/test/unit/fixtures/custom_transaction_type.ts
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,73 @@ | ||
| /* | ||
| This file is part of web3.js. | ||
|
|
||
| web3.js is free software: you can redistribute it and/or modify | ||
| it under the terms of the GNU Lesser General Public License as published by | ||
| the Free Software Foundation, either version 3 of the License, or | ||
| (at your option) any later version. | ||
|
|
||
| web3.js is distributed in the hope that it will be useful, | ||
| but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| GNU Lesser General Public License for more details. | ||
|
|
||
| You should have received a copy of the GNU Lesser General Public License | ||
| along with web3.js. If not, see <http://www.gnu.org/licenses/>. | ||
| */ | ||
|
|
||
| import { | ||
| BaseTransaction, | ||
| TxValuesArray, | ||
| AccessListEIP2930ValuesArray, | ||
| FeeMarketEIP1559ValuesArray, | ||
| JsonTx, | ||
| } from 'web3-eth-accounts'; | ||
|
|
||
| export class CustomTransactionType extends BaseTransaction<unknown> { | ||
| // eslint-disable-next-line class-methods-use-this | ||
| public getUpfrontCost(): bigint { | ||
| throw new Error('Method not implemented.'); | ||
| } | ||
| // eslint-disable-next-line class-methods-use-this | ||
| public raw(): TxValuesArray | AccessListEIP2930ValuesArray | FeeMarketEIP1559ValuesArray { | ||
| throw new Error('Method not implemented.'); | ||
| } | ||
| // eslint-disable-next-line class-methods-use-this | ||
| public serialize(): Uint8Array { | ||
| throw new Error('Method not implemented.'); | ||
| } | ||
| public getMessageToSign(hashMessage: false): Uint8Array | Uint8Array[]; | ||
| public getMessageToSign(hashMessage?: true | undefined): Uint8Array; | ||
| // eslint-disable-next-line class-methods-use-this | ||
| public getMessageToSign(): Uint8Array | Uint8Array[] { | ||
| throw new Error('Method not implemented.'); | ||
| } | ||
| // eslint-disable-next-line class-methods-use-this | ||
| public hash(): Uint8Array { | ||
| throw new Error('Method not implemented.'); | ||
| } | ||
| // eslint-disable-next-line class-methods-use-this | ||
| public getMessageToVerifySignature(): Uint8Array { | ||
| throw new Error('Method not implemented.'); | ||
| } | ||
| // eslint-disable-next-line class-methods-use-this | ||
| public getSenderPublicKey(): Uint8Array { | ||
| throw new Error('Method not implemented.'); | ||
| } | ||
| // eslint-disable-next-line class-methods-use-this | ||
| public toJSON(): JsonTx { | ||
| throw new Error('Method not implemented.'); | ||
| } | ||
| // eslint-disable-next-line class-methods-use-this | ||
| protected _processSignature(): unknown { | ||
| throw new Error('Method not implemented.'); | ||
| } | ||
| // eslint-disable-next-line @typescript-eslint/explicit-member-accessibility, class-methods-use-this | ||
| public errorStr(): string { | ||
| throw new Error('Method not implemented.'); | ||
| } | ||
| // eslint-disable-next-line class-methods-use-this | ||
| protected _errorMsg(): string { | ||
| throw new Error('Method not implemented.'); | ||
| } | ||
| } |
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
28 changes: 28 additions & 0 deletions
28
packages/web3-core/test/unit/fixtures/example_subscription_build.ts
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,28 @@ | ||
| /* | ||
| This file is part of web3.js. | ||
|
|
||
| web3.js is free software: you can redistribute it and/or modify | ||
| it under the terms of the GNU Lesser General Public License as published by | ||
| the Free Software Foundation, either version 3 of the License, or | ||
| (at your option) any later version. | ||
|
|
||
| web3.js is distributed in the hope that it will be useful, | ||
| but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| GNU Lesser General Public License for more details. | ||
|
|
||
| You should have received a copy of the GNU Lesser General Public License | ||
| along with web3.js. If not, see <http://www.gnu.org/licenses/>. | ||
| */ | ||
| import { Web3Subscription } from '../../../src'; | ||
|
|
||
| // subscription class that exposes buildSubscriptionParams | ||
| export class BuildSubscription extends Web3Subscription< | ||
| { data: string }, | ||
| { param1: string }, | ||
| { eth_subscribe: (newHeads: string) => void } | ||
| > { | ||
| public buildSubscriptionParams() { | ||
| this._buildSubscriptionParams(); | ||
| } | ||
| } |
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.
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.
Uh oh!
There was an error while loading. Please reload this page.
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.
removed, This conditional can never happen as we check
jsonRpc.isResponseWithError(response)andjsonRpc.isResponseWithResult(response)seperately