-
Notifications
You must be signed in to change notification settings - Fork 5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add test coverage to web3-core (#7091)
* add test coverage to web3-core * make types compitable * update * update * update types * update types * update * update tests
- Loading branch information
Alex
authored
Jun 11, 2024
1 parent
9547643
commit 7a51c33
Showing
12 changed files
with
611 additions
and
31 deletions.
There are no files selected for viewing
This file contains 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 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
73 changes: 73 additions & 0 deletions
73
packages/web3-core/test/unit/fixtures/custom_transaction_type.ts
This file contains 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 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 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 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.
7a51c33
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.
Benchmark
processingTx
8886
ops/sec (±4.14%
)9360
ops/sec (±3.81%
)1.05
processingContractDeploy
36289
ops/sec (±7.97%
)41290
ops/sec (±6.77%
)1.14
processingContractMethodSend
19089
ops/sec (±6.68%
)19873
ops/sec (±7.29%
)1.04
processingContractMethodCall
37879
ops/sec (±3.96%
)40597
ops/sec (±6.38%
)1.07
abiEncode
41900
ops/sec (±6.51%
)45937
ops/sec (±6.53%
)1.10
abiDecode
29048
ops/sec (±10.00%
)30402
ops/sec (±7.52%
)1.05
sign
1535
ops/sec (±3.67%
)1575
ops/sec (±3.03%
)1.03
verify
371
ops/sec (±0.63%
)382
ops/sec (±0.52%
)1.03
This comment was automatically generated by workflow using github-action-benchmark.