quality assurance in blockchain - stc...

27
By Arpan Sarkar, Senior Manager – Business Development & Jibendu Narayan Mazumder – Associate Director – Business Development Cognizant Technology Solutions Quality Assurance in Blockchain

Upload: others

Post on 06-Jun-2020

2 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Quality Assurance in Blockchain - STC 2019qaistc.com/2017/wp-content/uploads/2017/12/stc-2017_final-present… · Quality Assurance in Blockchain. 2 Abstract. Blockchain is rapidly

By Arpan Sarkar, Senior Manager – Business Development&

Jibendu Narayan Mazumder – Associate Director – Business Development

Cognizant Technology Solutions

Quality Assurance in Blockchain

Page 2: Quality Assurance in Blockchain - STC 2019qaistc.com/2017/wp-content/uploads/2017/12/stc-2017_final-present… · Quality Assurance in Blockchain. 2 Abstract. Blockchain is rapidly

2

AbstractBlockchain is rapidly revolutionizing the way enterprises conduct their business processes. A new paradigm oftrustless business transactions is fast evolving that needs no intervention from central regulatory authorities. And,this is made possible with a decentralized peer-to-peer network of nodes, each maintaining a local copy oftransaction ledger and mutually synchronizing on a near real-time basis.

The genesis of this Distributed Ledger Technology was in Bitcoin, but gradually others have evolved - Ethereum,Hyperledger, Corda, Monax etc. These have varying features/tech stack, but ensures security / immutability /decentralization to align to trustless model. Based on respective needs, enterprises across industries are choosingfrom this basket. Be it Document Management or Trade Finance, Blockchain in ubiquitous today.

Quality Assurance in Blockchain needs close examination because of its fundamental difference from TraditionalQA. Blockchain QA involves a balanced combination of:

• White-box Testing – Involves testing the core of the framework (e.g. automated unit testing of smart contractsusing frameworks like Embark/Truffle/Dapple/Populus)

• Grey-box Testing - Involves testing integrations between blockchain framework & applications (e.g. APITesting for validating access control, wallet balances etc)

• Black-box Testing - Involves testing of blockchain application functionalities / business rules (e.g. issuance ofcryptocurrencies)

• Non-Functional Testing – Involves performance and security testing (e.g. validation of performance onpumping large transaction volume into the blockchain network, secured blockchain access, wallet signature etc.)

Additionally, this paper will also explore areas like Blockchain-as-a-Service, Blockchain Cloud, Blockchain IoT etc.

Page 3: Quality Assurance in Blockchain - STC 2019qaistc.com/2017/wp-content/uploads/2017/12/stc-2017_final-present… · Quality Assurance in Blockchain. 2 Abstract. Blockchain is rapidly

3

Overview Of Blockchain

What is it?

Blockchain is a decentralized ledger of all transactions across a peer-to-peernetwork. Using this technology, participants can confirm transactions without theneed for a central certifying authority. Potential applications include fund transfers,setting trades, voting etc.

The first blockchain was conceptualized by Satoshi Nakamoto in 2008 and implemented the following year as a core component of the digital currency BITCOIN, where it serves as the public ledger for all transactions

17.9 billion US$

An analysis by Gartner predicts that by 2020, the annual traded volume of electronic currency transactions will exceed 5% of all electronically traded transactions, amounting to

20 billion US$

According to a study by Santander InnoVentures, banks' transactional costs could be reduced by

using Blockchain technologies.

Page 4: Quality Assurance in Blockchain - STC 2019qaistc.com/2017/wp-content/uploads/2017/12/stc-2017_final-present… · Quality Assurance in Blockchain. 2 Abstract. Blockchain is rapidly

4

Key Tenets Of Blockchain

Distributed Open Ledger

Network Consensus

Secured Transactio

ns

Smart Contracts

Everyone in the network can see the ledger and every node in the network has a synchronized copy of the digital ledger

No transaction can be added without consensus from everyone in the network. Special nodes, called Miners, can validate and add a transaction in a block and add to the blockchain

Private-Public key cryptography makes

transactions are secure, authenticated & verifiable

Business logic (rules) embedded in Blockchain

that can be triggered when certain conditions

are met

Page 5: Quality Assurance in Blockchain - STC 2019qaistc.com/2017/wp-content/uploads/2017/12/stc-2017_final-present… · Quality Assurance in Blockchain. 2 Abstract. Blockchain is rapidly

5

Benefits & Potential Applications

Cost Reduction

Increased Transparency and “Third Party” Elimination

Reduced Settlement Time

Secure Transaction Ledger with no double spending or transaction repudiation

Healthcare

Financial Services

Faster, cheaper payments could save billions of dollars from transaction costs while improving transparency

Patients’ encrypted health information could be shared with multiple providers without the risk of privacy breaches

File Storage

Peer to Peer file sharing networks removes the need for centralized databases and heavy storage areas

Using a blockchain code constituents could cast votes via smartphone, tablet or computer resulting in immediately verifiable results Voting

Page 6: Quality Assurance in Blockchain - STC 2019qaistc.com/2017/wp-content/uploads/2017/12/stc-2017_final-present… · Quality Assurance in Blockchain. 2 Abstract. Blockchain is rapidly

6

First Generation Blockchains Second Generation Blockchains

Blockchains based on cryptocurrencies and asset ownership

Blockchains based on smart contracts and autonomous decisions

Example - Bitcoin Example - Ethereum

Public Public, Permissioned, Private

First and Second Generation Blockchains

Page 7: Quality Assurance in Blockchain - STC 2019qaistc.com/2017/wp-content/uploads/2017/12/stc-2017_final-present… · Quality Assurance in Blockchain. 2 Abstract. Blockchain is rapidly

7

A Deep Dive Into The Key Tenets

Page 8: Quality Assurance in Blockchain - STC 2019qaistc.com/2017/wp-content/uploads/2017/12/stc-2017_final-present… · Quality Assurance in Blockchain. 2 Abstract. Blockchain is rapidly

8

Distributed Open Ledger

Centralized Body

(e.g. Bank)

Centralized Ledger

Every node in the decentralized system has a copy of the ledger (blockchain)

No centralized “official” copy exists and no user is trusted more than the other

Transactions are broadcast to network

Eliminates risk of data stored centrally

Decentralized Ledger

Page 9: Quality Assurance in Blockchain - STC 2019qaistc.com/2017/wp-content/uploads/2017/12/stc-2017_final-present… · Quality Assurance in Blockchain. 2 Abstract. Blockchain is rapidly

9

Network Consensus

# of nodes required to validate a transaction depends on the Distributed Ledger Technology being used :

1 for Open Chain Simple Majority for Juno Super Majority for Ripple All nodes for Casper Configurable for Stellar

Consensus Rules

Consensus Mechanism is central to the functioning of Blockchain – there is no need to “trust” a central authority

Addition of block to the existing Blockchain

Network Consensus

Miner broadcasts transition and nonce value to the network

Miner Node validates transaction and

solves Proof-of-Work

Syntax validation Transaction validation Nonce validation Timestamp validation Block size validation First transaction validation (Coinbase)

Validations for Consensus

Page 10: Quality Assurance in Blockchain - STC 2019qaistc.com/2017/wp-content/uploads/2017/12/stc-2017_final-present… · Quality Assurance in Blockchain. 2 Abstract. Blockchain is rapidly

10

Secured Transactions

Wallet & Transaction

Security

Sender

Private KeyFor signatures

Public KeyFor addresses

Message

Key Generation

Encryption Algorithm

Public Key

CiphertextReceiver

Message

Public Key

• SHA256/SHA160 for crypto.hashing

• Base58/Base58Check encodingfor data compression

Block and Chain

Security

Block # 1

Nonce - 16651

Coinbase - $100 -> AndersTransactions:

NULL

Prev Txn – 000000….

Hash – 000043D….

Block # 2

Nonce - 37284

Coinbase - $100 -> John

Transactions:

$10 from Anders to Sophie$5 from John to Sophie

Prev Txn – 000043D….

Hash – 0000A5A….

Every block identified by hash (SHA 256) value with Coinbase, Transactions, Previous transaction as inputs

All transactions hashed (Merkle root)

All these hashes are Base58 encoded

Nonce is a 32 bit field whose value is set so that hash of a block has run of leading 0s

Any alteration in any block will make subsequent blocks invalid

Page 11: Quality Assurance in Blockchain - STC 2019qaistc.com/2017/wp-content/uploads/2017/12/stc-2017_final-present… · Quality Assurance in Blockchain. 2 Abstract. Blockchain is rapidly

11

Smart Contracts

A computer program capable of facilitating, executing and enforcing the negotiation or performance of an agreement (contract) using Blockchain; the process is automated and can act as a substitute for legal contacts.

What are Smart

Contracts ?

Implication: Future contracts will be on a hybrid paper-plus- code model where contracts will be verified for authenticity via Blockchain and paper backups will be filed for traditional recourse.

How They Work

Use of smart contracts in music industry: Tracking ownership rights of music tracks on public Blockchain, real-time apportionment and payment of royalty as per set terms

Coding

Encryption and

Broadcasting

Network Consensus

Updating Distributed

Ledger

Monitoring Compliance

Example

Page 12: Quality Assurance in Blockchain - STC 2019qaistc.com/2017/wp-content/uploads/2017/12/stc-2017_final-present… · Quality Assurance in Blockchain. 2 Abstract. Blockchain is rapidly

12

First Generation Blockchain –Bitcoin

Page 13: Quality Assurance in Blockchain - STC 2019qaistc.com/2017/wp-content/uploads/2017/12/stc-2017_final-present… · Quality Assurance in Blockchain. 2 Abstract. Blockchain is rapidly

13

QA Landscape for Bitcoin

1

2

3

BitCoin Service Providers

ATMs Exchanges BTC Wallets

POS

Cards Gateways Merchant Portals

Escrow Service

Mining Pools

User 1 User 2 User 3

SideChains

Bitcoin MainChain

TestNet

QA Landscape for Bitcoin

End Consumer

Area of interest

Page 14: Quality Assurance in Blockchain - STC 2019qaistc.com/2017/wp-content/uploads/2017/12/stc-2017_final-present… · Quality Assurance in Blockchain. 2 Abstract. Blockchain is rapidly

14

QA POV for BTC Service Provider TransactionsEnd Customer Merchant BTC Service Provider Bitcoin Network Risk Analysis

Customer decides to pay with Bitcoin

1Payment Request API

call2

Response containing address (QR code) and

txn details4

Payment Response3

Bitcoin Payment5

Blockchain details6

Transaction validation request7

Transaction guarantee response

8

Payment Notification9

Payment Confirmation10

Payment BroadcastCheck Payment Status

Payment Status Response

U F

F

S

F S P

V

V

F

Direct to Bank Deposit

V

U Usability Testing F Functional Testing S Security Testing V Service Virtualization P Performance Testing A Automation Testing Services Testing

A

A A

Optional services like GAP600 that scores and guarantees bitcoin transactions as they are published on the network

Page 15: Quality Assurance in Blockchain - STC 2019qaistc.com/2017/wp-content/uploads/2017/12/stc-2017_final-present… · Quality Assurance in Blockchain. 2 Abstract. Blockchain is rapidly

15

Type of Testing for BitCoin Applications

Sl No Types of TestingBTC Service

ProviderMining Pools SideChains

1 UI testing2 Functional Testing3 Validation transaction elements in blockchain console4 Validate request/responses/risk analysis via APIs5 Performance testing6 Security testing7 Service virtualization8 Validate mining reward distribution algorithm9 Validation of consensus protocol10 Validation of two way peg - SPV algorithm11 Device testing12 Automation testing13 Multi-Signature logic testing

HighMediumLowNone

Page 16: Quality Assurance in Blockchain - STC 2019qaistc.com/2017/wp-content/uploads/2017/12/stc-2017_final-present… · Quality Assurance in Blockchain. 2 Abstract. Blockchain is rapidly

16

Second Generation Blockchain -Ethereum

Page 17: Quality Assurance in Blockchain - STC 2019qaistc.com/2017/wp-content/uploads/2017/12/stc-2017_final-present… · Quality Assurance in Blockchain. 2 Abstract. Blockchain is rapidly

17

Ethereum Overview

Email : Internet :: Bitcoin : Blockchain 2nd Generation Dapps

Key Tenets

1 Platform for any application building & hence SCALABLE

2 Dapps are JOINTLY OWNED

3 Smart Contract based & hence NO CENSORSHIP, DOWNTIME, 3RD PARTY INTERFERENCE

4 Based on ETHERS & TOKENS

Page 18: Quality Assurance in Blockchain - STC 2019qaistc.com/2017/wp-content/uploads/2017/12/stc-2017_final-present… · Quality Assurance in Blockchain. 2 Abstract. Blockchain is rapidly

18

QA Needs For Dapp LifecycleAccess testnet by changing config file

Connect to the testnet using Testrpc

Connect to testnet by selecting appropriate option when prompted

RUN A NODE IN ETH NETWORK

Install Ethereum Client

Install Ethereum Mist Wallet / Metamask Browser Extension

WALLET CREATION, SEND/RCV ETHER

JavaScript Console

Mist/Metamask Browser

JSON RPC API

CODE SMART CONTRACTS

Use Solidity

Use LLL

Use Serpent

COMPILE SMART CONTRACTS

SOLC Compiler

Browser-based Compilers

DEPLOY SMART CONTRACTS BUILD DAPPS

RUN & USE DAPPS

1

2

3

4

5

CALL SMART CONTRACTS WITH APIs

7

Access using APIs (Blockapps.net) & Browsers (Metamask, Alrthzero)

Ethereum Remix IDE, browser-based IDEs, Truffle, Embark, Dapple, Populus

Can claim ethers for testing using Ethereum Faucet

Smart Contracts UT

UI Testing of Dapps

Validation of synchronization

Validation of wallet integration

Validation of ether transaction from wallet

Functional TestingNon-Functional Testing

Validation of Transaction from BlockExplorer

ICO CROWD-SALE

API Testing60 6A Coin Contracts UT

Security TestingERC20 Compliance Testing

LEGEND No/Low Testing Need Medium-grade Testing Need High-grade Testing Need

Page 19: Quality Assurance in Blockchain - STC 2019qaistc.com/2017/wp-content/uploads/2017/12/stc-2017_final-present… · Quality Assurance in Blockchain. 2 Abstract. Blockchain is rapidly

19

Ethereum QA POV

Peer Sync Validation

• Comparing the latest block at the top of stats.ethdev.com with block number output in client node’s log

Unit Testing of Smart Contracts

• TDD approach using Truffle / Embark / Dapple / Populus

• UT of smart contracts through other contracts

Functional Testing

• Wallet Integration • Wallet Interface • Dapp Business Rules • Dapp Workflows• Cross-browser/device

Testing

Non-Functional Testing

• Performance Testing for txn. throughput validation

• Security Testing – key-based signing & token-based Dapp access

• Usability & Accessibility Testing

Transaction Validation

• Leverage BlockExplorer for Txn. Validation for

receiving/sending ether Txn. Validation of smart

contract deployment Txn. Validation of token

contract

User Interface Testing

• Validation of UI aspects like colour, logo, resolution, labels etc.

• Validation of navigability aspects

Compliance Testing

• ERC20 guidelines complianceAPI Testing

• Dapp API calls for internal smart contract methods

• Dapp API calls for interfacing application integration

Page 20: Quality Assurance in Blockchain - STC 2019qaistc.com/2017/wp-content/uploads/2017/12/stc-2017_final-present… · Quality Assurance in Blockchain. 2 Abstract. Blockchain is rapidly

20

Blockchain QA Catalogue

Page 21: Quality Assurance in Blockchain - STC 2019qaistc.com/2017/wp-content/uploads/2017/12/stc-2017_final-present… · Quality Assurance in Blockchain. 2 Abstract. Blockchain is rapidly

21

Blockchain QA CatalogueTesting

Categories Bitcoin Ethereum

White Box Testing

• Unit testing of SPV algorithm for SideChains• Unit testing of incentive distribution algorithm for

mining pools• Unit testing of the consensus protocol for SideChains

• Peer synchronization validation• Unit Testing of Smart Contracts (including Token Contracts)

Grey Box Testing• Validation of the REST APIs and JSON files for calls

between wallets, merchant applications, BTC Service Providers and BitCoin network

• Validation of APIso Dapp API calls for internal smart contract methodso Dapp API calls for interfacing application integration

Black Box Testing

• Transaction validation from Blockchain Console• Wallet integration and interface testing• Device Testing• UI Testing of Bitcoin Wallet• Functional validation of multi-signature escrow

services functionality• Integration and interface testing for merchant portals

and POS terminals and interfaces• Functional validation of direct to bank deposit feature

of BTC service providers and associated exchange rates

• Bitcoin ATM and cards testing and associated fees• Functional validation of SPV algorithm• Functional validation of incentive distribution algorithm

for mining pools

• Transaction Validation from BlockExplorer• Functional Testing of Dapps

o Wallet integration & interface testingo Business rules testingo Workflow testingo Cross-browser/device testing

• UI Testing of Dapps• ERC20 compliance validation

Non-Functional Testing

• Usability testing of BTC Wallets and merchant portals• Access controls testing for multi-user wallets• Security testing of transaction message signing and

encryption• Performance testing of transaction confirmation speed

settings• Service Virtualization

• Usability Testing of Dapps• Accessibility Testing of Dapps• Performance Testing for smart contract transaction

throughput validation• Security Testing

o Key based wallet accesso Token-based Dapp access

Page 22: Quality Assurance in Blockchain - STC 2019qaistc.com/2017/wp-content/uploads/2017/12/stc-2017_final-present… · Quality Assurance in Blockchain. 2 Abstract. Blockchain is rapidly

22

Emerging Areas

Page 23: Quality Assurance in Blockchain - STC 2019qaistc.com/2017/wp-content/uploads/2017/12/stc-2017_final-present… · Quality Assurance in Blockchain. 2 Abstract. Blockchain is rapidly

23

Emerging Areas In Blockchain

