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

Connect gclient with gtest #3895

Closed
clearloop opened this issue Apr 16, 2024 · 0 comments · May be fixed by #4016
Closed

Connect gclient with gtest #3895

clearloop opened this issue Apr 16, 2024 · 0 comments · May be fixed by #4016
Assignees
Labels
C1-feature Feature request

Comments

@clearloop
Copy link
Contributor

clearloop commented Apr 16, 2024

Problem to Solve

gtest and gclient have different logic layout in users' code that users have to write client-style code for twice for

  • testing
  • developing related tools

for their programs

Possible Solution

keep the current logic of gclient, introduce a micro provider for the runtime of gtest in gclient

abstraction

//! library-side

trait Provider {
  async fn upload_program() -> Result<()>;
}

impl Provider for Rpc {}

impl Provider for Gtest {}

for users' client library

//! my-project/client/src/lib.rs

struct Client<T: Provider>;

/// Shared logic for both testing and production
impl<T: Provider> Client<T> {
  pub fn upload_program(self) -> Result<()>;
}

impl Client<Rpc> {
  pub fn complex_logic_for_production();
}

/// Logic for deployment in production
pub fn deploy_prod() -> Result<()> {
    let client: Client<Rpc> = Client::rpc();
    client.upload_code()
}

/// Same logic for testing deployment
#[tokio::test]
async fn test_deploy() -> Result<()> {
    let client: Client<GTest> = Client::gtest();
    client.upload_code()
}

Notes

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C1-feature Feature request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant