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 lib tests to use dryRun to avoid changing state #509

Open
bvotteler opened this issue Dec 21, 2022 · 0 comments
Open

Refactor lib tests to use dryRun to avoid changing state #509

bvotteler opened this issue Dec 21, 2022 · 0 comments
Labels

Comments

@bvotteler
Copy link
Contributor

bvotteler commented Dec 21, 2022

We should be able to refactor some of our integration tests to use dryRun where the tests do not rely on a changed state for follow up actions.

The approach below can be used to check the success of a transaction without modifying the state of the blockchain

let request_redeem = api.tx.redeem.requestRedeem(2000, {P2WPKHv0: '0x01197bcaf42e278fcca2b55275cd64b25d240e7c'}, vault_id);
    const transactionAPI = new DefaultTransactionAPI(api, userKeyring);
    
    let myNonce = await api.rpc.system.accountNextIndex(userKeyring.address);
    const signed = request_redeem.sign(userKeyring, { nonce:  myNonce});

    const result = await signed.dryRun(transactionAPI.getAccount()!);
    
    // A technically valid but failing transaction returns Ok(Err(...))
    const resultOk = result.isOk && result.asOk.isOk;

    console.log("isOk", resultOk);
@bvotteler bvotteler added enhancement New feature or request prio:low and removed enhancement New feature or request labels Dec 21, 2022
@nud3l nud3l added this to Backlog Jan 3, 2023
@nud3l nud3l moved this to Todo ⏳ in Backlog Jan 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Todo
Development

No branches or pull requests

1 participant