BLOCKCHAIN-AS-A-SERVICE

BLOCKCHAIN IoT

Gearing Towards

Smart Contracts +

Smart Devices

Key QA Needs

o Functional QA for connected devices o Device Interoperability Testingo Network Testingo Security Testing for device authentication,

data transmission etc.o IoT Analytics Testing

Key QA Needso Functional QA for decentralized

applicationso Performance / Security Testingo DR/ Failover / Resilience Testingo Inter operability and Integration

Testing

Page 24: Quality Assurance in Blockchain - STC 2019qaistc.com/2017/wp-content/uploads/2017/12/stc-2017_final-present… · Quality Assurance in Blockchain. 2 Abstract. Blockchain is rapidly

24

1. http://biccur.com/blog/2016/12/16/three-generations-of-blockchain/2. http://www.oodlestechnologies.com/bitcoin-ebook3. http://www.oodlestechnologies.com/blogs/Bitcoin-To-Get-More-Anonymous-With-The-New-BIP-Called-Dandelion4. https://bitcoinj.github.io/testing5. https://bitpay.com/docs/testing6. https://bitpay.com/integrations/drupal-commerce7. https://bitpay.com/integrations/opencart8. https://blockchain.info/api9. https://blockchain.info/api/api_receive10. https://en.bitcoin.it/wiki/Multisignature11. https://en.wikipedia.org/wiki/Mining_pool12. https://gendal.me/2014/10/26/a-simple-explanation-of-bitcoin-sidechains/13. https://medium.com/@BrettNoyes/public-permissioned-and-private-blockchains-3c32965e33c914. https://www.blocktrail.com/api15. https://www.programmableweb.com/news/46-bitcoin-apis-bitstamp-bitcoin-charts-markets-and-50btc/2013/06/1116. https://www.slideshare.net/Tracxn/tracxn-sector-report-bitcoin-sept-201417. https://www.youtube.com/watch?annotation_id=annotation_2972284497&feature=iv&src_vid=vWt9wRZ3Hhk&v=ASCz5u

Ls5EE18. https://www.youtube.com/watch?v=5ROp9Ac3UqE19. https://www.youtube.com/watch?v=LLZNvl90PC020. https://www.coindesk.com/price/21. https://medium.com/@ConsenSys/22. https://blockgeeks.com23. https://monax.io/docs/tutorials/solidity/solidity_4_testing_solidity/24. https://dzone.com/articles/what-blockchain-can-do-for-the-internet-of-things25. https://letstalkpayments.com/3-companies-leading-the-blockchain-as-a-service-baas-revolution/

Bibliography

Page 25: Quality Assurance in Blockchain - STC 2019qaistc.com/2017/wp-content/uploads/2017/12/stc-2017_final-present… · Quality Assurance in Blockchain. 2 Abstract. Blockchain is rapidly

25

Jibendu Narayan MazumderAssociate Director – Business DevelopmentCognizant Technology Solutions

Jibendu heads the Business Development group within theBanking and Financial Services (BFS) Quality Engineering andAssurance (QE&A) practice and has around 13 years ofindustry experience. He specializes in architecting andoverseeing implementation of transformational strategies & roadmaps for large and complex QA programs and has helpedseveral clients achieve their vision of becoming world class QAorganizations. Prior to joining Cognizant he worked withcompanies like PricewaterhouseCoopers and KPMG.

Jibendu holds BE and ME degrees in Electronics and TelecomEngineering from Jadavpur University and an MBA degree fromQuestrom School of Business, Boston University, USA

Author Biographies

Arpan SarkarSenior Manager – Business Development Cognizant Technology Solutions

Arpan has an industry experience of 10+ years and workswith Cognizant as a senior Business Developmentprofessional in the Banking and Financial Services (BFS)Quality Engineering and Assurance (QE&A) practice. Hisgamut of experience ranges from software development totechnology consulting, core banking and businessdevelopment.

Arpan holds a BE degree in Mechanical Engineering fromJadavpur University and an MBA degree from XLRIJamshedpur. Prior to joining Cognizant, he has worked withother esteemed institutions like Bank of Baroda &Pricewaterhouse Coopers.

Page 26: Quality Assurance in Blockchain - STC 2019qaistc.com/2017/wp-content/uploads/2017/12/stc-2017_final-present… · Quality Assurance in Blockchain. 2 Abstract. Blockchain is rapidly

26

Thank You!!!

Page 27: Quality Assurance in Blockchain - STC 2019qaistc.com/2017/wp-content/uploads/2017/12/stc-2017_final-present… · Quality Assurance in Blockchain. 2 Abstract. Blockchain is rapidly

27

Q & A