Using Property-Based Testing in Blockchain …...Property based testing Blockchain properties Forall...

23
Using Property-Based Testing in Blockchain applications Thomas Arts

Transcript of Using Property-Based Testing in Blockchain …...Property based testing Blockchain properties Forall...

Page 1: Using Property-Based Testing in Blockchain …...Property based testing Blockchain properties Forall sequences of transactions: the total amount of tokens in the chain stays the same

UsingProperty-BasedTestinginBlockchainapplications

ThomasArts

Page 2: Using Property-Based Testing in Blockchain …...Property based testing Blockchain properties Forall sequences of transactions: the total amount of tokens in the chain stays the same

Anodeinadistributednetwork

Page 3: Using Property-Based Testing in Blockchain …...Property based testing Blockchain properties Forall sequences of transactions: the total amount of tokens in the chain stays the same
Page 4: Using Property-Based Testing in Blockchain …...Property based testing Blockchain properties Forall sequences of transactions: the total amount of tokens in the chain stays the same
Page 5: Using Property-Based Testing in Blockchain …...Property based testing Blockchain properties Forall sequences of transactions: the total amount of tokens in the chain stays the same
Page 6: Using Property-Based Testing in Blockchain …...Property based testing Blockchain properties Forall sequences of transactions: the total amount of tokens in the chain stays the same
Page 7: Using Property-Based Testing in Blockchain …...Property based testing Blockchain properties Forall sequences of transactions: the total amount of tokens in the chain stays the same
Page 8: Using Property-Based Testing in Blockchain …...Property based testing Blockchain properties Forall sequences of transactions: the total amount of tokens in the chain stays the same
Page 9: Using Property-Based Testing in Blockchain …...Property based testing Blockchain properties Forall sequences of transactions: the total amount of tokens in the chain stays the same

Anodeinadistributednetwork

Page 10: Using Property-Based Testing in Blockchain …...Property based testing Blockchain properties Forall sequences of transactions: the total amount of tokens in the chain stays the same

Anodeinadistributednetwork

Page 11: Using Property-Based Testing in Blockchain …...Property based testing Blockchain properties Forall sequences of transactions: the total amount of tokens in the chain stays the same

Anodeinadistributednetwork

Page 12: Using Property-Based Testing in Blockchain …...Property based testing Blockchain properties Forall sequences of transactions: the total amount of tokens in the chain stays the same

Anodeinadistributednetwork

Page 13: Using Property-Based Testing in Blockchain …...Property based testing Blockchain properties Forall sequences of transactions: the total amount of tokens in the chain stays the same

Anodeinadistributednetwork

AFORK

Page 14: Using Property-Based Testing in Blockchain …...Property based testing Blockchain properties Forall sequences of transactions: the total amount of tokens in the chain stays the same

Testingchallenges

Acomplexdistributedsystem,theusualchallengeofinfinitelymanypossiblestatesForexample:synchronization,differentkindsoftransactions,unpredictableorderofevents,cryptographyhardtomock,...

Page 15: Using Property-Based Testing in Blockchain …...Property based testing Blockchain properties Forall sequences of transactions: the total amount of tokens in the chain stays the same

QuickCheck

London2018 15

Instead of writing test cases.... they are automatically generated from properties Useful for Unit Testing, Component Testing, System Testing Less work, better testing, more fun

Page 16: Using Property-Based Testing in Blockchain …...Property based testing Blockchain properties Forall sequences of transactions: the total amount of tokens in the chain stays the same

QuickCheckinaNutshell

PropertiesTestcaseTestcaseTestcaseTestcaseTestcase

MinimalTestcase

Page 17: Using Property-Based Testing in Blockchain …...Property based testing Blockchain properties Forall sequences of transactions: the total amount of tokens in the chain stays the same

QuickCheck

APIundertest

Aminimalfailingexample

Page 18: Using Property-Based Testing in Blockchain …...Property based testing Blockchain properties Forall sequences of transactions: the total amount of tokens in the chain stays the same

DEMO

Page 19: Using Property-Based Testing in Blockchain …...Property based testing Blockchain properties Forall sequences of transactions: the total amount of tokens in the chain stays the same

Propertybasedtesting

BlockchainpropertiesForallsequencesoftransactions:thetotalamountoftokensinthechainstaysthesameInvalidtransactionsarenotacceptedonthechain(e.g.toolowfee,toolittleinaccount,etc)

Page 20: Using Property-Based Testing in Blockchain …...Property based testing Blockchain properties Forall sequences of transactions: the total amount of tokens in the chain stays the same

Propertybasedtesting

DistributedsystemForallpossiblenet-splits,crashesandforks,ifnetworkisstablelongenough,nodesagreeuponchain.

Page 21: Using Property-Based Testing in Blockchain …...Property based testing Blockchain properties Forall sequences of transactions: the total amount of tokens in the chain stays the same

Conclusions

Blockchaintesting•  generatedtestsfoundmanycornercases•  onsystemleveleasytoaddonefeatureandtestthousandsofnewtestsincludingfeature

•  hardtomockcrypto

Page 22: Using Property-Based Testing in Blockchain …...Property based testing Blockchain properties Forall sequences of transactions: the total amount of tokens in the chain stays the same

Questions

•  https://aeternity.com/•  https://github.com/aeternity/epoch/•  https://github.com/Quviq/epoch-eqc

Page 23: Using Property-Based Testing in Blockchain …...Property based testing Blockchain properties Forall sequences of transactions: the total amount of tokens in the chain stays the same

Anodeinadistributednetwork

synchronization