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
99
What is Ethereum about tech layer
nakajo2011
0
410
The Ethereum design direction.
nakajo2011
0
95
Report of Devcon5 2019.10.17
nakajo2011
0
650
Compare of Libra and Ethereum
nakajo2011
1
480
What is Move language
nakajo2011
1
1.3k
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
音楽のための関数型プログラミング言語mimiumにおける多段階計算の活用
tomoyanonymous
1
310
Observability in Practice:Grafana 與 Edge Device SRE 的那些事
blueswen
0
190
【やさしく解説 設計編・中級 #4】ルールの寿命と、システムの年輪
panda728
PRO
2
120
AI時代、エンジニアはどう育つのか -未経験エンジニアの成長を間近で見て考えたこと-
thasu0123
0
110
自作OSでスライド発表する
uyuki234
1
3.8k
SLOをサービス品質の共通言語にするために 取り組んできたこと
wakana0222
0
480
「なぜそう決めたのか」を残し続ける仕組み ― Notion AI カスタムエージェント × Slack連携による設計判断の自動記録 - NIKKEI Tech Talk #47
niftycorp
PRO
0
260
Skillsは効率化、Agentsは"自分の拡張"——Builder時代のエージェント編成(CC Night 2026)
wemra
1
210
気圧・高度・GPSを記録&可視化するアプリ「Koudo」を作った話
hjmkth
1
350
ECSアプリログをFireLensでコスト削減しようとしたけど諦めた話 in Fargate×Node.js
akihisaikeda
2
4.2k
技術記事、 専門家としてのプログラマ、 言語化
mizchi
14
7.4k
OS アップデート対応の取り組み方がもっと共有されてほしい
andpad
0
110
Featured
See All Featured
Amusing Abliteration
ianozsvald
1
220
Fantastic passwords and where to find them - at NoRuKo
philnash
52
3.8k
Beyond borders and beyond the search box: How to win the global "messy middle" with AI-driven SEO
davidcarrasco
3
180
Building a Modern Day E-commerce SEO Strategy
aleyda
45
9.1k
BBQ
matthewcrist
89
10k
Reality Check: Gamification 10 Years Later
codingconduct
0
2.2k
The Spectacular Lies of Maps
axbom
PRO
1
850
Paper Plane
katiecoart
PRO
2
52k
The Illustrated Children's Guide to Kubernetes
chrisshort
51
52k
Hiding What from Whom? A Critical Review of the History of Programming languages for Music
tomoyanonymous
3
920
Impact Scores and Hybrid Strategies: The future of link building
tamaranovitovic
0
330
Jess Joyce - The Pitfalls of Following Frameworks
techseoconnect
PRO
1
190
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. 長時間ありがとうございました! おわり