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

refactor(tests): Spawn node for the tests #195

Open
wants to merge 18 commits into
base: main
Choose a base branch
from
Open

Conversation

gshep
Copy link
Member

@gshep gshep commented Nov 4, 2024

Resolves #161

@gear-tech/dev

@mertwole mertwole marked this pull request as draft November 5, 2024 05:34
@gshep gshep requested a review from mertwole November 7, 2024 11:03
@gshep gshep marked this pull request as ready for review November 7, 2024 11:03
@gshep gshep changed the title Draft: refactor(tests): Spawn node for the tests refactor(tests): Spawn node for the tests Nov 7, 2024
@@ -60,6 +61,8 @@ jobs:
run: cargo fmt -- --check
tests:
runs-on: kuberunner
env:
NAME: gear_node${{ github.run_id }}_${{ github.run_number }}
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
NAME: gear_node${{ github.run_id }}_${{ github.run_number }}
NODE_CONTAINER_NAME: gear_node${{ github.run_id }}_${{ github.run_number }}

- name: Run tests
run: cargo test --release --all-targets
run: cargo test --release --workspace --exclude erc20-relay-app --all-targets && cargo test --release --package erc20-relay-app -- --nocapture || { exit_code=$?; if [ x$exit_code != x0 ]; then docker logs --details $NAME; docker stop $NAME; fi; exit $exit_code; }
Copy link
Member

Choose a reason for hiding this comment

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

I suppose there's no much sense in printing logs as you can easily re-run the failing test locally and see the logs

salt.to_le_bytes()
}

// The struct purpose is to avoid the following error:
Copy link
Member

Choose a reason for hiding this comment

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

I think this comment causes more questions then gives answers - what this error means? Why it occur? How this struct resolves this problem?

) -> sails_rs::errors::Result<
impl future::Future<Output = sails_rs::errors::Result<(ActorId, Vec<u8>)>>,
> {
let _lock = LOCK.lock().await;
Copy link
Member

Choose a reason for hiding this comment

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

What's the point of acquiring lock here?

Copy link
Member Author

Choose a reason for hiding this comment

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

The method is a mutating one so the access should be synchronized

use vft::vft_gateway;

async fn spin_up_node() -> (GClientRemoting, GearApi, CodeId, GasUnit) {
static LOCK: Mutex<(u32, Option<CodeId>)> = Mutex::const_new((0, None));
Copy link
Member

Choose a reason for hiding this comment

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

Why salt and code ID are in one mutex?

Copy link
Member Author

Choose a reason for hiding this comment

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

There are no other arguments to introduce a new one though. Actually the mutex should store something like struct Context with all required fields but it's too tempting to use tuples )


const RPC_URL: &str = "http://127.0.0.1:5052";
const RPC_URL: &str = "http://34.159.93.103:50000";
Copy link
Member

Choose a reason for hiding this comment

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

What's this IP?

Copy link
Member Author

Choose a reason for hiding this comment

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

It is our Beacon API endpoint for Holesky

relayer/src/ethereum_checkpoints/tests/mod.rs Outdated Show resolved Hide resolved
#[tokio::test]
async fn init_mainnet() -> Result<()> {
init(Network::Mainnet).await
init(Network::Mainnet, "https://www.lightclientdata.org".into()).await
Copy link
Member

Choose a reason for hiding this comment

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

I think that connecting to some RPC in tests is not a good idea as our CI depends on stability of some third-party servers

Copy link
Member Author

Choose a reason for hiding this comment

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

settle up the issue by using archive data

#[tokio::test]
async fn init_and_updating() -> Result<()> {
let beacon_client = BeaconClient::new(RPC_URL.to_string(), None)
async fn replay_back_and_updating() -> Result<()> {
Copy link
Member

Choose a reason for hiding this comment

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

So this test is expected to run ~15 minutes I suppose? (I've checked that CI time is 20 min. for tests now)

#[tokio::test]
async fn init_and_updating() -> Result<()> {
let beacon_client = BeaconClient::new(RPC_URL.to_string(), None)
async fn replay_back_and_updating() -> Result<()> {
Copy link
Member

Choose a reason for hiding this comment

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

Can you shortly describe what happened with init_and_updating and replaying_back tests? Why it's a single test now and why is it so much less code?

Copy link
Member Author

Choose a reason for hiding this comment

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

Frankly speaking nothing special. Both tests were just merged into one and a bit of refactoring.

@gshep gshep requested a review from mertwole November 26, 2024 18:26
Conflicts:
	.github/workflows/ci.yml
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.

Refactor erc20-relay tests to spawn node
2 participants