Skip to content

Commit

Permalink
update contract
Browse files Browse the repository at this point in the history
  • Loading branch information
luu-alex committed Jan 31, 2024
1 parent 24c910b commit 5bc2e3c
Showing 1 changed file with 92 additions and 0 deletions.
92 changes: 92 additions & 0 deletions packages/web3-eth-contract/test/unit/contract.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { ValidChains, Hardfork, AccessListResult, Address, ETH_DATA_FORMAT , DEF
import { Web3ContractError } from 'web3-errors';
import { Web3Context , Web3ConfigEvent } from 'web3-core';
import { Web3ValidatorError } from 'web3-validator';
import { AbiItem } from 'web3-utils';

import { Contract } from '../../src';
import { sampleStorageContractABI } from '../fixtures/storage';
Expand Down Expand Up @@ -110,6 +111,97 @@ describe('Contract', () => {
expect(contract).toBeInstanceOf(Contract);
});

it('should init with abiItem, options and context', () => {
const contract = new Contract(
[{
anonymous: false,
constant: true,
inputs: [
{
name: 'testMe',
type: 'uint256[3]'
},
{
name: 'inputA',
type: 'tuple',
components: [
{
name: 'a',
type: 'uint8'
},
{
name: 'b',
type: 'uint8'
}
]
},
{
name: 'inputB',
type: 'tuple[]',
components: [
{
name: 'a1',
type: 'uint256'
},
{
name: 'a2',
type: 'uint256'
}
]
},
{
name: 'inputC',
type: 'uint8',
indexed: false
}
],
name: "testName",
outputs: [
{
name: "test",
type: "uint256"
},
{
name: 'outputA',
type: 'tuple',
components: [
{
name: 'a',
type: 'uint8'
},
{
name: 'b',
type: 'uint8'
}
]
},
{
name: 'outputB',
type: 'tuple[]',
components: [
{
name: 'a1',
type: 'uint256'
},
{
name: 'a2',
type: 'uint256'
}
]
}
],
payable: false,
stateMutability: "pure",
type: "function",
gas: 175875
} as AbiItem],
{ gas: '123' },
{ config: { defaultAccount: '0x00000000219ab540356cBB839Cbe05303d7705Fa' } },
);

expect(contract).toBeInstanceOf(Contract);
});

it('should init with abi, address and options', () => {
const contract = new Contract([], '0x00000000219ab540356cBB839Cbe05303d7705Fa', {
gas: '123',
Expand Down

1 comment on commit 5bc2e3c

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Benchmark

Benchmark suite Current: 5bc2e3c Previous: 6c075db Ratio
processingTx 9544 ops/sec (±3.68%) 9301 ops/sec (±4.81%) 0.97
processingContractDeploy 40987 ops/sec (±6.74%) 39129 ops/sec (±7.62%) 0.95
processingContractMethodSend 19731 ops/sec (±8.66%) 19443 ops/sec (±5.19%) 0.99
processingContractMethodCall 39807 ops/sec (±5.84%) 38971 ops/sec (±6.34%) 0.98
abiEncode 46089 ops/sec (±6.95%) 44252 ops/sec (±6.92%) 0.96
abiDecode 31506 ops/sec (±9.75%) 30419 ops/sec (±8.89%) 0.97
sign 1659 ops/sec (±4.36%) 1656 ops/sec (±4.08%) 1.00
verify 382 ops/sec (±0.44%) 373 ops/sec (±0.78%) 0.98

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.