hyperledger-cacti/cacti

test(ethereum): fix broken validations in ethereum plugin connector tests

Opened this issue · 1 comments

Describe the bug

Multiple tests are failing in cactus-plugin-ledger-connector-ethereum/src/test/typescript/integration including:

  • geth-contract-deploy-and-invoke-using-json-object-v1.test.ts: test("deployContract with additional parameters should fail")
  • geth-contract-deploy-and-invoke-using-keychain-v1.test.ts: test("deployContract with additional parameters should fail")
  • geth-invoke-web3-method-v1.test.ts: test("invokeRawWeb3EthMethod with missing arg throws error (getBlock)")

To Reproduce

Run these tests in run and debug and note the failing tests in the terminal output.

Expected behavior

The failing tests should pass - contingent upon the jest assertions in those tests also passing. If the test description says the specific function called should return an error, it should return an error and not a resolved promise.

Log/Stack Traces

Full file:

broken-ethereum-tests.log

Relevent snippets:

` FAIL packages/cactus-plugin-ledger-connector-ethereum/src/test/typescript/integration/geth-contract-deploy-and-invoke-using-json-object-v1.test.ts (73.064 s, 757 MB heap size)
Ethereum contract deploy and invoke using keychain tests
✓ setup ethereum connector (4180 ms)
✓ deploys contract using json object (5040 ms)
✓ deploys contract using json object with constructorArgs (5139 ms)
✓ deployContract without contractJSON should fail (98 ms)
✕ deployContract with additional parameters should fail (5030 ms)
✓ invoke Web3SigningCredentialType.GETHKEYCHAINPASSWORD (10230 ms)
✓ invoke Web3SigningCredentialType.PrivateKeyHex (4171 ms)
✓ invokeContractV1 without methodName should fail (45 ms)

● Ethereum contract deploy and invoke using keychain tests › deployContract with additional parameters should fail

expect(received).rejects.toThrow()

Received promise resolved instead of rejected
Resolved to value: {"config": [Object], "data": [Object], "headers": [AxiosHeaders], "request": [ClientRequest], "status": 200, "statusText": "OK"}

  273 |
  274 |     // have the left the original assertion above as a comment for additional context, this can be removed once this test is debugged. 
> 275 |     await expect(
      |           ^
  276 |       apiClient.deployContract({
  277 |         contract: {
  278 |           contractJSON: HelloWorldContractJson,

  at expect (node_modules/expect/build/index.js:113:15)
  at Object.<anonymous> (packages/cactus-plugin-ledger-connector-ethereum/src/test/typescript/integration/geth-contract-deploy-and-invoke-using-json-object-v1.test.ts:275:11)

Test Suites: 1 failed, 1 total
Tests: 1 failed, 7 passed, 8 total
Snapshots: 0 total
Time: 73.156 s
Ran all test suites matching /packages/cactus-plugin-ledger-connector-ethereum/src/test/typescript/integration/geth-contract-deploy-and-invoke-using-json-object-v1.test.ts/i.
Waiting for the debugger to disconnect...`

` FAIL packages/cactus-plugin-ledger-connector-ethereum/src/test/typescript/integration/geth-invoke-web3-method-v1.test.ts (24.625 s, 641 MB heap size)
invokeRawWeb3EthMethod Tests
✓ invoke method using json-rpc proxy (48 ms)
✓ invokeRawWeb3EthMethod with 0-argument method works (getGasPrice) (9 ms)
✓ invokeRawWeb3EthMethod with 1-argument method works (getBlock) (24 ms)
✓ invokeRawWeb3EthMethod with 2-argument method works (getStorageAt) (15 ms)
✕ invokeRawWeb3EthMethod with missing arg throws error (getBlock) (13 ms)
✓ invokeRawWeb3EthMethod with invalid arg throws error (getBlock) (30 ms)
✓ invokeRawWeb3EthMethod with non existing method throws error (3 ms)

● invokeRawWeb3EthMethod Tests › invokeRawWeb3EthMethod with missing arg throws error (getBlock)

expect(received).rejects.toBeTruthy()

Received promise resolved instead of rejected
Resolved to value: {"baseFeePerGas": 765625000n, "difficulty": 2n, "extraData": "0xd883010c00846765746888676f312e32302e34856c696e757800000000000000ec0a71024e85a0189e80a46d242a5fcece2ccf6e312947436fb6a7a0f479383d3a5fe38732d961e979f5cb2776d0cae48e1664e653c2b31fd562826be43d5c6601", "gasLimit": 798438265n, "gasUsed": 0n, "hash": "0x1a71ac619e3eeb9b151971039105389f6f64d51ceddeaec67a719618fbe31a98", "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "miner": "0x0000000000000000000000000000000000000000", "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000", "nonce": 0n, "number": 2n, "parentHash": "0xea9b82988f8ab3834ab4906a4d61f167cbe7e1d5e0124b092253600d710a2c26", "receiptsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "sha3Uncles": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347", "size": 612n, "stateRoot": "0xc3b31e08b8fb33599eafcc9e20d81bb2af09d26308e4aa3f46617b5839e03ff4", "timestamp": 1723908677n, "totalDifficulty": 5n, "transactionsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "uncles": []}

  182 |
  183 |     // have the left the original assertion above as a comment for additional context, this can be removed once this test is debugged. 
> 184 |     await expect(
      |           ^
  185 |       connector.invokeRawWeb3EthMethod({
  186 |         methodName: "getBlock",
  187 |       })

  at expect (node_modules/expect/build/index.js:113:15)
  at Object.<anonymous> (packages/cactus-plugin-ledger-connector-ethereum/src/test/typescript/integration/geth-invoke-web3-method-v1.test.ts:184:11)

Test Suites: 1 failed, 1 total
Tests: 1 failed, 6 passed, 7 total
Snapshots: 0 total
Time: 24.71 s, estimated 25 s
Ran all test suites matching /packages/cactus-plugin-ledger-connector-ethereum/src/test/typescript/integration/geth-invoke-web3-method-v1.test.ts/i.`

