-
Notifications
You must be signed in to change notification settings - Fork 4
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
base: main
Are you sure you want to change the base?
Conversation
Rename to replay_back_and_updating
Conflicts: .github/workflows/ci.yml
.github/workflows/ci.yml
Outdated
@@ -60,6 +61,8 @@ jobs: | |||
run: cargo fmt -- --check | |||
tests: | |||
runs-on: kuberunner | |||
env: | |||
NAME: gear_node${{ github.run_id }}_${{ github.run_number }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NAME: gear_node${{ github.run_id }}_${{ github.run_number }} | |
NODE_CONTAINER_NAME: gear_node${{ github.run_id }}_${{ github.run_number }} |
.github/workflows/ci.yml
Outdated
- 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; } |
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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)); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's this IP?
There was a problem hiding this comment.
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
#[tokio::test] | ||
async fn init_mainnet() -> Result<()> { | ||
init(Network::Mainnet).await | ||
init(Network::Mainnet, "https://www.lightclientdata.org".into()).await |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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<()> { |
There was a problem hiding this comment.
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<()> { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
Conflicts: gear-programs/erc20-relay/app/tests/gclient.rs
Conflicts: .github/workflows/ci.yml
Conflicts: .github/workflows/ci.yml
Resolves #161
@gear-tech/dev