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

Name-registry: Refactor get_timestamp_and_call to get the timestamp from a transaction #684

Open
K1-R1 opened this issue May 22, 2023 · 0 comments
Labels
App: Name Registry Label used to filter for the app issue Awaiting SDK feature(s) SDK does not support desired functionality, yet

Comments

@K1-R1
Copy link
Member

K1-R1 commented May 22, 2023

Once fuels-rs 0.42.0 is available, the test utility function get_timestamp_and_call can be refactored in order to get the timestamp from a transaction, as opposed to a hard-coded value. An example of how the refactor might look:

pub(crate) async fn get_timestamp_and_call<T, D>(
    handler: ContractCallHandler<T, D>,
) -> (FuelCallResponse<D>, u64)
where
    T: FuelAccount,
    D: Tokenizable + Debug,
{
    let call_response = handler.call().await.unwrap();
    let tx_id = call_response.tx_id;

    let provider = handler.account.try_provider().unwrap();
    let tx_response = provider
        .get_transaction_by_id(&tx_id)
        .await
        .unwrap()
        .unwrap();

    let time = tx_response.time.unwrap().timestamp().try_into().unwrap();

    (call_response, time)
}

This requires the release of fuels-rs 0.42.0 in order to access the tx_id from a FuelCallResponse, made available by:
FuelLabs/fuels-rs#734

This should also allow for testing on currently ignored tests

@K1-R1 K1-R1 added App: Name Registry Label used to filter for the app issue Awaiting SDK feature(s) SDK does not support desired functionality, yet labels May 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
App: Name Registry Label used to filter for the app issue Awaiting SDK feature(s) SDK does not support desired functionality, yet
Projects
None yet
Development

No branches or pull requests

1 participant