Тема доклада
Тема доклада
Тема доклада
KYIV 2019
How serverless makes Integration TDD a reality.
Why we do need it.
Sergey Medvedev
Enterprise Architect
.NET CONFERENCE #1 IN UKRAINE
Тема доклада
Тема доклада
Тема доклада
.NET LEVEL UP
Theory
.NET CONFERENCE #1 IN UKRAINE KYIV 2019
Тема доклада
Тема доклада
Тема доклада
.NET LEVEL UP
Why do we need testing?
.NET CONFERENCE #1 IN UKRAINE KYIV 2019
- Be able to refactor -> can improve code
- To detect bugs early -> can validate solution quickly
- Be confident in code -> do not be afraid of demo
- Be not afraid of code -> be able to refactor
Тема доклада
Тема доклада
Тема доклада
.NET LEVEL UP
Typical test
pyramid
.NET CONFERENCE #1 IN UKRAINE KYIV 2019
Тема доклада
Тема доклада
Тема доклада
.NET LEVEL UP
Typical test
pyramid
.NET CONFERENCE #1 IN UKRAINE KYIV 2019
Тема доклада
Тема доклада
Тема доклада
.NET LEVEL UP
Code dissected
.NET CONFERENCE #1 IN UKRAINE KYIV 2019
10% of code for 90% of cases
– Happy path
90% of code for 10% cases –
Sad and Bad paths
Тема доклада
Тема доклада
Тема доклада
.NET LEVEL UP
Where to start?
.NET CONFERENCE #1 IN UKRAINE KYIV 2019
Start with Integration test for Happy path!
Тема доклада
Тема доклада
Тема доклада
.NET LEVEL UP
Practice
.NET CONFERENCE #1 IN UKRAINE KYIV 2019
Тема доклада
Тема доклада
Тема доклада
.NET LEVEL UP
Part 2. Practice
.NET CONFERENCE #1 IN UKRAINE KYIV 2019
Domain: Block chain
Goal: Be able to find Nonce to complete block
Limitations:
- Too many competitors -> performance
- Unclear final infrastructure -> prototype
Requirements:
- Need highly scalable solution
- Implementation must follow the standard
Тема доклада
Тема доклада
Тема доклада
.NET LEVEL UP .NET CONFERENCE #1 IN UKRAINE KYIV 2019
OK, we need some basic theory
Тема доклада
Тема доклада
Тема доклада
.NET LEVEL UP
Bitcoin theory.
Simplified
Block chain
.NET CONFERENCE #1 IN UKRAINE KYIV 2019
More details: https://5minuteblockchain.com/2019/05/10/blockchain/
Тема доклада
Тема доклада
Тема доклада
.NET LEVEL UP
Bitcoin theory.
Simplified
Block structure
.NET CONFERENCE #1 IN UKRAINE KYIV 2019
More details: https://5minuteblockchain.com/2019/05/20/blocks-in-bitcoin/
Тема доклада
Тема доклада
Тема доклада
.NET LEVEL UP
Bitcoin theory.
Simplified
Block hash and nonce
.NET CONFERENCE #1 IN UKRAINE KYIV 2019
More details: https://en.bitcoin.it/wiki/Block_hashing_algorithm
Bitcoin hash: SHA256(SHA256(Block_Header))
where
- Block_Header is concatenation of HEX’ed values of the following fields
Field Purpose
Version Block version number
hashPrevBlock 256-bit hash of the previous block header
hashMerkleRoot 256-bit hash based on all of the transactions in the block
Time As seconds since 1970-01-01T00:00 UTC
Bits Current difficulty
Nonce
32-bit number (starts at 0, is incremented for each hash.
If Nonce overflows - extraNonce portion of the generation
transaction is incremented, which changes the Merkle
root.
Тема доклада
Тема доклада
Тема доклада
.NET LEVEL UP
Bitcoin theory.
Simplified
Merkle root
.NET CONFERENCE #1 IN UKRAINE KYIV 2019
More details: https://5minuteblockchain.com/2019/05/20/blocks-in-bitcoin/
Тема доклада
Тема доклада
Тема доклада
.NET LEVEL UP .NET CONFERENCE #1 IN UKRAINE KYIV 2019
Everything is clear.
Let’s start programming!
Тема доклада
Тема доклада
Тема доклада
.NET LEVEL UP .NET CONFERENCE #1 IN UKRAINE KYIV 2019
But, let’s imaging the solution first…
Тема доклада
Тема доклада
Тема доклада
.NET LEVEL UP
Solution. Vision
.NET CONFERENCE #1 IN UKRAINE KYIV 2019
Component diagram
Тема доклада
Тема доклада
Тема доклада
.NET LEVEL UP
Solution. Vision
.NET CONFERENCE #1 IN UKRAINE KYIV 2019
Activity diagram
Тема доклада
Тема доклада
Тема доклада
.NET LEVEL UP
Where to start?
.NET CONFERENCE #1 IN UKRAINE KYIV 2019
Start with Integration test for Happy path!
Тема доклада
Тема доклада
Тема доклада
.NET LEVEL UP
Step 1: Basic solution
.NET CONFERENCE #1 IN UKRAINE KYIV 2019
Тема доклада
Тема доклада
Тема доклада
.NET LEVEL UP
Step 1: Basic solution
.NET CONFERENCE #1 IN UKRAINE KYIV 2019
Outcome:
• Integration test in "unit test like" style
• we know basic interfaces, models, draft project structure
• we can "run" the solution!!!
• we can split work into at least 2 stream:
• protocol research to identify contracts and refine them -
IBitcoinClient
• continue work on architecture and design for mining - IMiner
Тема доклада
Тема доклада
Тема доклада
.NET LEVEL UP
Step 2: Infrastructure & Scaling prototype
.NET CONFERENCE #1 IN UKRAINE KYIV 2019
Тема доклада
Тема доклада
Тема доклада
.NET LEVEL UP
Step 2: Infrastructure
& Scaling prototype
.NET CONFERENCE #1 IN UKRAINE KYIV 2019
Outcome:
• Established architecture
• Approach on how to address key problem - scalability
• Can run performance tests
• Not afraid to refactor
• Can split work into multiple streams
• Can validate refactored solution
Тема доклада
Тема доклада
Тема доклада
.NET LEVEL UP
Next steps…
.NET CONFERENCE #1 IN UKRAINE KYIV 2019
Refactoring goals:
• align implementation with standards
• write unit tests to address Sad/Bad paths
• Improving infrastructure
• Etc.
Тема доклада
Тема доклада
Тема доклада
.NET LEVEL UP
Key takeaways
.NET CONFERENCE #1 IN UKRAINE KYIV 2019
Serverless
• Quick infrastructure prototyping
• Infrastructure as a Code (IaaC)
Integration test:
• Focus on end result
• Solution scaffolding
• Quick solution to run
• Early demo to engage business
• Framework to develop in parallel by multiple teams with confidence
• Write unit tests for stable parts
Тема доклада
Тема доклада
Тема доклада
.NET LEVEL UP .NET CONFERENCE #1 IN UKRAINE KYIV 2019
Instead of conclusion…
Тема доклада
Тема доклада
Тема доклада
.NET LEVEL UP
Don’t know how to proceed – write tests!
.NET CONFERENCE #1 IN UKRAINE KYIV 2019
Thanks and have a green tests!

.NET Fest 2019. Сергей Медведев. How serverless makes Integration TDD a reality. Why we do need it.