Skip to content
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

Client integration tests against framework modules #677

Merged
merged 37 commits into from
Oct 16, 2024

Conversation

andygolay
Copy link
Contributor

@andygolay andygolay commented Oct 10, 2024

Summary

  • Update client tests so they run against the Movement framework in our fork of aptos-core

Changelog

  • Added client_l2move_l1move and client_l1move_l2move files with tests against framework.
  • Fix get_bridge_transfer_details_counterparty which was returning a struct with initiator and recipient address types reversed. Implemented a BridgeTransferDetailsCounterparty struct to achieve this.

Testing

To run client tests:

  1. Navigate to the root of the movement repo, checkout the andygolay/framework-client-tests branch, and start a local Suzuka node:
CELESTIA_LOG_LEVEL=FATAL CARGO_PROFILE=release CARGO_PROFILE_FLAGS=--release nix develop --extra-experimental-features nix-command --extra-experimental-features flakes --command bash  -c "just bridge native build.setup.eth-local.celestia-local --keep-tui"

Note, if you have any .movement directories present, e.g. when re-running tests, the directories must be deleted before starting the node.

  1. In the generated .movement directory, there will be a config.yaml. In that file, change f90391c81027f03cdea491ed8b36ffaced26b6df208a9b569e5baf2590eb9b16 to 0xA550C18 so the file looks like:
---
profiles:
  default:
    network: Custom
    private_key: "0x0000000000000000000000000000000000000000000000000000000000000001"
    public_key: "0x4cb5abf6ad79fbf5abbccafcc269d85cd2651ed4b885b5869f241aedf0a5ba29"
    account: "0xA550C18"
    rest_url: "http://0.0.0.0:30731/"
    faucet_url: "http://0.0.0.0:30732/"
  1. Run each set of Movement client tests:

L1 Move to L2 Move:

rust_backtrace=1 cargo test --test client_l1move_l2move -- --nocapture --test-threads=1

L2 Move to L1 Move:

rust_backtrace=1 cargo test --test client_l2move_l1move -- --nocapture --test-threads=1

Outstanding issues

  • The refund and abort tests have a sleep of 20 seconds before calling refund or abort. Just a heads up.
  • If your node has been running for awhile, L1 --> L2 tests are sometimes flaky at the extract_bridge_transfer_id_framework call, where it won't find a matching transaction. I don't know why that happens but restarting the node and re-running steps 1 and 2 of the above test directions appears to fix it so tests pass.
  • There was an issue with not finding a coin store for the recipient in client_l1move_l2_move test_movement_client_complete_transfer. The fix I implemented for it is rather hacky. That test should be cleaned up but perhaps in a later iteration.

@0xmovses
Copy link
Contributor

This looks good, I will do a thorough review once we have the governance on testnet devnet issue resolved for local client tests.

@andygolay andygolay marked this pull request as ready for review October 16, 2024 11:21
Copy link
Contributor

@0xmovses 0xmovses left a comment

Choose a reason for hiding this comment

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

Thank you for this!

Main thing here is that the client_l1move_l2move.rs tests are testing with the old AtomicBridgeInitiator/ Counterparty contract I believe. The abis used in the client handler fns are those contracts not AtomicBridgeInitiatorMOVE.

However, this successfully proves that clients are able to to call the framework functions as expected.

The lack of configurability of ABI on ETH side could cause issues. We assume right now they are the same, which is why this works, but if there were updates to the AtomicBridgeInitiatorMOVE contract, the Clients would break, becase they are always using the sol type AtomicBridgeInitiator.

Before testing e2e we should add this configurability. I'm happy to add this onto this PR if you like while we switch.

bridge_transfer_id.extend_from_slice(random_suffix.as_bytes());

Self {
initiator: b"32Be343B94f860124dC4fEe278FDCBD38C102D88".to_vec(),
Copy link
Contributor

Choose a reason for hiding this comment

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

Where does this address come from?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's the dummy valid EIP-55 address used in the framework modules.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll add a comment.

) -> Result<(), anyhow::Error> {
let _ = tracing_subscriber::fmt().with_max_level(tracing::Level::DEBUG).try_init();

let _ = tracing_subscriber::fmt().with_max_level(tracing::Level::DEBUG).try_init();
Copy link
Contributor

Choose a reason for hiding this comment

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

Dup line here.

}

#[tokio::test]
async fn test_eth_client_should_successfully_call_initiate_transfer_only_weth() {
Copy link
Contributor

Choose a reason for hiding this comment

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

These should be testing the MOVE.sol contracts seems like they are initialised currently with the old Initiator contracts. In other words this it AtomicBridgeInitiator -> COIN. Right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I didn't touch the Eth client tests, I think I had gotten it in my mind that we were using the E2E tests to tests the .sol contracts; I was just using the client tests to check the Movement client against the framework.

One thing I notice on main is that there aren't Eth tests in client_movement_eth` anymore. Not sure why or how they disappeared.

Copy link
Contributor

Choose a reason for hiding this comment

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

Don't worry about this, I'm going to make sure the .sol MOVE contrats are supported by the relayer in a seperate PR. Right now it only uses the old ABIs for WETH contracts.

@0xmovses
Copy link
Contributor

0xmovses commented Oct 16, 2024

On second thought, let me add the configurability in a follow up PR, to reduce the scope creep on this. I will add a fast followup PR after this goes in.

@andygolay
Copy link
Contributor Author

On second thought, let me add the configurability in a follow up PR, to reduce the scope creep on this. I will add a fast followup PR after this goes in.

Sounds good, looking into the diff to see how to fix the E2E test

@0xmovses
Copy link
Contributor

I followed the testing steps written above and all the client tests are passing 🥳

@0xmovses
Copy link
Contributor

0xmovses commented Oct 16, 2024

I've triggered all the CI to ensure that bumping aptos doesn't introduce any failure, it shouldn't as its only the framework code. After those pass will be good to approve this.

@0xmovses 0xmovses self-requested a review October 16, 2024 18:34
@0xmovses 0xmovses merged commit 70ae3c1 into main Oct 16, 2024
262 of 264 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants