Skip to content

Hardhat + Localnet #54

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 40 commits into from
Closed

Conversation

wertikalk
Copy link
Collaborator

@wertikalk wertikalk commented Apr 12, 2024

Update: no longer WIP - it is done

Context

Contains hardhat dev. env. setup and initial tests (market.t.ts and verifreg.t.ts).

When complete, it will include all ports of all rust integration tests (from ./testing/) on localnet setup with some tests being able to run on calibnet testnet.

Approach

  • Created Docker image with necessary scripts (./lib-dev/dev-env)
    • Note: rust tests can also be run from this container easing up the setup for the lib's maintainers (Mac M1 errors, ...)
  • Initialized hardhat tests (./hh-test) with config dependent on the network on which they're run

Affected issues:

@wertikalk wertikalk added the FIlecoin-solidity issue that we show on the board for Filecoin-solidity phase 2 label Apr 12, 2024
@wertikalk wertikalk self-assigned this Apr 12, 2024
@wertikalk wertikalk marked this pull request as ready for review May 8, 2024 07:41
@wertikalk wertikalk changed the title [WIP] Hardhat + Localnet Hardhat + Localnet May 8, 2024
Copy link
Collaborator

@snissn snissn left a comment

Choose a reason for hiding this comment

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

The local tests are able to run except for two specific errors which I have documented and would like @bojinovic to review. Also the calibnet test I think I am blocked related to an issue with the F3_ADDR value.

For the calibnet test I have this output, but I am thinking that the correct F3_ADDR value will fix and/or cleaning up the way that works so that F3_ADDR is inferred from the F3_PK.

export F3_ADDR=t3veh4pxl7337q2p6sqc2kmcun4tgqa7nupctohkd6yqo5iphlkk42yncrqswmbreek2xywcijpb6psk2cr6nq
# npx hardhat test --bail 


  Account Test
{
  fil: {
    address: 't3veh4pxl7337q2p6sqc2kmcun4tgqa7nupctohkd6yqo5iphlkk42yncrqswmbreek2xywcijpb6psk2cr6nq',
    idAddress: 111415n
  }
}
    1) Test 1: Integration test port
DBG: (Test 1: Integration test port) :::: 
	Deploying contracts... (account)

	Authenticating message...



  0 passing (2m)
  1 failing

  1) Account Test
       Test 1: Integration test port:
     Error: missing revert data (action="call", data=null, reason=null, transaction={ "data": "0xf5c62e87000000000000000000000000000000000000000000000000000000000001b3370000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000006084680e6fe64ebe64d718a2a46145631fd52129b5c66e8b6e4d6216c754a7bf38f992fc3971f7d0ea0a6c217d1df164e213e0c7d718cb7fcb22151393c142e306411a881249b061710bb74c9c315ec7a476a3c56363af4799b9c27a9d9552fca500000000000000000000000000000000000000000000000000000000000000608eabea2a4001061ac4c9fe3c517725b8829b159149a863b2a2320cc628d026a871d3cb34947371f384a9eb49ff9bd56a019fa70e10c06ac5ca93df3c1d6f54d540c57cbe2f5209cafdc12146d5d59172dd4d8359015e10584fa6327de0ce5a6a", "from": "0xf7931ff7FC55d19EF4A8139fa7E4b3F06e03F2e2", "to": "0xA8095879b566A20BE28bafd55ca4A60B74Ce3BfE" }, invocation=null, revert=null, code=CALL_EXCEPTION, version=6.12.1)
      at makeError (node_modules/ethers/src.ts/utils/errors.ts:694:21)
      at getBuiltinCallException (node_modules/ethers/src.ts/abi/abi-coder.ts:118:21)
      at Function.getBuiltinCallException (node_modules/ethers/src.ts/abi/abi-coder.ts:235:16)
      at JsonRpcProvider.getRpcError (node_modules/ethers/src.ts/providers/provider-jsonrpc.ts:979:32)
      at /var/lib/fil-sol/node_modules/ethers/src.ts/providers/provider-jsonrpc.ts:563:45
      at processTicksAndRejections (node:internal/process/task_queues:95:5)

docker compose up
```

Enter into the container from VS Code.
Copy link
Collaborator

Choose a reason for hiding this comment

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

After connecting to the docker container for the first time I needed to run

make install_solc_linux

Please either install that dependency in the docker build process or add a note to the README that it is a required step

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Updated the readme with make deps_install task that performs solc and yarn installs.

@snissn
Copy link
Collaborator

snissn commented May 23, 2024

there's also a failing forge test on this PR:

Failing tests:
Encountered 1 failing test in contracts/v0.8/tests/serialize.test.sol:FilAddressSerialize
[FAIL. Reason: assertion failed] test_1() (gas: 22037)

@wertikalk
Copy link
Collaborator Author

there's also a failing forge test on this PR:

Failing tests:
Encountered 1 failing test in contracts/v0.8/tests/serialize.test.sol:FilAddressSerialize
[FAIL. Reason: assertion failed] test_1() (gas: 22037)

This was a mistake commit. Was experimenting with deserialization.

contract FilAddressSerialize is Test {
    using FilecoinCBOR for *;

    function test_1() external {
        CommonTypes.FilAddress memory addr1 = CommonTypes.FilAddress({data: abi.encodePacked([uint8(0), 0x04, 0x22])});
        //0x5860000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000022
        CommonTypes.FilAddress memory addr2 = CommonTypes.FilAddress({data: abi.encode([0x66])});
        //0x584000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000066
        assertEq(addr2.serializeAddress(), abi.encodePacked([uint8(0), 0x04, 0x22]));
    }
}

Assert condition is wrong. Removed the test.

@snissn
Copy link
Collaborator

snissn commented May 24, 2024

thanks for these changes!

With the latest code I am trying to run and validate the tests so that we can merge the PR. I think that I need to rebuild my docker environment and will try that.

If you have other suggestions in the meantime, here is my output in the docker container:

# export HH_NETWORK=localnet && npx hardhat test --bail


  Account Test
    1) Test 1: Integration test port
DBG: (Test 1: Integration test port) :::: 
	Deploying contracts... (account)



  0 passing (22s)
  1 failing

  1) Account Test
       Test 1: Integration test port:
     Error: could not coalesce error (error={ "code": 1, "message": "failed to look up actor state nonce: resolution lookup failed (t410fsr4izgpov6wvycodvz53rorota5f4iwwtker3zq): resolve address t410fsr4izgpov6wvycodvz53rorota5f4iwwtker3zq: actor not found: validation failure" }, payload={ "id": 9, "jsonrpc": "2.0", "method": "eth_sendRawTransaction", "params": [ "0x02f

@snissn
Copy link
Collaborator

snissn commented May 25, 2024

Below is the latest result that I get running the calibnet tests. There are still some failures but i see more passing tests than failing tests!


  Account Test
    1) Test 1: Integration test port
DBG: (Test 1: Integration test port) :::: 
	Deploying contracts... (account)

	Authenticating message...


  Address Test
    ✔ Test 1: Integration test port (128912ms)

  BigInt Test
    ✔ Test 1: Integration test port (111494ms)

  CborDecode Test
    ✔ Test 1: Integration test port (221771ms)

  Datacap Test
    ✔ Test 1: Integration test port (110909ms)

  Deserialize Params Test
    ✔ Test 1: Integration test port (155954ms)

  Leb128 Test
    ✔ Test 1: Integration test port

  Market Test
    2) Test 1: State changes on Calibnet
DBG: (Test 1: State changes on Calibnet) :::: 
	Adding funds to balance...

    ✔ Test 2: Reading from Calibnet (6527ms)

  Market Cbot Test
    ✔ Test 1: Integration test port (142970ms)

  Precompiles Test
    ✔ Test 1: Integration test port (112920ms)

  Send Test
    ✔ Test 1: Integration test port (273521ms)

  Verifreg Test
    ✔ Test 1: Integration test port (166314ms)

  Market Tests (Beacon)
    3) "before all" hook for "Test 1: State changes on Calibnet (Before Upgrade)"

  Market Tests (Transparent)
    4) Test 1: State changes on Calibnet (Before Upgrade)
DBG::No logs for: 'Test 1: State changes on Calibnet (Before Upgrade)'
    5) Test 2: Reading from Calibnet (Before Upgrade)
DBG::No logs for: 'Test 2: Reading from Calibnet (Before Upgrade)'
    6) Test 1: State changes on Calibnet (After Upgrade)
DBG::No logs for: 'Test 1: State changes on Calibnet (After Upgrade)'
    7) Test 2: Reading from Calibnet (After Upgrade)
DBG::No logs for: 'Test 2: Reading from Calibnet (After Upgrade)'

  Market Tests (UUPS)
    8) "before all" hook for "Test 1: State changes on Calibnet (Before Upgrade)"


  11 passing (33m)
  8 failing

  1) Account Test
       Test 1: Integration test port:
     Error: missing revert data (action="call", data=null, reason=null, transaction={ "data": "0xf5c62e87000000000000000000000000000000000000000000000000000000000001b3370000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000060b179ef5bdedaffffdd5a8c245c7e3a9629329b7870ee56eff12dbbc5479cebaae70233d708b37d1ff57ccab813c22aa80a9ea5d8fd8df5364d3dc71e024e1ffd872d87c2c60cab54966aac4f6b1fee4b0b3c663dde7d6d525a26f57e569452c500000000000000000000000000000000000000000000000000000000000000608eabea2a4001061ac4c9fe3c517725b8829b159149a863b2a2320cc628d026a871d3cb34947371f384a9eb49ff9bd56a019fa70e10c06ac5ca93df3c1d6f54d540c57cbe2f5209cafdc12146d5d59172dd4d8359015e10584fa6327de0ce5a6a", "from": "0xf7931ff7FC55d19EF4A8139fa7E4b3F06e03F2e2", "to": "0xF5d6a1907c9eED68D9b497449A334387Aa1EabC1" }, invocation=null, revert=null, code=CALL_EXCEPTION, version=6.12.1)
      at makeError (node_modules/ethers/src.ts/utils/errors.ts:694:21)
      at getBuiltinCallException (node_modules/ethers/src.ts/abi/abi-coder.ts:118:21)
      at Function.getBuiltinCallException (node_modules/ethers/src.ts/abi/abi-coder.ts:235:16)
      at JsonRpcProvider.getRpcError (node_modules/ethers/src.ts/providers/provider-jsonrpc.ts:979:32)
      at /var/lib/fil-sol/node_modules/ethers/src.ts/providers/provider-jsonrpc.ts:563:45
      at processTicksAndRejections (node:internal/process/task_queues:95:5)

  2) Market Test
       Test 1: State changes on Calibnet:

      AssertionError: expected '0x00' to equal '0x0de0b6b3a7640000'
      + expected - actual

      -0x00
      +0x0de0b6b3a7640000
      
      at /var/lib/fil-sol/hh-test/calibnet/e2e/market.t.ts:62:48
      at step (hh-test/calibnet/e2e/market.t.ts:33:23)
      at Object.next (hh-test/calibnet/e2e/market.t.ts:14:53)
      at fulfilled (hh-test/calibnet/e2e/market.t.ts:5:58)
      at processTicksAndRejections (node:internal/process/task_queues:95:5)

  3) Market Tests (Beacon)
       "before all" hook for "Test 1: State changes on Calibnet (Before Upgrade)":
     Error: Contract at 0x4644Aed07481028F0AA298432F2c58cf51228642 doesn't look like a beacon

Deploy a beacon using deployBeacon().
      at Proxy.deployBeaconProxy (node_modules/@openzeppelin/hardhat-upgrades/src/deploy-beacon-proxy.ts:71:13)
      at processTicksAndRejections (node:internal/process/task_queues:95:5)

  4) Market Tests (Transparent)
       Test 1: State changes on Calibnet (Before Upgrade):
     Error: could not decode result data (value="0x", info={ "method": "get_balance", "signature": "get_balance((bytes))" }, code=BAD_DATA, version=6.12.1)
      at makeError (node_modules/ethers/src.ts/utils/errors.ts:694:21)
      at assert (node_modules/ethers/src.ts/utils/errors.ts:715:25)
      at Interface.decodeFunctionResult (node_modules/ethers/src.ts/abi/interface.ts:916:15)
      at staticCallResult (node_modules/ethers/src.ts/contract/contract.ts:346:35)
      at processTicksAndRejections (node:internal/process/task_queues:95:5)
      at async staticCall (node_modules/ethers/src.ts/contract/contract.ts:303:24)
      at async Proxy.get_balance (node_modules/ethers/src.ts/contract/contract.ts:351:41)

  5) Market Tests (Transparent)
       Test 2: Reading from Calibnet (Before Upgrade):
     Error: could not decode result data (value="0x", info={ "method": "get_deal_data_commitment", "signature": "get_deal_data_commitment(uint64)" }, code=BAD_DATA, version=6.12.1)
      at makeError (node_modules/ethers/src.ts/utils/errors.ts:694:21)
      at assert (node_modules/ethers/src.ts/utils/errors.ts:715:25)
      at Interface.decodeFunctionResult (node_modules/ethers/src.ts/abi/interface.ts:916:15)
      at staticCallResult (node_modules/ethers/src.ts/contract/contract.ts:346:35)
      at processTicksAndRejections (node:internal/process/task_queues:95:5)
      at async staticCall (node_modules/ethers/src.ts/contract/contract.ts:303:24)
      at async Proxy.get_deal_data_commitment (node_modules/ethers/src.ts/contract/contract.ts:351:41)

  6) Market Tests (Transparent)
       Test 1: State changes on Calibnet (After Upgrade):
     Error: Contract at 0x8E131be7aA417F3E04aD10E7d044646c896aC39b doesn't look like an ERC 1967 proxy with a logic contract address


      at getImplementationAddress (node_modules/@openzeppelin/upgrades-core/src/eip-1967.ts:29:11)
      at processTicksAndRejections (node:internal/process/task_queues:95:5)
      at async processProxyImpl (node_modules/@openzeppelin/hardhat-upgrades/src/utils/validate-impl.ts:23:26)
      at async validateProxyImpl (node_modules/@openzeppelin/hardhat-upgrades/src/utils/validate-impl.ts:62:30)
      at async deployProxyImpl (node_modules/@openzeppelin/hardhat-upgrades/src/utils/deploy-impl.ts:72:3)
      at async Proxy.upgradeProxy (node_modules/@openzeppelin/hardhat-upgrades/src/upgrade-proxy.ts:38:32)

  7) Market Tests (Transparent)
       Test 2: Reading from Calibnet (After Upgrade):
     Error: Contract at 0x8E131be7aA417F3E04aD10E7d044646c896aC39b doesn't look like an ERC 1967 proxy with a logic contract address


      at getImplementationAddress (node_modules/@openzeppelin/upgrades-core/src/eip-1967.ts:29:11)
      at processTicksAndRejections (node:internal/process/task_queues:95:5)
      at async processProxyImpl (node_modules/@openzeppelin/hardhat-upgrades/src/utils/validate-impl.ts:23:26)
      at async validateProxyImpl (node_modules/@openzeppelin/hardhat-upgrades/src/utils/validate-impl.ts:62:30)
      at async deployProxyImpl (node_modules/@openzeppelin/hardhat-upgrades/src/utils/deploy-impl.ts:72:3)
      at async Proxy.upgradeProxy (node_modules/@openzeppelin/hardhat-upgrades/src/upgrade-proxy.ts:38:32)

  8) Market Tests (UUPS)
       "before all" hook for "Test 1: State changes on Calibnet (Before Upgrade)":
     Error: Timed out waiting for implementation contract deployment to address 0x197dd6B8952aED4F7Cd63Ea1e0502e0b506138aa with transaction 0xf8ad7674e9cde5fc1c30fff71c5dc0fbd3b2e1df888e3c608bfb13580b40cb0b

Run the function again to continue waiting for the transaction confirmation. If the problem persists, adjust the polling parameters with the timeout and pollingInterval options.
      at waitAndValidateDeployment (node_modules/@openzeppelin/upgrades-core/src/deployment.ts:239:17)
      at async fetchOrDeployGeneric (node_modules/@openzeppelin/upgrades-core/src/impl-store.ts:86:5)
      at async deployImpl (node_modules/@openzeppelin/hardhat-upgrades/src/utils/deploy-impl.ts:109:22)
      at async deployProxyImpl (node_modules/@openzeppelin/hardhat-upgrades/src/utils/deploy-impl.ts:77:9)
      at async Proxy.deployProxy (node_modules/@openzeppelin/hardhat-upgrades/src/deploy-proxy.ts:48:28)



make: *** [Makefile:154: test_hh_calibnet] Error 8

@@ -30,6 +30,11 @@ import "../utils/Errors.sol";
/// @notice It imports the library and create a callable method for each method in the library
/// @author Zondax AG
contract DataCapApiTest {
address _n;
address _n2;
function dummy() public view returns (uint) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

this appears unused - please remove

@snissn snissn mentioned this pull request Jun 3, 2024
4 tasks
@wertikalk
Copy link
Collaborator Author

closing in favor of: #63

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
FIlecoin-solidity issue that we show on the board for Filecoin-solidity phase 2
Projects
Development

Successfully merging this pull request may close these issues.

[M4] Test suite expansion - Hardhat tests
2 participants