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
5427 contracts unit tests #5465
Merged
Merged
Changes from 5 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
044d06a
sample abi of a contract
jdevcs 2146eaf
unit tests contract
jdevcs d6008ef
contract events test
jdevcs 6e5246a
unit test data
jdevcs 777334e
additional tests for more coverage
jdevcs 67b1adf
default common check
jdevcs 54f13a1
test contract source and updated abi
jdevcs 59f8616
Merge branch '4.x' into junaid/contractsunitests
jdevcs 4e74cb9
common type fix
jdevcs 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| /* | ||
| 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/>. | ||
| */ | ||
|
|
||
| // sample storage contract ABI | ||
| export const sampleStorageContractABI = [ | ||
| { | ||
| inputs: [], | ||
| name: 'retrieve', | ||
| outputs: [ | ||
| { | ||
| internalType: 'uint256', | ||
| name: '', | ||
| type: 'uint256', | ||
| }, | ||
| ], | ||
| stateMutability: 'view', | ||
| type: 'function', | ||
| }, | ||
| { | ||
| inputs: [ | ||
| { | ||
| internalType: 'uint256', | ||
| name: 'num', | ||
| type: 'uint256', | ||
| }, | ||
| ], | ||
| name: 'store', | ||
| outputs: [], | ||
| stateMutability: 'nonpayable', | ||
| type: 'function', | ||
| }, | ||
| ]; | ||
142 changes: 142 additions & 0 deletions
142
packages/web3-eth-contract/test/fixtures/unitTestFixtures.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,142 @@ | ||
| /* | ||
| 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/>. | ||
| */ | ||
|
|
||
| export const getLogsData = { | ||
| request: { | ||
| fromBlock: 'earliest', | ||
| toBlock: 'latest', | ||
| topics: ['0x7d7846723bda52976e0286c6efffee937ee9f76817a867ec70531ad29fb1fc0e'], | ||
| }, | ||
|
|
||
| response: [ | ||
| { | ||
| logIndex: 1, | ||
| transactionIndex: 0, | ||
| transactionHash: '0xbe70733bcf87282c0ba9bf3c0e2d545084fad48bd571c314140c8dc1db882673', | ||
| blockHash: '0x78755c18c9a0a1283fa04b2f78c7794c249395b08f7f7dff304034d64d6a1607', | ||
| blockNumber: 25, | ||
| address: '0x2D029a4bd792d795f35e0583F64eD9DedeBBa849', | ||
| data: '0x0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000548656c6c6f000000000000000000000000000000000000000000000000000000', | ||
| topics: ['0x7d7846723bda52976e0286c6efffee937ee9f76817a867ec70531ad29fb1fc0e'], | ||
| type: 'mined', | ||
| id: 'log_886b29f0', | ||
| }, | ||
| ], | ||
| }; | ||
|
|
||
| export const getPastEventsData = { | ||
| event: 'GREETING_CHANGED', | ||
| response: [ | ||
| { | ||
| logIndex: BigInt(1), | ||
| transactionIndex: BigInt(0), | ||
| transactionHash: '0xbe70733bcf87282c0ba9bf3c0e2d545084fad48bd571c314140c8dc1db882673', | ||
| blockHash: '0x78755c18c9a0a1283fa04b2f78c7794c249395b08f7f7dff304034d64d6a1607', | ||
| blockNumber: BigInt(25), | ||
| address: '0x2D029a4bd792d795f35e0583F64eD9DedeBBa849', | ||
| data: '0x0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000548656c6c6f000000000000000000000000000000000000000000000000000000', | ||
| topics: ['0x7d7846723bda52976e0286c6efffee937ee9f76817a867ec70531ad29fb1fc0e'], | ||
| returnValues: { | ||
| '0': 'Hello', | ||
| __length__: 1, | ||
| greeting: 'Hello', | ||
| }, | ||
| event: 'GREETING_CHANGED', | ||
| signature: '0x7d7846723bda52976e0286c6efffee937ee9f76817a867ec70531ad29fb1fc0e', | ||
| raw: { | ||
| data: '0x0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000000548656c6c6f000000000000000000000000000000000000000000000000000000', | ||
| topics: ['0x7d7846723bda52976e0286c6efffee937ee9f76817a867ec70531ad29fb1fc0e'], | ||
| }, | ||
| }, | ||
| ], | ||
| }; | ||
|
|
||
| export const AllGetPastEventsData = { | ||
| getLogsData: [ | ||
| { | ||
| logIndex: 0, | ||
| transactionIndex: 0, | ||
| transactionHash: '0x1ba478ce1810bfa8a0725c0ca94f3cfe163a70c396037a1f3c94cad34e497959', | ||
| blockHash: '0x79eece1fb22b7109f302b65bd826b1cebf9f704642e86ae9086ed93baf44a45e', | ||
| blockNumber: 20, | ||
| address: '0x20bc23D0598b12c34cBDEf1fae439Ba8744DB426', | ||
| data: '0x00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000548656c6c6f0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010416e6f74686572204772656574696e6700000000000000000000000000000000', | ||
| topics: ['0x0d363f2fba46ab11b6db8da0125b0d5484787c44e265b48810735998bab12b75'], | ||
| type: 'mined', | ||
| id: 'log_0a03b06c', | ||
| }, | ||
| { | ||
| logIndex: 1, | ||
| transactionIndex: 0, | ||
| transactionHash: '0x1ba478ce1810bfa8a0725c0ca94f3cfe163a70c396037a1f3c94cad34e497959', | ||
| blockHash: '0x79eece1fb22b7109f302b65bd826b1cebf9f704642e86ae9086ed93baf44a45e', | ||
| blockNumber: 20, | ||
| address: '0x20bc23D0598b12c34cBDEf1fae439Ba8744DB426', | ||
| data: '0x00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000010416e6f74686572204772656574696e6700000000000000000000000000000000', | ||
| topics: ['0x7d7846723bda52976e0286c6efffee937ee9f76817a867ec70531ad29fb1fc0e'], | ||
| type: 'mined', | ||
| id: 'log_389ae161', | ||
| }, | ||
| ], | ||
|
|
||
| response: [ | ||
| { | ||
| logIndex: BigInt(0), | ||
| transactionIndex: BigInt(0), | ||
| transactionHash: '0x1ba478ce1810bfa8a0725c0ca94f3cfe163a70c396037a1f3c94cad34e497959', | ||
| blockHash: '0x79eece1fb22b7109f302b65bd826b1cebf9f704642e86ae9086ed93baf44a45e', | ||
| blockNumber: BigInt(20), | ||
| address: '0x20bc23D0598b12c34cBDEf1fae439Ba8744DB426', | ||
| data: '0x00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000548656c6c6f0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010416e6f74686572204772656574696e6700000000000000000000000000000000', | ||
| topics: ['0x0d363f2fba46ab11b6db8da0125b0d5484787c44e265b48810735998bab12b75'], | ||
| returnValues: { | ||
| '0': 'Hello', | ||
| '1': 'Another Greeting', | ||
| __length__: 2, | ||
| from: 'Hello', | ||
| to: 'Another Greeting', | ||
| }, | ||
| event: 'GREETING_CHANGING', | ||
| signature: '0x0d363f2fba46ab11b6db8da0125b0d5484787c44e265b48810735998bab12b75', | ||
| raw: { | ||
| data: '0x00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000548656c6c6f0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010416e6f74686572204772656574696e6700000000000000000000000000000000', | ||
| topics: ['0x0d363f2fba46ab11b6db8da0125b0d5484787c44e265b48810735998bab12b75'], | ||
| }, | ||
| }, | ||
| { | ||
| logIndex: BigInt(1), | ||
| transactionIndex: BigInt(0), | ||
| transactionHash: '0x1ba478ce1810bfa8a0725c0ca94f3cfe163a70c396037a1f3c94cad34e497959', | ||
| blockHash: '0x79eece1fb22b7109f302b65bd826b1cebf9f704642e86ae9086ed93baf44a45e', | ||
| blockNumber: BigInt(20), | ||
| address: '0x20bc23D0598b12c34cBDEf1fae439Ba8744DB426', | ||
| data: '0x00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000010416e6f74686572204772656574696e6700000000000000000000000000000000', | ||
| topics: ['0x7d7846723bda52976e0286c6efffee937ee9f76817a867ec70531ad29fb1fc0e'], | ||
| returnValues: { | ||
| '0': 'Another Greeting', | ||
| __length__: 1, | ||
| greeting: 'Another Greeting', | ||
| }, | ||
| event: 'GREETING_CHANGED', | ||
| signature: '0x7d7846723bda52976e0286c6efffee937ee9f76817a867ec70531ad29fb1fc0e', | ||
| raw: { | ||
| data: '0x00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000010416e6f74686572204772656574696e6700000000000000000000000000000000', | ||
| topics: ['0x7d7846723bda52976e0286c6efffee937ee9f76817a867ec70531ad29fb1fc0e'], | ||
| }, | ||
| }, | ||
| ], | ||
| }; |
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.