` FAIL packages/cactus-plugin-ledger-connector-ethereum/src/test/typescript/integration/geth-contract-deploy-and-invoke-using-keychain-v1.test.ts (68.848 s, 658 MB heap size)
Ethereum contract deploy and invoke using keychain tests
✓ setup ethereum connector (4245 ms)
✓ deploys contract using keychain (5071 ms)
✓ deploys contract using keychain with constructorArgs (5125 ms)
✓ deployContract without contractName should fail (163 ms)
✕ deployContract with additional parameters should fail (4204 ms)
✓ invoke Web3SigningCredentialType.GETHKEYCHAINPASSWORD (10386 ms)
✓ invoke Web3SigningCredentialType.None (5087 ms)
✓ runTransactionV1 without transaction config should fail (30 ms)
✓ invoke Web3SigningCredentialType.PrivateKeyHex (5171 ms)
✓ invoke Web3SigningCredentialType.CactiKeychainRef (4153 ms)
✓ invokeContractV1 without methodName should fail (27 ms)
✓ get prometheus exporter metrics (10 ms)

● Ethereum contract deploy and invoke using keychain tests › deployContract with additional parameters should fail

expect(received).rejects.toThrow()

Received promise resolved instead of rejected
Resolved to value: {"config": {"adapter": [Array], "data": "{\"contract\":{\"contractName\":\"HelloWorld\",\"keychainId\":\"e7536fa2-6c12-4726-aaef-ef8a71912f44\"},\"web3SigningCredential\":{\"ethAccount\":\"0x6a2ec8c50ba1a9ce47c52d1cb5b7136ee9d0ccc0\",\"secret\":\"\",\"type\":\"GETH_KEYCHAIN_PASSWORD\"},\"gas\":1000000,\"fake\":4}", "env": [Object], "headers": [AxiosHeaders], "maxBodyLength": -1, "maxContentLength": -1, "method": "post", "timeout": 0, "transformRequest": [Array], "transformResponse": [Array], "transitional": [Object], "url": "http://127.0.0.1:33569/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-ethereum/deploy-contract", "validateStatus": [Function validateStatus], "xsrfCookieName": "XSRF-TOKEN", "xsrfHeaderName": "X-XSRF-TOKEN"}, "data": {"transactionReceipt": [Object]}, "headers": [Object], "request": {"_closed": false, "_contentLength": "245", "_defaultKeepAlive": true, "_ended": true, "_events": [Object], "_eventsCount": 7, "_hasBody": true, "_header": "POST /api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-ethereum/deploy-contract HTTP/1.1·
Accept: application/json, text/plain, */*·
Content-Type: application/json·
User-Agent: axios/1.7.2·
Content-Length: 245·
Accept-Encoding: gzip, compress, deflate, br·
Host: 127.0.0.1:33569·
Connection: close···
", "_headerSent": true, "_keepAliveTimeout": 0, "_last": true, "_maxListeners": undefined, "_onPendingData": [Function nop], "_redirectable": [Writable], "_removedConnection": false, "_removedContLen": false, "_removedTE": false, "_trailer": "", "aborted": false, "agent": [Agent], "chunkedEncoding": false, "destroyed": false, "finished": true, "host": "127.0.0.1", "insecureHTTPParser": undefined, "joinDuplicateHeaders": undefined, "maxHeaderSize": undefined, "maxHeadersCount": null, "maxRequestsOnConnectionReached": false, "method": "POST", "outputData": [Array], "outputSize": 0, "parser": null, "path": "/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-ethereum/deploy-contract", "protocol": "http:", "res": [IncomingMessage], "reusedSocket": false, "sendDate": false, "shouldKeepAlive": false, "socket": [Socket], "socketPath": undefined, "strictContentLength": false, "timeoutCb": null, "upgradeOrConnect": false, "useChunkedEncodingByDefault": true, "writable": true, Symbol(kCapture): false, Symbol(kBytesWritten): 0, Symbol(kNeedDrain): false, Symbol(corked): 0, Symbol(kOutHeaders): [Object], Symbol(errored): null, Symbol(kHighWaterMark): 16384, Symbol(kRejectNonStandardBodyWrites): false, Symbol(kUniqueHeaders): null}, "status": 200, "statusText": "OK"}

  280 |
  281 |     // have the left the original assertion above as a comment for additional context, this can be removed once this test is debugged. 
> 282 |     await expect(
      |           ^
  283 |       apiClient.deployContract({
  284 |         contract: {
  285 |           contractName: HelloWorldContractJson.contractName,

  at expect (node_modules/expect/build/index.js:113:15)
  at Object.<anonymous> (packages/cactus-plugin-ledger-connector-ethereum/src/test/typescript/integration/geth-contract-deploy-and-invoke-using-keychain-v1.test.ts:282:11)

Test Suites: 1 failed, 1 total
Tests: 1 failed, 11 passed, 12 total
Snapshots: 0 total
Time: 68.934 s, estimated 70 s
Ran all test suites matching /packages/cactus-plugin-ledger-connector-ethereum/src/test/typescript/integration/geth-contract-deploy-and-invoke-using-keychain-v1.test.ts/i.`