Upgrade to Pro — share decks privately, control downloads, hide ads and more …

The Art of Test Automation for Cryptocurrency Wallets

The Art of Test Automation for Cryptocurrency Wallets

The Art of Test Automation for Cryptocurrency Wallets
Test Automation Days
Rotterdam
May 2023

Peter Yinusa

May 29, 2023
Tweet

More Decks by Peter Yinusa

Other Decks in Technology

Transcript

  1. Agenda 1. Fundamentals of a Wallet 2. Understanding the Challenges

    3. Implementing Best Practices 4. Enhancing Your Test Suite 5. Dealing with Flaky Tests
  2. What is a Crypto Wallet A cryptocurrency wallet is a

    software program that holds your public and private keys and interacts with various blockchains enabling you to send and receive digital assets, including cryptocurrencies and NFTs (non-fungible tokens).
  3. Reveal Secret Recovery Phrase 1. automation 2. framework 3. parallel

    4. execution 5. isolation 6. blockchain 7. assertion 8. element 9. locator 10. mock 11. flaky 12. extension
  4. Confirm Secret Recovery Phrase 1. automation 2. framework 3. ______

    4. _______ 5. isolation 6. blockchain 7. assertion 8. _______ 9. locator 10. mock 11. flaky 12. extension
  5. Confirm Secret Recovery Phrase 1. automation 2. framework 3. parallel

    4. _______ 5. isolation 6. blockchain 7. assertion 8. _______ 9. locator 10. mock 11. flaky 12. extension
  6. Confirm Secret Recovery Phrase 1. automation 2. framework 3. parallel

    4. execution 5. isolation 6. blockchain 7. assertion 8. _______ 9. locator 10. mock 11. flaky 12. extension
  7. Confirm Secret Recovery Phrase 1. automation 2. framework 3. parallel

    4. execution 5. isolation 6. blockchain 7. assertion 8. element 9. locator 10. mock 11. flaky 12. extension
  8. Hot Wallets • Connected to the internet • Web-based, desktop

    & mobile wallets • Free Cold Wallets • Offline • Paper & hardware wallets • Expensive Types of Wallets
  9. Non-Custodial Wallets • You have complete control of your private

    keys • Lose your private key/secret recovery phrase, and you lose access to your assets • No KYC or AML processes or procedures Types of Wallets Custodial Wallets • Third-party has control of private keys • Recovery mechanisms in place so you can regain access to your wallet • KYC and AML processes and procedures
  10. Many wallets rely heavily on browser extensions to process transactions

    and interact with dApps (decentralised applications). Other popular extensions; • Loom – Screen Recorder & Screen Capture • Zenhub - Project Management Inside GitHub • Grammarly - Grammar Checker and Writing App • LastPass - Password Manager Discovering Crypto Wallets
  11. Blockchain Environment Cost • Pay gas fees to cover the

    computational effort required to execute the specific operation on the network Speed • Blocks are committed once every twelve seconds Control • No entity has control over the network
  12. Third Party Integrations Client Errors • An error caused by

    the user (e.g. rate limiting) Server Errors • An error caused by the server (e.g. an outage)
  13. Third Party Applications MetaMask makes a global JavaScript API available

    on websites by leveraging the window.ethereum provider object. This API abstracts the complexities of interacting with the Ethereum blockchain, providing a unified way for dApps to read data from the blockchain, suggest transactions, and interact with smart contracts.
  14. Test Names / / ❌ Transaction should add Bob to

    the address book, import TST token and send 1 TST to Bob / / ✅ Address Book adds Bob to the address book Token imports TST token Transaction sends 1 TST to Bob
  15. Organisation / / ❌ tests - add-contact.spec.js - import-token.spec.js -

    send-token.spec.js / / ✅ tests - address book - add-contact.spec.js - token - import-token.spec.js - transaction - send-token.spec.js
  16. / / ✅ Import token Step 1 Step 2 Send

    token Step 1 Step 2 Step 3 / / ❌ Import token Step 1 Step 2 Send token Step 3 Step 4 Step 5 Test Coupling
  17. Controlling the Blockchain / / ❌ Network name: Ethereum Mainnet

    RPC URL: https://mainnet.infura.io/v3/ Chain ID: 1 Currency symbol: ETH Block explorer: https://etherscan.io / / ✅ Network name: Localhost 8545 RPC URL: http://localhost:8545 Chain ID: 1337 Currency symbol: ETH Block explorer: https://etherscan.io
  18. / / ❌ 1. Open the application in a new

    window 2. Switch to the new window 3. Click the Connect button 4. Switch to the popup window 5. Connect the wallet to the application 6. Switch back to the application 7. Click the Deploy button 8. Switch to the popup window 9. Click the Confirm button 10. Switch back to the application 11. Wait for the deployment to complete Controlling the Blockchain / / ✅ 1. const contractFactory = new ContractFactory(abi, bytecode, signer); 2. const contract = await contractFactory.deploy(); 3. await contract.deployTransaction.wait();
  19. Controlling Application State / / ❌ new FixtureBuilder().build() / /

    ✅ new FixtureBuilder() .withAddressBookControllerContactBob() .withTokensControllerTestToken() .build()
  20. Accessing External Sites / / ❌ https://example.com/ / / ⚠

    https://metamask.github.io/test-dapp/ / / ✅ http://localhost:8080
  21. Wait for Commands / / ❌ await new Promise((resolve) =>

    setTimeout(resolve, time)); / / ✅ await driver.wait(condition, timeout);
  22. Element Locators / / ❌ await driver.findElement( 'footer > button:nth-of-type(2)');

    / / ⚠ await driver.findElement({ text: 'Confirm', tag: 'button' }); / / ✅ await driver.findElement( '[data-testid="confirm-button"]');
  23. Assertions / / ❌ await driver.findElement({ text: 'Send TST' });

    / / ✅ const item = await driver.findElement( '[data-testid="transaction-list-item"]'); assert.equal(await item.getText(), 'Send TST');