Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Truffle Test Tips and other
Search
nakajo2011
November 10, 2018
Programming
200
2
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Truffle Test Tips and other
nakajo2011
November 10, 2018
More Decks by nakajo2011
See All by nakajo2011
Plasma_Overview_gbec20180928.pdf
nakajo2011
0
95
What is Ethereum about tech layer
nakajo2011
0
410
The Ethereum design direction.
nakajo2011
0
94
Report of Devcon5 2019.10.17
nakajo2011
0
650
Compare of Libra and Ethereum
nakajo2011
1
470
What is Move language
nakajo2011
1
1.2k
blockchain-changing-and-issues
nakajo2011
4
590
Thinking Scalability from DEX
nakajo2011
0
120
Truffleの紹介_in_hicon2018.pdf
nakajo2011
3
330
Other Decks in Programming
See All in Programming
Webフレームワークの ベンチマークについて
yusukebe
0
170
IBM Bobを活用したレガシーアプリの最新化
oniak3ibm
PRO
1
200
「AIで開発し、AIを届ける」をEvalでつなぐ 〜AIネイティブに始めるプロダクト開発の実践〜 / Connecting "Develop with AI, deliver AI" with Eval
rkaga
4
5.1k
Java × distroless で 軽量なコンテナイメージを / Java on Distroless
contour_gara
0
550
Snowflake Summitでの新機能 CoCo / CoWork / snowflake-summit-2026-overall-what-new-coco
tatsuhiro
1
140
Spring Security 実践 ─ GraphQL APIで実務に役立つ 認証・認可 を学ぶ
wagyu
0
240
Oxlintのカスタムルールの現況
syumai
6
1.1k
OSもどきOS
arkw
0
570
ADKを使って簡単にAIエージェントを作ってみよう
k1mu21
0
270
Spec Driven Development | AI Summit Lisbon
danielsogl
PRO
0
190
Datadog × OpenTelemetry 入門と実践のあいだ
kn_to_maxpno
1
160
AIとASP.NET Coreで雑Webアプリを作った話
mayuki
0
650
Featured
See All Featured
Leo the Paperboy
mayatellez
7
1.8k
A better future with KSS
kneath
240
18k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
16
2k
How Software Deployment tools have changed in the past 20 years
geshan
0
34k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
38
2.9k
Understanding Cognitive Biases in Performance Measurement
bluesmoon
32
2.9k
Bridging the Design Gap: How Collaborative Modelling removes blockers to flow between stakeholders and teams @FastFlow conf
baasie
0
590
The State of eCommerce SEO: How to Win in Today's Products SERPs - #SEOweek
aleyda
2
11k
Principles of Awesome APIs and How to Build Them.
keavy
128
18k
Fireside Chat
paigeccino
42
4k
Darren the Foodie - Storyboard
khoart
PRO
3
3.4k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
Transcript
Copyright ©2018 chaintope, Inc. all rights reserved. hicon2018 Truffle Test
Tips 2018/11/10 chaintope, Inc Yukishige Nakajo
Copyright ©2018 chaintope, Inc. all rights reserved. Truffle Test Tips
1. 答え合わせ 2. Truffle Testの起動シーケンス 3. new()とdeployed() 4. HowTo Event Test 5. Dapp Projects test statistic 今日話すこと
Copyright ©2018 chaintope, Inc. all rights reserved. Truffle Test Tips
1. 答え合わせ 2. Truffle Testの起動シーケンス 3. new()とdeployed() 4. HowTo Event Test 5. Dapp Projects test statistic 今日話すこと
Copyright ©2018 chaintope, Inc. all rights reserved. Step - 2
1. 答え合わせ
Copyright ©2018 chaintope, Inc. all rights reserved. Step - 3
1. 答え合わせ
Copyright ©2018 chaintope, Inc. all rights reserved. # Analysis result
for BatchOverFlowToken: ~~ snip ~~ ==== Integer Overflow ==== SWC ID: 101 Type: Warning Contract: BatchOverFlowToken Function name: batchTransfer(address[],uint256) PC address: 2599 -------------------- In file: BatchOverFlowToken.sol:20 uint256(cnt) * _value -------------------- 1. 答え合わせ
Copyright ©2018 chaintope, Inc. all rights reserved. Step - 4
1. 答え合わせ
Copyright ©2018 chaintope, Inc. all rights reserved. Truffle Test Tips
1. 答え合わせ 2. Truffle Testの起動シーケンス 3. new()とdeployed() 4. HowTo Event Test 5. Dapp Projects test statistic 今日話すこと
Copyright ©2018 chaintope, Inc. all rights reserved. ・truffle embeded node
or ganache-cliの場合 2. Truffle Testの起動シーケンス
Copyright ©2018 chaintope, Inc. all rights reserved. ・ganache-cli以外のnode(like go-ethereum) 2.
Truffle Testの起動シーケンス
Copyright ©2018 chaintope, Inc. all rights reserved. Truffleではクリーンな環境を作成する https://truffleframework.com/docs/truffle/testing/testing-your-contracts#clean-room-environment 1.
ganache-cli使う時と、go-ethereumなどを使う時で動作 が異なるので注意 2. コンパイルが通らないとNG a. solidity編集中にちょっとテストを。。ができない 3. Migrationが通らないとNG a. migration fileを作っている場合は特に注意 2. Truffle Testの起動シーケンス
Copyright ©2018 chaintope, Inc. all rights reserved. Truffle Test Tips
1. 答え合わせ 2. Truffle Testの起動シーケンス 3. new()とdeployed() 4. HowTo Event Test 5. Dapp Projects test statistic 今日話すこと
Copyright ©2018 chaintope, Inc. all rights reserved. 3. new()とdeployed()
Copyright ©2018 chaintope, Inc. all rights reserved. Contract.new() • 新しくsmart
contractのインスタンスを生成する • つまりnetworkにdeployされる • 基本的にはこれを使って書く • new()するたびにcontract addressは変わるので注意 • deployに膨大なgasを使うContractの場合、gasが不足 するかもしれないので注意 • その場合はgasPrice=1とかにしちゃえばいい 3. new()とdeployed()
Copyright ©2018 chaintope, Inc. all rights reserved. Contract.deployed() • 事前にmigrationでdeployされたSmart
Contractのイン スタンスが帰ってくる • truffle devの時は基本的に使えない • ganache-cliの時は自分でmigrationを事前にする必 要がある 3. new()とdeployed()
Copyright ©2018 chaintope, Inc. all rights reserved. Contract.deployed() • あまり使ったことはない
• インスタンス取得にdeployする必要がないので高速 • でも前の状態を保持しているので注意が必要 3. new()とdeployed()
Copyright ©2018 chaintope, Inc. all rights reserved. Truffle Test Tips
1. 答え合わせ 2. Truffle Testの起動シーケンス 3. new()とdeployed() 4. HowTo Event Test 5. Dapp Projects test statistic 今日話すこと
Copyright ©2018 chaintope, Inc. all rights reserved. 4. HowTo
Event Test
Copyright ©2018 chaintope, Inc. all rights reserved. • Contract.EventName()なメソッドでEventは定義されて いる
• 引数は順番に次の3つ • topics : indexedをつけたparameterを絞り込む • term: Eventをキャッチするblock範囲 • callback: Filterに関係するeventが発生した時に呼ば れる 4. HowTo Event Test
Copyright ©2018 chaintope, Inc. all rights reserved. • Eventが発生したかどうかは結構重要 •
Eventが余分に発生していないこともチェックする必要が あある 4. HowTo Event Test
Copyright ©2018 chaintope, Inc. all rights reserved. Truffle Test Tips
1. 答え合わせ 2. Truffle Testの起動シーケンス 3. new()とdeployed() 4. HowTo Event Test 5. Dapp Projects test statistic 今日話すこと
Copyright ©2018 chaintope, Inc. all rights reserved. 5. Dapp Projects
test statistic
Copyright ©2018 chaintope, Inc. all rights reserved. • Research 20
Dapps • Make test projects: 4 • Not have test projects: 9 • Not found repository: 7 Has Test Project is 30 % 5. Dapp Projects test statistic
Copyright ©2018 chaintope, Inc. all rights reserved. ちなみに・・・・ TheDAO has
test …... https://github.com/slockit/DAO/tree/develop/tests 5. Dapp Projects test statistic
Copyright ©2018 chaintope, Inc. all rights reserved. 長時間ありがとうございました! おわり