Skip to content

Commit

Permalink
Increase Web3-contract Unit tests to above 90% (#6643)
Browse files Browse the repository at this point in the history
* add a unit test for smart contract overloading

* add a unit test for smart contract wrong method parameters

* add more tests for contract
  • Loading branch information
Muhammad-Altabba authored Dec 12, 2023
1 parent c858390 commit a4f2f8c
Show file tree
Hide file tree
Showing 4 changed files with 491 additions and 2 deletions.
125 changes: 125 additions & 0 deletions fixtures/build/GreeterWithOverloading.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
{
"abi": [
{
"inputs": [
{
"internalType": "string",
"name": "_greeting",
"type": "string"
}
],
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "string",
"name": "greeting",
"type": "string"
}
],
"name": "GREETING_CHANGED",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": false,
"internalType": "string",
"name": "from",
"type": "string"
},
{
"indexed": false,
"internalType": "string",
"name": "to",
"type": "string"
}
],
"name": "GREETING_CHANGING",
"type": "event"
},
{
"inputs": [],
"name": "greet",
"outputs": [
{
"internalType": "string",
"name": "",
"type": "string"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "increment",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "string",
"name": "_greeting",
"type": "string"
},
{
"internalType": "bool",
"name": "_raiseEvents",
"type": "bool"
}
],
"name": "setGreeting",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
},
{
"internalType": "string",
"name": "",
"type": "string"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "string",
"name": "_greeting",
"type": "string"
}
],
"name": "setGreeting",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
},
{
"internalType": "string",
"name": "",
"type": "string"
}
],
"stateMutability": "nonpayable",
"type": "function"
}
],
"evm": {
"bytecode": {
"object": "608060405234801562000010575f80fd5b506040516200104d3803806200104d8339818101604052810190620000369190620001da565b806001908162000047919062000460565b505f80819055505062000544565b5f604051905090565b5f80fd5b5f80fd5b5f80fd5b5f80fd5b5f601f19601f8301169050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b620000b6826200006e565b810181811067ffffffffffffffff82111715620000d857620000d76200007e565b5b80604052505050565b5f620000ec62000055565b9050620000fa8282620000ab565b919050565b5f67ffffffffffffffff8211156200011c576200011b6200007e565b5b62000127826200006e565b9050602081019050919050565b5f5b838110156200015357808201518184015260208101905062000136565b5f8484015250505050565b5f620001746200016e84620000ff565b620000e1565b9050828152602081018484840111156200019357620001926200006a565b5b620001a084828562000134565b509392505050565b5f82601f830112620001bf57620001be62000066565b5b8151620001d18482602086016200015e565b91505092915050565b5f60208284031215620001f257620001f16200005e565b5b5f82015167ffffffffffffffff81111562000212576200021162000062565b5b6200022084828501620001a8565b91505092915050565b5f81519050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52602260045260245ffd5b5f60028204905060018216806200027857607f821691505b6020821081036200028e576200028d62000233565b5b50919050565b5f819050815f5260205f209050919050565b5f6020601f8301049050919050565b5f82821b905092915050565b5f60088302620002f27fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff82620002b5565b620002fe8683620002b5565b95508019841693508086168417925050509392505050565b5f819050919050565b5f819050919050565b5f62000348620003426200033c8462000316565b6200031f565b62000316565b9050919050565b5f819050919050565b620003638362000328565b6200037b62000372826200034f565b848454620002c1565b825550505050565b5f90565b6200039162000383565b6200039e81848462000358565b505050565b5b81811015620003c557620003b95f8262000387565b600181019050620003a4565b5050565b601f8211156200041457620003de8162000294565b620003e984620002a6565b81016020851015620003f9578190505b620004116200040885620002a6565b830182620003a3565b50505b505050565b5f82821c905092915050565b5f620004365f198460080262000419565b1980831691505092915050565b5f62000450838362000425565b9150826002028217905092915050565b6200046b8262000229565b67ffffffffffffffff8111156200048757620004866200007e565b5b62000493825462000260565b620004a0828285620003c9565b5f60209050601f831160018114620004d6575f8415620004c1578287015190505b620004cd858262000443565b8655506200053c565b601f198416620004e68662000294565b5f5b828110156200050f57848901518255600182019150602085019450602081019050620004e8565b868310156200052f57848901516200052b601f89168262000425565b8355505b6001600288020188555050505b505050505050565b610afb80620005525f395ff3fe608060405234801561000f575f80fd5b506004361061004a575f3560e01c80634495ef8a1461004e578063a41368621461007f578063cfae3217146100b0578063d09de08a146100ce575b5f80fd5b61006860048036038101906100639190610545565b6100d8565b604051610076929190610628565b60405180910390f35b61009960048036038101906100949190610656565b610203565b6040516100a7929190610628565b60405180910390f35b6100b861031e565b6040516100c5919061069d565b60405180910390f35b6100d66103ae565b005b5f6060821561011c577f0d363f2fba46ab11b6db8da0125b0d5484787c44e265b48810735998bab12b756001856040516101139291906107ad565b60405180910390a15b836001908161012b9190610976565b50821561016b577f7d7846723bda52976e0286c6efffee937ee9f76817a867ec70531ad29fb1fc0e60016040516101629190610a45565b60405180910390a15b60018080805461017a906106ea565b80601f01602080910402602001604051908101604052809291908181526020018280546101a6906106ea565b80156101f15780601f106101c8576101008083540402835291602001916101f1565b820191905f5260205f20905b8154815290600101906020018083116101d457829003601f168201915b50505050509050915091509250929050565b5f60607f0d363f2fba46ab11b6db8da0125b0d5484787c44e265b48810735998bab12b756001846040516102389291906107ad565b60405180910390a1826001908161024f9190610976565b507f7d7846723bda52976e0286c6efffee937ee9f76817a867ec70531ad29fb1fc0e60016040516102809190610a45565b60405180910390a1600180808054610297906106ea565b80601f01602080910402602001604051908101604052809291908181526020018280546102c3906106ea565b801561030e5780601f106102e55761010080835404028352916020019161030e565b820191905f5260205f20905b8154815290600101906020018083116102f157829003601f168201915b5050505050905091509150915091565b60606001805461032d906106ea565b80601f0160208091040260200160405190810160405280929190818152602001828054610359906106ea565b80156103a45780601f1061037b576101008083540402835291602001916103a4565b820191905f5260205f20905b81548152906001019060200180831161038757829003601f168201915b5050505050905090565b60015f546103bc9190610a92565b5f81905550565b5f604051905090565b5f80fd5b5f80fd5b5f80fd5b5f80fd5b5f601f19601f8301169050919050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b610422826103dc565b810181811067ffffffffffffffff82111715610441576104406103ec565b5b80604052505050565b5f6104536103c3565b905061045f8282610419565b919050565b5f67ffffffffffffffff82111561047e5761047d6103ec565b5b610487826103dc565b9050602081019050919050565b828183375f83830152505050565b5f6104b46104af84610464565b61044a565b9050828152602081018484840111156104d0576104cf6103d8565b5b6104db848285610494565b509392505050565b5f82601f8301126104f7576104f66103d4565b5b81356105078482602086016104a2565b91505092915050565b5f8115159050919050565b61052481610510565b811461052e575f80fd5b50565b5f8135905061053f8161051b565b92915050565b5f806040838503121561055b5761055a6103cc565b5b5f83013567ffffffffffffffff811115610578576105776103d0565b5b610584858286016104e3565b925050602061059585828601610531565b9150509250929050565b6105a881610510565b82525050565b5f81519050919050565b5f82825260208201905092915050565b5f5b838110156105e55780820151818401526020810190506105ca565b5f8484015250505050565b5f6105fa826105ae565b61060481856105b8565b93506106148185602086016105c8565b61061d816103dc565b840191505092915050565b5f60408201905061063b5f83018561059f565b818103602083015261064d81846105f0565b90509392505050565b5f6020828403121561066b5761066a6103cc565b5b5f82013567ffffffffffffffff811115610688576106876103d0565b5b610694848285016104e3565b91505092915050565b5f6020820190508181035f8301526106b581846105f0565b905092915050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52602260045260245ffd5b5f600282049050600182168061070157607f821691505b602082108103610714576107136106bd565b5b50919050565b5f819050815f5260205f209050919050565b5f8154610738816106ea565b61074281866105b8565b9450600182165f811461075c5760018114610772576107a4565b60ff1983168652811515602002860193506107a4565b61077b8561071a565b5f5b8381101561079c5781548189015260018201915060208101905061077d565b808801955050505b50505092915050565b5f6040820190508181035f8301526107c5818561072c565b905081810360208301526107d981846105f0565b90509392505050565b5f6020601f8301049050919050565b5f82821b905092915050565b5f6008830261082c7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff826107f1565b61083686836107f1565b95508019841693508086168417925050509392505050565b5f819050919050565b5f819050919050565b5f61087a6108756108708461084e565b610857565b61084e565b9050919050565b5f819050919050565b61089383610860565b6108a761089f82610881565b8484546107fd565b825550505050565b5f90565b6108bb6108af565b6108c681848461088a565b505050565b5b818110156108e9576108de5f826108b3565b6001810190506108cc565b5050565b601f82111561092e576108ff8161071a565b610908846107e2565b81016020851015610917578190505b61092b610923856107e2565b8301826108cb565b50505b505050565b5f82821c905092915050565b5f61094e5f1984600802610933565b1980831691505092915050565b5f610966838361093f565b9150826002028217905092915050565b61097f826105ae565b67ffffffffffffffff811115610998576109976103ec565b5b6109a282546106ea565b6109ad8282856108ed565b5f60209050601f8311600181146109de575f84156109cc578287015190505b6109d6858261095b565b865550610a3d565b601f1984166109ec8661071a565b5f5b82811015610a13578489015182556001820191506020850194506020810190506109ee565b86831015610a305784890151610a2c601f89168261093f565b8355505b6001600288020188555050505b505050505050565b5f6020820190508181035f830152610a5d818461072c565b905092915050565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b5f610a9c8261084e565b9150610aa78361084e565b9250828201905080821115610abf57610abe610a65565b5b9291505056fea2646970667358221220ca996f61ff5eed9f5836fc8d7c848be4c10bc5fff806ab49930b9c7947082dea64736f6c63430008140033"
}
}
}
Loading

0 comments on commit a4f2f8c

Please sign in to comment.